Thursday, 2 August 2007

Aliases - using .profile to improve your life

Sick of typing

cd /home/user/MyDocs/.documents

every time you want to navigate to the documents folder on your Nokia N800 using xterm? Sick of typing any long commands?

The good news is you don't have to if you don't want to. You can easily create your own commands, or aliases, which carry out long command line operations like the one above.

All you need to do is create a text file called .profile, which you store in the home directory, /home/user/

In this file, you list your aliases, like this:

alias docs='cd /home/user/MyDocs/.documents/
alias home='cd /home/user/
alias cls='clear'
alias msfc='/home/user/framework-3.0/msfconsole'

and any other commands you want to make aliases for.

Once you restart xterm, (make sure it's the latest version), you'll have these commands at your disposal. In other words,

typing

docs

will execute the command

cd /home/user/MyDocs/.documents/

leaving you with more time to play golf, swim, search for the ultimate grits, or whatever else takes your fancy.

Which is nice.

How do you make a text file? There's lots of ways to do this, but one easy way is to download MaemoPad using the application manager.

So:

1. Download MaemoPad and start it up

2. Go to File New to create a new file

3. Type in your aliases, as described above.

4. Save the file in your documents folder, giving it any name you like, such as aliases. You can't save a file in MaemoPad with a dot at the beginning of the name, so don't bother trying to name it .profile - it won't let you

5. Now we are going to move the file you just made into the /home/user directory, which is where it has to go, and rename it. Start up xterm, and type

mv /home/user/MyDocs/.documents/aliases /home/user/.profile

6. Pause to reflect that that was the last time you will ever have to go through the tedious process of typing "/home/user/MyDocs/.documents/" thanks to your new .profile file, restart your xterm, and go and have some healthy outdoor fun.

4 comments:

clark slater said...

Brilliant tip thanks! Profile works a treat, only problem is that I can't get vpn working from a user profile alias because it needs root access...and I can't seem to get any aliases working under gainroot.

I have tried editing /root/.profile as well as /etc/.profile but to no avail so far.

timothyd4y said...

Perfect. Thanks for the clear directions. Saving me hours!!

Anonymous said...

@darkslater: you need the latest xterm from maemo hackers repository I think. Then you should do an apt-get upgrade.

Benjamin Auffarth said...

The home command is unnecessary:

alias home='cd /home/user/

is equivalent to typing cd with no arguments.

 
© Copyright 2007-2008