Using git -prompt.sh PROMPT_COMMAND to Change the Cygwin Header Bar

To better customize Cygwin's command line and terminal window, I followed this git-prompt guide: https://web.archive.org/web/20160304014517/http://ithaca.arpinum.org/2013/01/02/git- prompt.html

Everything in the manual works except for the last prompt, located under the heading "One Last Thing", which offers the following line to change your PS1 and set the title bar of your terminal:

PROMPT_COMMAND='__git_ps1 "\u \W" "\\\$ " " [%s $(get_sha)] "; set_titlebar "$USER@${HOSTNAME%%.*} $(get_dir)"'

However, when I add this line to my .bashrc, I get the following error:

-bash: set_titlebar: command not found

I have searched everywhere for a solution to why this is happening, but I have come to a standstill. I am using mintty 1.2-beta1 (x86_64-pc-cygwin), my terminal is installed on xterm and using the script git-prompt.sh.

+4
source share
1 answer

set_titlebar It is not a built-in Bash function, but a user-defined function of the author of the article.

At the top of the related guide, the author refers to a previous post:

Many people have written or adapted complex scripts to get information from git, drag and drop this data, and then put it in the invitation of their shells. (Ive done it myself.) However, [...]

This is a link to a script where it is set_titlebardefined:

function set_titlebar {
    case $TERM in
        *xterm*|ansi|rxvt)
            printf "\033]0;%s\007" "$*"
            ;;
    esac
}

You will need to enable this function, one similar or write yourself.

+4
source

Source: https://habr.com/ru/post/1530705/


All Articles