Thursday, December 3, 2009

setting a command shortcut in linux

The alias command helps to create your own custom shortcut name to a linux command. The format is -
alias name='command'
An example alias view all hidden files -
alias lh='ls -la'
An example alias to cd to the webserver root -
alias webroot='cd /usr/local/apache2/htdocs'
An example alias to run php in CLI mode -
alias php='/usr/local/apache2/php/bin/php'
To list all the available aliases, just type alias on the command line.

If you would want the aliases to be available everytime/forever, add them to your .bash_profile

Wednesday, December 2, 2009

mysql :: tab to autocomplete table names

If you use mysql client, and the table names are quite lengthy to type, you can enable mysql's auto-rehash option to use the auto-complete feature. This is similar to how one would use tab key for auto-completion in command prompt.

When invoking mysql client, issue auto-rehash option as below -
mysql -u uname -p --auto-rehash
However, do note that the mysql client will startup slowly as it requires to create the hash on the table names etc.