Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 3 down vote accepted

Switch to a bash function:

function changelc {
    export PS1="$1"
}

And then, when tested:

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

Your Answer

 
discard

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.