|
Quick Bash Tip: Environment Variables as Aliases
Samuel A. Falvo II
kc5tja -at- arrl.net 2010 Jun 25 11:04 PDT
I miss AmigaOS's ASSIGN command and its pseudo-devices which point to a directory of your choice (or, in the case of AmigaOS 2.x and later, multiple directories, thus eliminating the need for special environment variables like PATH). I also miss AmigaOS 2.x's ability to just type a directory name like a command to switch to that directory. Thankfully, I can regain a bit of both semantics using Bash's environment variables and quote expansions. I discovered long ago that you can synthesize aliases using environment variables. For example, $ export L='ls -ltr' $ $L I use this capability to create a number of directory aliases: $ cd extremely/long/path/here $ export D0="cd `pwd`" $ cd /another/long/path/goes/here $ export D1="cd `pwd`" At this point, I can now type in $D0 to jump immediately to .../extremely/long/path/here and $D1 to jump to /another/long/path/goes/here. Nifty!
You might be wondering why I first |