Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have a really long path to a folder, and I just want the string 'longlocation' to replace it in the terminal, I know I can edit the .bashrc file and add this command:

alias changelc='export PS1="longlocation"'

This will make the path be replaced by the string 'longlocation' whenever I enter the command 'changelc' in the terminal.

Now what I want is, if I enter the command 'changelc homefolder' then the long path be replaced by the string 'homefolder', or in general, any string that follows 'changelc'.

How do I achieve this?

share|improve this question
@Radu no. I want the new text that replaces the path to be variable, not constant. That is the main difference. – GrowinMan May 20 '13 at 14:46
up vote 3 down vote accepted

Switch to a bash function:

function changelc {
    export PS1="$1"

And then, when tested:

$ changelc "rawr: "
share|improve this answer
Perfect......... – GrowinMan May 20 '13 at 14:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.