Trickmaker | Solution to hidden treasure of technology
Register or
Login with Facebook for commenting
RSS Trickmaker Home Page Print the Page Mobile Version Trickmaker Desktop Version Trickmaker
advertisement

Be a Guest Blogger

Saturday, January 1, 2011

Long Commands & Editing your .bashrc using Terminal

By
Pin It
advertisement
Share It
-----------------------






Long commands:

If you think you will never be able to remember the long command given in the above tip, you are right. This is where the role of “alias” comes in

alias short_name= ‘command_name arg1 arg2 arg3’

For example you can first form the following alias, by issuing the command in the termnial $ alias share_dir=’python-c “import SimpleHTTPServer;SimpleHTTPServer.test()”’and from now you can just type share_dir to share your current directory over the internet.

Alias are generally stored in your ~/.bashrc file, so you don’t have to manually make them for each terminal session. If you ever want to use alias without its expansion you can use the \ mark before it. For example, if you have an alias like the following alias ls=’ls --color=auto’ and want use ls without that --color option the you can issue the following:
$ \ls.

Editing your .bashrc:

The .bashrc file located in your home directory is the configuration file for your bash shell. It is executed every time you open a terminal window or invoke the shell. Therefore it is a great place to store your “alias”. To open it, type the following and hit return:

$ gedit ~/.bashrc

You can use it for fun stuff such as displaying a message every time your shell is started or for more useful stuff as making your default startup directory as your Desktop folder instead of your home directory when you invoke the shell. Both of these can be achieved simply by typing the following in your .bashrc. echo “message you want to display” cd Desktop. You can edit this file to include whatever fancies your, there are also some default alias present over there, especially related to the ls commandthat you can enable/disable by simply uncommenting/commenting them.

Customise your shell experience


Attachments:


If you LIKE this, then copy the below and put this in your WEBSITE or BLOG