fb prompt for mercurial
This commit is contained in:
@@ -51,7 +51,6 @@ if [ -n "$PS1" ]; then
|
|||||||
|
|
||||||
[ -n "$(which svn)" ] && prompt_check_svn=true
|
[ -n "$(which svn)" ] && prompt_check_svn=true
|
||||||
[ -n "$(which git)" ] && prompt_check_git=true
|
[ -n "$(which git)" ] && prompt_check_git=true
|
||||||
[ -n "$(which hg)" ] && prompt_check_hg=true
|
|
||||||
|
|
||||||
if [ -n "$ZSH_VERSION" ]; then
|
if [ -n "$ZSH_VERSION" ]; then
|
||||||
s_host="%m"
|
s_host="%m"
|
||||||
@@ -68,6 +67,14 @@ if [ -n "$PS1" ]; then
|
|||||||
# Turn on checkwinsize
|
# Turn on checkwinsize
|
||||||
shopt -s checkwinsize
|
shopt -s checkwinsize
|
||||||
fi
|
fi
|
||||||
|
# For hg from FB
|
||||||
|
if [ -f /usr/share/scm/scm-prompt.sh ]; then
|
||||||
|
source /usr/share/scm/scm-prompt.sh
|
||||||
|
prompt_check_hg=true
|
||||||
|
elif [ -f /opt/facebook/hg/share/scm-prompt ]; then
|
||||||
|
source /opt/facebook/hg/share/scm-prompt
|
||||||
|
prompt_check_hg=true
|
||||||
|
fi
|
||||||
|
|
||||||
# zsh
|
# zsh
|
||||||
function precmd() {
|
function precmd() {
|
||||||
@@ -82,18 +89,27 @@ if [ -n "$PS1" ]; then
|
|||||||
prompt_extra=""
|
prompt_extra=""
|
||||||
PS1=""
|
PS1=""
|
||||||
if [ "$USER" != "vahagnk" -a "$USER" != "vahagn" ]; then
|
if [ "$USER" != "vahagnk" -a "$USER" != "vahagn" ]; then
|
||||||
PS1+="${c_user}${s_user}@" # username@
|
PS1+="\[${c_user}\]${s_user}@" # username@
|
||||||
fi
|
fi
|
||||||
PS1+="${c_host}${s_host}:" # hostname
|
PS1+="\[${c_host}\]${s_host}:" # hostname
|
||||||
PS1+="${c_time}${s_time}" # time
|
PS1+="\[${c_time}\]${s_time}" # time
|
||||||
PS1+=" ${c_cwd}${s_cwd}" # working_dir
|
PS1+=" \[${c_cwd}\]${s_cwd}" # working_dir
|
||||||
#
|
#
|
||||||
# git branch if exist
|
# git branch if exist
|
||||||
#
|
#
|
||||||
if [ -n "$prompt_check_git" ]; then
|
if [ -n "$prompt_check_git" ]; then
|
||||||
local git_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null | tr -d ' ')
|
local git_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null | tr -d ' ')
|
||||||
if [ -n "$git_branch" ]; then
|
if [ -n "$git_branch" ]; then
|
||||||
PS1+="${c_branch}@${git_branch}"
|
PS1+="\[${c_branch}\]@${git_branch}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# hg branch if exist
|
||||||
|
#
|
||||||
|
if [ -n "$prompt_check_hg" -a -z "$git_branch" ]; then
|
||||||
|
local hg_branch=$(_scm_prompt %s)
|
||||||
|
if [ -n "$hg_branch" ]; then
|
||||||
|
PS1+="\[${c_branch}\]@${hg_branch}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#
|
#
|
||||||
@@ -102,39 +118,39 @@ if [ -n "$PS1" ]; then
|
|||||||
if [ -n "$prompt_check_svn" ]; then
|
if [ -n "$prompt_check_svn" ]; then
|
||||||
local svn_rev=$(svn info . 2> /dev/null | awk -F ':' '/Revision:/ { print $2 }')
|
local svn_rev=$(svn info . 2> /dev/null | awk -F ':' '/Revision:/ { print $2 }')
|
||||||
if [ -n "$svn_rev" ]; then
|
if [ -n "$svn_rev" ]; then
|
||||||
PS1+="${c_branch}@${svn_rev}" # svn revision
|
PS1+="\[${c_branch}\]@${svn_rev}" # svn revision
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#
|
#
|
||||||
# Python venv.
|
# Python venv
|
||||||
#
|
#
|
||||||
local jobs_bg=$(jobs -r | wc -l | tr -d ' ')
|
local jobs_bg=$(jobs -r | wc -l | tr -d ' ')
|
||||||
if [ -n "$VIRTUAL_ENV" ]; then
|
if [ -n "$VIRTUAL_ENV" ]; then
|
||||||
# PS1+=",\[${c_info}\]$(realpath --relative-to=$PWD $VIRTUAL_ENV)"
|
# PS1+=",\[${c_info}\]$(realpath --relative-to=$PWD $VIRTUAL_ENV)"
|
||||||
PS1+=",${c_info}$(basename $VIRTUAL_ENV)"
|
PS1+=",\[${c_info}\]$(basename $VIRTUAL_ENV)"
|
||||||
fi
|
fi
|
||||||
#
|
#
|
||||||
# Info about jobs.
|
# Info about jobs.
|
||||||
#
|
#
|
||||||
local jobs_bg=$(jobs -r | wc -l | tr -d ' ')
|
local jobs_bg=$(jobs -r | wc -l | tr -d ' ')
|
||||||
if [ $jobs_bg -gt 0 ]; then
|
if [ $jobs_bg -gt 0 ]; then
|
||||||
PS1+=",${c_info}bg=${jobs_bg}"
|
PS1+=",\[${c_info}\]bg=${jobs_bg}"
|
||||||
fi
|
fi
|
||||||
local jobs_stopped=$(jobs -s | wc -l | tr -d ' ')
|
local jobs_stopped=$(jobs -s | wc -l | tr -d ' ')
|
||||||
if [ $jobs_stopped -gt 0 ]; then
|
if [ $jobs_stopped -gt 0 ]; then
|
||||||
PS1+=",${c_info}stp=${jobs_stopped}"
|
PS1+=",\[${c_info}\]stp=${jobs_stopped}"
|
||||||
fi
|
fi
|
||||||
#
|
#
|
||||||
# exit code if not zero
|
# exit code if not zero
|
||||||
#
|
#
|
||||||
if [ "$exit_code" -ne "0" ]; then
|
if [ "$exit_code" -ne "0" ]; then
|
||||||
PS1+=",${c_error}rc=${exit_code}"
|
PS1+=",\[${c_error}\]rc=${exit_code}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Colors should be set here and surrounded with \[\]otherwise bash fails to
|
# Colors should be set here and surrounded with \[\]otherwise bash fails to
|
||||||
# calculate prompt length. The text is set through PROMPT_COMMAND
|
# calculate prompt length. The text is set through PROMPT_COMMAND
|
||||||
PS1+="${c_reset}\$ " # reset colors and print $
|
PS1+="\[${c_reset}\]\$ " # reset colors and print $
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user