Hello everybody
I would like to start a scripts, trips and tricks tread.
If you use some nice little helper to help you do some tasks please paste them here. Please also state what kind of linux you run, because not every script might work on every box.
I would like to start the thread with pasting some of my alias from .bashrc
I am using debian/sid
Here my sysinfo:
Host/Kernel/OS "dellbox" running Linux 2.6.39-1.slh.1-aptosid-amd64 x86_64 [ aptosid 2011-01 Γῆρας - kde-full - (201102052200) ]
CPU Info 4x Intel Core i5 M 520 @ 3072 KB cache flags( sse3 ht nx lm vmx ) clocked at [ 1199.000 MHz ]
Videocard ATI M92 [Mobility Radeon HD 4500/5100 Series] [ ]
Network cards Broadcom NetLink BCM57780 Gigabit PCIe
Processes 238 | Uptime 1day | Memory 1982.7/3829.6MB | HDD WDC WD5000BEVT-7 Size 500GB (82%used) | Client Shell | Infobash v3.36
here my aliases:
# Easy extract
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
# Makes directory then moves into it
function mkcdr {
mkdir -p -v $1
cd $1
}
# Creates an archive from given directory
mktar() { tar cvf "${1%%/}.tar" "${1%%/}/"; }
mktgz() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; }
mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; }
### ALIASES
## Keeping things organized
alias ls='ls -hF --color' # add colors for filetype recognition
alias lx='ls -lXB' # sort by extension
alias lk='ls -lSr' # sort by size
alias la='ls -Al' # show hidden files
alias lr='ls -lR' # recursice ls
alias lt='ls -ltr' # sort by date
alias lm='ls -al |more' # pipe through 'more'
alias tree='tree -Cs' # nice alternative to 'ls'
alias ll='ls -l' # long listing
alias l='ls -hF --color' # quick listing
alias lsize='ls --sort=size -lhr' # list by size
alias lsd='ls -l | grep "^d"' #list only directories
## Moving around & all that jazz
alias back='cd $OLDPWD'
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
## Misc
alias edit='nano'
alias rm='mv -t ~/.local/share/Trash/files'
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -p -v'
alias df='df -h'
alias du='du -h -c'
alias reload='source ~/.bashrc'
alias biggest='BLOCKSIZE=1048576; du -x | sort -nr | head -10'
alias xpclean='find \( -iname '*ini' -o -iname '*db' \) -exec rm -f {} \;'
## App-specific
alias nano='nano -W -m'
alias wget='wget -c'
## Sudo fixes
alias install='sudo apt-get install'
alias remove='sudo apt-get remove'
## empty trash
alias trash="rm -fr ~/.Trash"
#du in init3
alias xdu='/etc/init.d/kdm stop; apt-get dist-upgrade'
Scripts, Tips And Tricks
Started by tomuchrice, 2011-06-09 20:24
|
3 replies to this topic
#2Posted 2011-06-09 21:05:49 Quote alias back='cd $OLDPWD' will do the same thing. some nice bash tricks: ctrl-r will let you search your history. just type what you're looking for and if there's any match, it will show up. hit ctrl-r again to go back deeper in history. putting a ! in front of a command will re-execute this command. as it could be dangerous (think rm for example), you can do: $ !command:p to print it first. still in bash, ctrl-a will bring you at the beginning of the line, ctrl-e, at the end. ctrl-w will delete the word at the left of the cursor. ctrl-u will delete everything at the left of the cursor, ctrl-k will delete everything at the right of the cursor. #3Posted 2011-06-13 06:44:52
Personally i like my editor with spice
alias edit='nana' But really i think the "Tab" key needs to be mentioned for the sake of how awesome bash is. #4Posted 2011-10-21 00:41:54
set -o vi
|
Sponsored by: |












