How often do you spend typing same long command again and again. It might just take few seconds but if you sum up it could comsume considerable amount of time over a day, weeks, month and even a year.
On Windows OS there is often a Keyboard Shortcut. But if you are a Linux user relying on the command line then you can use Bash Aliases (command line short cut) instead of typing a long command sequence.
Listed below are some popular and commonly used bash aliases that have been found throughout the web:
//Make ls display in columns and with a file type indicator (end directories with "/", etc) by default: alias ls="ls -CF" //We can also anticipate some typos to make it call the correct command: alias sl="ls" //for viewing large directory listings with the long format: alias lsl="ls -lhFA | less" //Frequently used directories alias home='cd /home/{$yourUserDirectory}' alias docs='cd /home/{$yourUserDirectory}/Documents' alias desk='cd /home/{$yourUserDirectory}/Desktop' alias www='cd /home/www/' //Quickly navigate directories alias .. ='cd ..' alias ... ='cd ../..' alias .4 = ‘cd ../../../../’ alias .5 = ‘cd ../../../../../’ //clear screen alias c = 'clear'
alias gs='git status' //gpullalias gpull=’git pull origin’ alias gpush='git push origin' alias gpom='git pull origin master' alias gb='git branch' alias gc='git checkout' alias gcm='git checkout master' alias ga='git add' alias gA='git add .' alias gcom='git commit -m' alias gm='git merge' alias gl='git log' alias gcb='git checkout branch' alias gbd='git branch -d' //for example gbD branchToBeDeleted alias gbD='git branch -D'
//Add below on .bashrc and type "extract" to execute command extract() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar e $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *) echo "'$1' cannot be extracted via extract()" ;; esac else echo "'$1' is not a valid file" fi }
kp () { ps aux | grep $1 > /dev/null mypid=$(pidof $1) if [ "$mypid" != "" ]; then kill -9 $(pidof $1) if [[ "$?" == "0" ]]; then echo "PID $mypid ($1) killed." fi else echo "None killed." fi return; }
alias busy="cat /dev/urandom | hexdump -C | grep "ca fe""