0

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?

  • @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
3

Switch to a bash function:

function changelc {
    export PS1="$1"
}

And then, when tested:

$ changelc "rawr: "
rawr:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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