Some .bashrc tips to make your life easier

Your .bashrc file can be enhanced with a few tweaks to make your life easier. Here come some tips and shortcuts to display or get info, gathered from various sources.

Simple colors & PS1 improvement

To easily pimp your terminal with colors, add their name equivalent to your .bashrc and use them in the PS1 line. The result will be far more readable.

# Simple colors
BGREEN='\[33[1;32m\]'
GREEN='\[33[0;32m\]'
BRED='\[33[1;31m\]'
RED='\[33[0;31m\]'
BBLUE='\[33[1;34m\]'
BLUE='\[33[0;34m\]'
NORMAL='\[33[00m\]'
if [ "$color_prompt" = yes ]; then
PS1="${NORMAL}[${BBLUE}\A${NORMAL}][${BGREEN}\u${NORMAL}:${RED}\w${NORMAL}] ${BRED}\$ ${NORMAL}"
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

Usefull aliases

You may want to put your aliases in a specific file called from your .bashrc:

if [ -f ~/.bash_aliases ]; then
 . ~/.bash_aliases
 fi

Now, create your .bash_aliases file and complete it with any alias you need. Here come a few ideas:

#=====================================#
# ~/.bash_aliases | Personnal aliases #
#=====================================#

# System tools
alias update='sudo apt-get update'
alias install='sudo apt-get install'
alias app='apt-cache policy'
alias bye='sudo /sbin/shutdown'

# Quick access
alias ..='cd ..'
alias ...='cd ../../../'
alias dl='cd ~/Downloads/'
alias doc='cd ~/Documents/'

# Infos
alias c='clear'
alias disc='df -h /home/'
alias topp='top -b | grep'
alias ping='ping -c 5 www.google.fr'
alias f="find . |grep "

# Config files
alias bash='vim ~/.bashrc'
alias al='vim ~/.bash_aliases'
alias dock='vim .config/plank/dock1/settings'
alias note='vim ~/notes'

# Programs
alias moc='mocp -m /home/raphael/Music -T transparent-background'

Links

Advertisements

Comments are closed.

Create a free website or blog at WordPress.com.

Up ↑