Cheatsheet: .bashrc

File ~/.bashrc is a simple configuration of Linux user where user can describe all shell instructions necessary for each session. It’s a frequent practice to leave useful command at this file, but aliases and functions looks much more suitable for this configuration file.

I won’t explain here the point of aliases and, of course, functions, because it’s everywhere on Internet. Instead just want to remind that you can apply your configuration changes without relogging. Just run the command…

source ~/.bashrc

which refreshes the user environment at the operating system.

So, here is my collection of Bash tricks automizing my workflow and home processes especially.


Code Description
alias mv="mv -i"
alias cp="cp -i"  
alias rm="rm -i"
Ask before removing or overwriting files. You can set it up for unconfident or fresh Linux users.
alias wowzago="cd /usr/local/WowzaStreamingEngine"
 alias wowzago_logs="cd /usr/local/WowzaStreamingEngine/logs"
 alias wowzago_conf="cd /usr/local/WowzaStreamingEngine/conf"
Fast movement to WowzaStreamingEngine directory
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
alias ......='cd ../../../../../'
Enables you to navigate the filesystem faster
extract () {
    if [ -f $1 ] ; then
        case $1 in
         *.tar.bz2)      tar xvjf $1 ;;
         *.tar.gz)       tar xvzf $1 ;;
         *.tar.xz)       tar Jxvf $1 ;;
         *.bz2)          bunzip2 $1 ;;
         *.rar)          unrar 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'..." ;;
        echo "'$1' is not a valid file!"
The pearl of bash scripting. Standardizing archive extraction for each popular compression format.
function mcd { mkdir -p "$1" && cd "$1";}
Allows to change directory right after its creation
export CDPATH="/usr/local/WowzaStreamingEngine"
Setup CDPATH to directory in which you go at the most frequent cases

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s