Friday 11 February 2011

How to edit PATH?

How to edit PATH?

setting the path is very easy.

if you use a bash shell (as you probably do) just type

$ export PATH=$PATH:/im/appending/this/to/the/path
 
$export ROS_PACKAGE_PATH=$PWD:$ROS_PACKAGE_PATH

if you want to make the change came true everytime (otherwise you will have to type it everytime you open a new shell) there's a hidden file in your home:

~/.bashrc

Edit it with you text editor and append the line above to the file.
This file contains a bunch of command that are always executed everytime you start a shell. So edit it and then restart a shell and you will have all those command executed. If you appended the comand above you will have your path set too.

In this same file you can actually do some other cool stuff, for example you can set some alias.

Alias are very useful!!
I guess you get bored as anybody to have always to write long command like:

$ sudo apt-get install mypackage

you can then define an alias in your .bashrc like this :

alias ai='sudo apt-get install'

so you can istall stuff just typing:

$ ai mypackage

You can also define an other alias like

alias asrc='sudo apt-cache search'

so you can search a, for example, browser package from commanf line just typing:

$ asrc browser

and so on. There are already a few examples in the files that are commented, like

alias ll='ls -al'

which is pretty useful too, faster and better than usual ls. If you like it just take out the # from the baginning of the line to activate it.

Be careful to check if your alias already exists as a command anyway, or you risk to "hide" some useful command.

If you for example redefine cd

alias cd='ls'

everytime you use cd to change directory it will actually list the content of the directory. You probably shoudn't want to do that!