-2

if I am in: /1/2/3 I want prompt to show:

user /3:

If I am in : / I want the prompt to show:

user /:

This does not work ( when in /1/2/3 ) ( no slash )

PS1="\u \W: "

This does not work ( when in / ) ( shows double / )

PS1="\u /\W: "

What should I do ?

  • 3
    Are you sure you want to do that? It looks like a bad idea to me. – dr01 Feb 28 '17 at 16:15
  • @dr01, base folder with a slash. my mind is not really configured to believe /folder equates to a folder in the /. the slash also helps seperate the username from the foldername. easier on the eyes. – user218169 Feb 28 '17 at 16:16
  • The shell prompt will be the same whether you're in /home/penguen/stuff-to-delete/etc or in /etc. May (and likely will) be source of troubles. – dr01 Feb 28 '17 at 16:23
  • @dr01, it would be just a visual thing. I would know where I probably am. – user218169 Feb 28 '17 at 16:24
  • 1
    When your mind eventually reconfigure, you will hate what you have done. – ctrl-alt-delor Feb 28 '17 at 22:13
3

You could always use:

PS1='${USER=$(LOGNAME)} /${PWD##*/}: '

(which would also work in most other Bourne-like shells).

Your Answer

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