1

Can the prompt be hidden if the directory has no change after the last command executed? Show only the $, show the path only if the directory was changed in the last command. My ps1:

precmd () { __git_ps1 "%B%F{blue}$shellEmulator%f%F{cyan}%3d%f%b" "%F{green}
$ %f" "|%s"}

The shell I am using is zsh.

4
  • 1
    Why would you like that? That would just be annoying. For example, you run dir and then you'll have to scroll up to see where you are if you forget
    – Gantendo
    Apr 25, 2023 at 13:51
  • 1
    Hello, which shell? Add it as a tag please.
    – Destroy666
    Apr 25, 2023 at 13:54
  • Because my screen is small, and I am finding way to press less c-l, umm... maybe a silly reason. Apr 25, 2023 at 14:13
  • 1
    precmd is not ps1, but it seems like a good place to start – have you tried adding anything into it yet? e.g. making it store the current $PWD? Apr 25, 2023 at 14:38

1 Answer 1

0

I think precmd() is a good starting point. A minimalistic proof-of-concept could be:

precmd() {
  if [[ $PWD_PREV == $PWD ]]; then
    PS1="$ "
  else
    PS1="%~ $ "
    PWD_PREV=$PWD
  fi
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .