Time Saving Bash Tricks

- - posted in bash, cli, ssh

This is a followup from the lightning talk 5 Time Saving Bash Tricks that I gave at DevOpsDays, Bangalore 2011.

SSH multiplexing

Adding these to ~/.ssh/config or /etc/ssh_config will allow you to multiplex one SSH connection to open multiple terminals, multiple scp and git push without having to authenticate over keys or passwords.

Host \*
ControlMaster auto
ControlPath /tmp/%r0%h:%p

Ensuring Bash Hisory across multiple sessions

Add this to ~/.bashrc

shopt -s histappend

The rabbit hole of directories

Remember to use pushd and popd when in deeply working with many directories.

grizzly:~$ pushd /var/log/apache2/
/var/log/apache2 ~
grizzly:apache2$ # do something
grizzly:apache2$ pushd /etc
/etc /var/log/apache2 ~
grizzly:etc$ # do something else
grizzly:etc$ popd
/var/log/apache2 ~
grizzly:apache2$ popd
~
grizzly:~$

In fact, you can effectively use pushd instead of cd.

Background tail processes to share STDOUT and STDERR with any REPL

tail -f httpd.log &

Then start the REPL, or continue working on the shell (which is also a REPL).

And finally, some copypasta on the Shell

Note that these work with the emacs-readline, which is the default configuration in most distributions (including OS X).

Comments