Shell leads the willing and drags along the reluctant “ -maybe Seneca

Nowadays, working with a shell is an inherent part of the everyday life of a software engineer, therefore, I would dare to say that any “trick” that can improve the general speed or knowledge regarding this matter is rather important.


Without further ado, I will share a compilation of different commands which has helped me greatly.

10 Bash Commands to Improve Speed

  1. Go Back to the Previous Directory

cd -

2. Execute Your Last Command

!!

3. Check the Return Code of Your Last Command

echo $? 

4. Get the Process ID

# echo $SHELL
ps -p $(echo $$)
PID TTY          TIME CMD
26719 pts/0    00:00:01 bash

5. Execute the Emulating Tree Command

alias tree='function tree(){ find ${1:-.} | sed -e "s/[^-][^\/]*\//  |/g" -e "s/|\([^ ]\)/|-\1/"; unset -f tree;}; tree'

6. Ad-hoc YAML Linter

alias ymllint='python -c "import sys,yaml as y;y.safe_load(open(sys.argv[1]))"'

7. Ad-hoc JSON Linter

alias jsonl='jq "." >/dev/null <'

8. Set the Sell

# echo $SHELLOPTS to check
set -o vi
set - o emacs

9. Globbing

# * matches any sequence of characters
ls a*

10. Create a Nested Structure

mkdir -p provisioning/{datasources,notifiers,dashboards/backup}

# will create
.
└── provisioning
    ├── dashboards
    │   └── backup
    ├── datasources
    └── notifiers

11. Reverse search

" Shell alone is eternal, perpetual, immortal" - maybe Schopenhauer