Search code examples
bashterminalcygwin

Is there a way to hide the current directory while typing commands in Cygwin


It is kinda annoying to have the path show each time i write a command. Is there a way to make it so that only the $ sign shows when i execute a command by pressing enter?

Image


Solution

  • Sure, set your PS1 environment variable. See http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html

    To set this as default in cygwin:

    1. open bash.bashrc, for me that was in C:\tools\cygwin\etc\bash.bashrc
    2. Find the variable PS1 and change the lower case w to an upper case
    PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\W\[\e[0m\]\n\$ '
                                                   ^ this one
    
    1. Restart your terminal

    If you already have a high degree of context, for instance when working in vs code, you could change the entire variable to something very minimalist:

    PS1='\[\e]0;\w\a\]\[\e[32m\]\[\e[33m\]\W\[\e[0m\] $ '
    

    Which will produce something like this:

    enter image description here