02 September 2010

Setting up your bash prompt for colours, aliases and other things

One of the little joys in life is to have a nice coloured bash prompt and a lot of aliases to simplify navigation in bash.

I've placed most of my commands in ~/.bash_aliases.


To know how to colour a terminal, see this and this
Being able to create aliases to commands is one of the best things I've found out about the bash shell. You'll find a similar functionality in MS-DOS, called doskey.

These are the aliases I use in bashrc. Typing "cd .." became so annoying that the alias "f" (for "fall" to the below directory) became a handy tool.

# User specific aliases and functions
alias bashrc='gedit ~/.bashrc;source ~/.bashrc;echo bashrc has been sourced'
alias bashaliases='gedit ~/.bash_aliases;source ~/.bash_aliases;echo bash_aliases has been sourced'    
alias bashprofile='gedit ~/.bash_profile;source ~/.bash_profile;echo bash_profile has been sourced'
alias aliases="clear;cat ~/.bash_aliases|grep --color \"alias\""
alias home='cd;ls;pwd'
alias root='cd /;ls;pwd'
alias die='halt -p'
alias desktop='cd ~/Desktop;ls;pwd'
alias f='cd ..;ls;pwd'
alias ff='cd ../..;ls;pwd'
alias fff='cd ../../..;ls;pwd'
alias ffff='cd ../../../..;ls;pwd'
alias fffff='cd ../../../../..;ls;pwd'
alias ffffff='cd ../../../../../..;ls;pwd'
alias fffffff='cd ../../../../../../..;ls;pwd'
alias ffffffff='cd ../../../../../../../..;ls;pwd'
alias home='cd;ls;pwd'
alias root='cd /;ls;pwd'
alias shtdn='halt -p'
#alias startsql="service mysqld start"
#adding a hibernate option which I found while using Fedora20
alias hibernate='systemctl hibernate'
#--- For a coloured, customised prompt
# 0 is for non-bold colour. Replace it with 1 for bold
# 31m is the colour
# \u makes it show the username
# \h makes it show the address
# \W makes it show the directory name. Use \w for showing the full path
#export PS1="\e[0;32m[\u@\h \W]\$ \e[m"
#export PS1="\e[1;32m[\W] \e[m"
#alias br='xrandr --output eDP1 --brightness 0.5'
#alias brightness='xrandr --output eDP1 --brightness '
alias night='sct 2300'
alias day='sct 4000'
alias normal='sct'
#to shift memory from swap space to RAM
alias swap='sudo swapoff -a; sudo swapon -a'
#to convert webp files to png
alias convertwebp="find ./ -name '*.webp' -exec dwebp {} -o {}.png \;; find . -type f -name '*.webp' -delete"
#irest is a program I created
#alias restartirest='kill -9 $(pgrep -f 'irest');cd;nohup java -jar /someFolder/iRestTracker/irest/dist/irest.jar&'
alias killirest="kill -9 $(pgrep -f 'iRest')"
alias pauseirest="kill -STOP $(pgrep -f 'iRest')"
alias resumeirest="kill -CONT $(pgrep -f 'iRest')"
alias ireststatus="ps -aef | grep iRest"
alias irest="cd ~;python -B /home/nav/iRest/main.py >> iRestErrors.log"
alias ufw='sudo ufw'

alias pushall="git push --all origin"
alias pullall="git pull --all"
alias commit='git add -A && git commit -m '
 
alias deb='sudo dpkg -i '
alias showinstalled='sudo apt list --installed'
alias install='sudo apt-get install -y '
alias uninstall='sudo apt-get remove -y '
alias update='sudo apt-get update '
alias aptsearch='apt-cache search ' 
alias autoremove='sudo apt -y autoremove'

alias updatedb='sudo updatedb'
 
#To play a beep in Ubuntu after running some program from the bash prompt.
alias beep='paplay /usr/share/sounds/freedesktop/stereo/complete.oga'
 
#To use wipe, first install via sudo apt-get install -y wipe
alias shred='wipe -rfiqQ 1 '

alias invert='xcalib -i -a'
alias sysinfo='inxi -Fxz;sudo get-edid | parse-edid;sudo lshw -c memory'
alias osinfo='lsb_release -a'
 
alias netio='sudo nethogs'
alias gedit='xed' #for Linux Mint


Say thank you or donate