{"thread":{"id":"43291","subject":"Re: StGit-enabled bash-prompt","startedAt":"2006-10-26T21:17:29Z","lastAt":"2006-10-27T18:54:04Z","messageCount":3,"participants":["Ben Clifford","Robin Rosenberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"294843","messageId":"200610262317.30209.robin.rosenberg.lists@dewire.com","threadId":"43291","inReplyTo":null,"subject":"StGit-enabled bash-prompt","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2006-10-26T21:17:29Z","receivedAt":"2006-10-26T21:17:29Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Hi,\n\nI added the following snippet to my .bashrc to help me keep track of what \npatch I'm working on.  I got annoyed at typing stg top/stg series all the \ntime.\n\nThis changes the bash prompt to include the current git branch and the top \nstgit patch to the prompt.\n\nOf course you will read and understand this code. I don't know how good an \nidea it is to use the DEBUG trap this way.\n\nNO WARRANTY (as always)\n\n-- robin\n\nif [ \"$PS1\" ]; then\n    function stgtag\n    {\n        br=$(stg branch 2>/dev/null)\n        top=$(stg top 2>/dev/null)\n        if [[ -n \"$br$top\" ]];then\n            echo \" [$top@$br] \"\n        fi\n    }\n    trap 'PS1=\"\\u@\\h$(stgtag)\\w]\\$ \"' DEBUG\n\n"},{"id":"294245","messageId":"Pine.LNX.4.64.0610270957020.9123@dildano.hawaga.org.uk","threadId":"43291","inReplyTo":"200610262317.30209.robin.rosenberg.lists@dewire.com","subject":"Re: StGit-enabled bash-prompt","fromName":"Ben Clifford","fromEmail":"benc@hawaga.org.uk","sentAt":"2006-10-27T10:01:15Z","receivedAt":"2006-10-27T10:01:15Z","isPatch":false,"sender":{"key":"benc@hawaga.org.uk","avatar":"https://gravatar.com/avatar/c7ce083471287f8e77b69dd147f757799d1efdd740727fd7e3003f33e88be898?d=mp&s=160"},"body":"\nOn Thu, 26 Oct 2006, Robin Rosenberg wrote:\n\n> Of course you will read and understand this code. I don't know how good an \n> idea it is to use the DEBUG trap this way.\n\nI set my prompt without using it, with something approximating this\nbeing defined in my .bash_profile. I think the use of ' instead of \" \ncauses evaluation of __prompt_githead be delayed until the prompt is \ndisplayed.\n\n\n  PS1='$(__prompt_githead) '$PS1\n\n  __prompt_githead() {\n  PS_GIT=$(git-symbolic-ref HEAD 2>/dev/null) || exit\n  echo -n \" $(basename $PS_GIT)\" \n  }\n\n-- \n"},{"id":"298427","messageId":"200610272054.04948.robin.rosenberg.lists@dewire.com","threadId":"43291","inReplyTo":"Pine.LNX.4.64.0610270957020.9123@dildano.hawaga.org.uk","subject":"Re: StGit-enabled bash-prompt","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2006-10-27T18:54:04Z","receivedAt":"2006-10-27T18:54:04Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"fredag 27 oktober 2006 12:01 skrev Ben Clifford:\n> On Thu, 26 Oct 2006, Robin Rosenberg wrote:\n> > Of course you will read and understand this code. I don't know how good\n> > an idea it is to use the DEBUG trap this way.\n>\n> I set my prompt without using it, with something approximating this\n> being defined in my .bash_profile. I think the use of ' instead of \"\n> causes evaluation of __prompt_githead be delayed until the prompt is\n> displayed.\n\nAhh, ofcourse. Thanks.\n\n"}]}