diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-09 10:10:57 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-09 10:10:57 +1200 |
commit | 51b8554b56185a7b245b891d43646151735cd374 (patch) | |
tree | 8cce73993ab2ecfacce45c47e3a43a91af4c0424 /pdksh | |
parent | Copy prompt.bash to kshrc.d (diff) | |
download | dotfiles-51b8554b56185a7b245b891d43646151735cd374.tar.gz dotfiles-51b8554b56185a7b245b891d43646151735cd374.zip |
Remove VCS display from prompt for now
Requires porting; one major obstacle is the lack of a -d option for the
read command, but this may not even be needed.
Diffstat (limited to 'pdksh')
-rw-r--r-- | pdksh/kshrc.d/prompt.ksh | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/pdksh/kshrc.d/prompt.ksh b/pdksh/kshrc.d/prompt.ksh index bef80733..f7a187ed 100644 --- a/pdksh/kshrc.d/prompt.ksh +++ b/pdksh/kshrc.d/prompt.ksh @@ -21,7 +21,6 @@ prompt() { # Set up prompt, including optional PROMPT_PREFIX and PROMPT_SUFFIX # variables PS1='[\u@\h:\w]' - PS1=$PS1'$(prompt vcs)' PS1=$PS1'$(prompt job)' PS1=$PS1'$(prompt ret)' PS1='${PROMPT_PREFIX}'$PS1 @@ -95,164 +94,6 @@ prompt() { PS4='+ ' ;; - git) - # Bail if we have no git(1) - if ! hash git 2>/dev/null ; then - return 1 - fi - - # Attempt to determine git branch, bail if we can't - local branch - branch=$( { - git symbolic-ref --quiet HEAD || - git rev-parse --short HEAD - } 2>/dev/null ) - if [[ ! -n $branch ]] ; then - return 1 - fi - branch=${branch##*/} - - # Safely read status with -z --porcelain - local line - local -i ready modified untracked - while IFS= read -rd '' line ; do - if [[ $line == [MADRCT]* ]] ; then - ready=1 - fi - if [[ $line == ?[MADRCT]* ]] ; then - modified=1 - fi - if [[ $line == '??'* ]] ; then - untracked=1 - fi - done < <(git status -z --porcelain 2>/dev/null) - - # Build state array from status output flags - local -a state - if ((ready)) ; then - state[${#state[@]}]='+' - fi - if ((modified)) ; then - state[${#state[@]}]='!' - fi - if ((untracked)) ; then - state[${#state[@]}]='?' - fi - - # Add another indicator if we have stashed changes - if git rev-parse --verify refs/stash >/dev/null 2>&1 ; then - state[${#state[@]}]='^' - fi - - # Print the status in brackets with a git: prefix - (IFS= ; printf '(git:%s%s)' "${branch:-unknown}" "${state[*]}") - ;; - - # Mercurial prompt function - hg) - # Bail if we have no hg(1) - if ! hash hg 2>/dev/null ; then - return 1 - fi - - # Exit if not inside a Mercurial tree - local branch - if ! branch=$(hg branch 2>/dev/null) ; then - return 1 - fi - - # Safely read status with -0 - local line - local -i modified untracked - while IFS= read -rd '' line ; do - if [[ $line == '?'* ]] ; then - untracked=1 - else - modified=1 - fi - done < <(hg status -0 2>/dev/null) - - # Build state array from status output flags - local -a state - if ((modified)) ; then - state[${#state[@]}]='!' - fi - if ((untracked)) ; then - state[${#state[@]}]='?' - fi - - # Print the status in brackets with an hg: prefix - (IFS= ; printf '(hg:%s%s)' "${branch:-unknown}" "${state[*]}") - ;; - - # Subversion prompt function - svn) - # Bail if we have no svn(1) - if ! hash svn 2>/dev/null ; then - return 1 - fi - - # Determine the repository URL and root directory - local key value url root - while IFS=: read -r key value ; do - case $key in - 'URL') - url=${value## } - ;; - 'Repository Root') - root=${value## } - ;; - esac - done < <(svn info 2>/dev/null) - - # Exit if we couldn't get either - if [[ ! -n $url || ! -n $root ]] ; then - return 1 - fi - - # Remove the root from the URL to get what's hopefully the branch - # name, removing leading slashes and the 'branches' prefix, and any - # trailing content after a slash - local branch - branch=${url/"$root"} - branch=${branch#/} - branch=${branch#branches/} - branch=${branch%%/*} - - # Parse the output of svn status to determine working copy state - local symbol - local -i modified untracked - while read -r symbol _ ; do - if [[ $symbol == *'?'* ]] ; then - untracked=1 - else - modified=1 - fi - done < <(svn status 2>/dev/null) - - # Add appropriate state flags - local -a state - if ((modified)) ; then - state[${#state[@]}]='!' - fi - if ((untracked)) ; then - state[${#state[@]}]='?' - fi - - # Print the state in brackets with an svn: prefix - (IFS= ; printf '(svn:%s%s)' "${branch:-unknown}" "${state[*]}") - ;; - - # VCS wrapper prompt function; print the first relevant prompt, if any - vcs) - local vcs - for vcs in "${PROMPT_VCS[@]:-git}" ; do - if prompt "$vcs" ; then - return - fi - done - ;; - # Show return status of previous command in angle brackets, if not zero ret) if ((PROMPT_RETURN > 0)) ; then |