BASH (The Bourne-again shell)

Nitin Shukla
3 min readAug 7, 2020

Hello again….Yep, it has been a while.

Here are the few things that I learned and implemented to increase my productivity. It could be interesting to those who woke up every morning and open their “Terminal” to work. With time, I’ll add more stuff here.

Include this stuff (But the kid is not my son) in your .bash_profile (open -e .bash_profile) if you want see those effects ;)

# — -Home — — — — — — — — —
oragne=$(tput setaf 166);
yellow=$(tput setaf 228);
green=$(tput setaf 71);
white=$(tput setaf 15);
bold=$(tput bold);
reset=$(tput sgr0);

PS1=“\[${bold}\]\[${oragne}\]nits”;
PS1+=“\[${green} \]\W ->”;
PS1+=“\n”
PS1+=“\[${white}\]\$ \[${reset}\]”;
export PS1;

# Highlight the user name when logged in as root.
if [[ “${USER}” == “root” ]]; then
userStyle=“${red}”;
else
userStyle=“${orange}”;
fi;

Good enough to beautify your terminal. Thanks to
Corey Schafer.

I am using Mac but the idea can be easily translated to Linux.

  1. I normally keep everything in Document folder, thats like my work station. So I wanted to write a function which can put into Document folder.

function ws()
{
cd $path/Documents
}

Create a folder and jumps inside

function mkcd ()
{
mkdir -p — “$1” && cd -P — “$1”
}

Copy remotely and to the given destination

function super_scp() {
scp -r ${1} /Users/${2}
}
alias scp=super_scp

2. Something can be very handy if you remember the keyword.. like

# — — # MAKE TERMINAL BETTER# — —— — — — — — — — —

alias c.=’cd ..’
alias ..=’cd ../’ # Go back 1 directory level
alias …=’cd ../../’ # Go back 2 directory levels
alias .3=’cd ../../../’ # Go back 3 directory levels
alias .4=’cd ../../../../’ # Go back 4 directory levels
alias edit=’subl’ # edit: Opens any file in sublime editor
alias f=’open -a Finder ./’ # f: Opens current directory in MacOS Finder
alias ~=’cd ~’ # ~: Go Home
alias c=’clear’ # c: Clear terminal display

trash () { command mv “$@” ~/.Trash ; } # trash: Moves a file to the MacOS trash

alias py=’python’

alias qfind=“find . -name” # qfind: Quickly search for file

# — — #git branch in your command# — — — — — — — — — —

# GIT
alias g=“git”
alias gs=“git status”
alias gin=“git int”
alias gad=“git add”
alias gm=“git checkout master”
alias gd=“git diff”

Conclusion

These are few tips to customize your Terminal. There is much more you can do to customize your Terminal. I’m still learning and implement tricks when I think it is necessary. I do not want to overdo it. The idea is, it should be good enough and natural to use.

! — — — — — — — — — — — — — — — —

Nitin Shukla

Bologna 7/8/2020

! — — — — — — — — — — — — — — — -

--

--

Nitin Shukla

My interests are in: Science&technology, Programming Micro-Macro Economy, Geo-politics, Renewable energy, Learning new skills, Playing and watching Tennis.