Bash/Shell repeating commands
There are many small habits that can make your command-line work safer and more predictable. Here are some practical tips:
Repeating commands:
Check the default shell: echo $SHELL
Repeat my last command with !!
Example:
$ rm -rf igor/
#Oh no! Missing sudo
$ sudo !!
Go to your home directory with cd ~ or just cd. Go to your previous directory with cd -.
Example:
$ cd /etc/skel
$ cd
$ pwd
# Expecting /home/igor
$ cd -
$ pwd
# Expecting /etc/skel
Repeat the last command, but swap characters with ^old^new
Example:
$ echo "Hello, world!"
$ ^world^Bash
# Output: Hello, Bash!
$ dursh en module1 module2 module3
$ ^dursh^drush