Zach Wasserman created something I've been wanting for a long time and have been to lazy to implement myself: the 'go' command.
Often, I'll be looking for some file on the command line, I'll type cd and be tab-completing and end up getting to the file itself. Of course, "cd ~/my/stuff/file.txt" doesn't make much sense.
bash: cd: stuff.txt: Not a directory
I end up changing cd to vim, but it's kind of a waste. The solution, then, is to follow the 'click on something' paradigm from modern GUIs: clicking on a directory opens that directory and shows its contents; clicking on a file opens that file in whatever the default for that file type is. For simplicity, let's just use the $EDITOR for files.
Behold, the 'go' command:
go()
{
if [ -f $1 ]
then
$EDITOR $1
else
cd $1 && ls
fi
}
Add it to your .bashrc file. http://zwass.wordpress.com/2011/03/16/the-go-command/ for details.
Thanks, Zach and Andrew.
Tags: #technical