Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

how to remove path of my command line?

Writer Andrew Henderson

When I start to enter in different folder the path is registered in my command line and I don't know how to remove it. I am almost sure my question wasn't clear. An example is always better. Once in home:

luiz@feynman:~$ cd Music/
luiz@feynman:~/Music$ cd Beatles/
luiz@feynman:~/Music/Beatles$ cd 17\ Love/

What is annoying me is this :~/Music or ~/Music/Beatles before $. It seems a stupid problem but when I need to enter into many folders is really a big problem. I guess I should change something in my .bashrc, but I don't know what.

Thanks

2

3 Answers

look at and edit the value of $PS1. It contains the template for your prompt.

Something like '\u@\h \w $ ' is typical, in this the '\w' is a placeholder for the working directory. SettingPS1'\u@\h $ '` would remove the working directory.

For full details on how to set PS1, consult the bash man page

1

You can use this prompt for PS1

PS1='\u@\h: $(x=$(pwd); l=${#x}; if [ $l -lt 24 ]; then echo $x; else echo ... ${x: -20};fi;)\$'

Just put this at the very end of your .bashrc. From now every time you go to a path with a length greater than 24 it'll show the last 20 characters preceding by .... In fact when we go deep down a directory only the last directories become significant. Because we already know where we started.

1

Or you could use PROMPT_DIRTRIM to only include the last couple of directories in the prompt.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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