From 1bc27724484b8ac9a9ff6ec70cf50574171c2860 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Mon, 2 May 2016 21:29:19 +0200 Subject: [PATCH] Minor improvements concerning prompt & darcs detection. --- TODO.md | 2 ++ files/bashrc.d/70-util-darcs.sh | 2 ++ files/bashrc.d/90-prompt.sh | 30 +++++++++++++++++------------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/TODO.md b/TODO.md index 1e467b1..3e696eb 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,5 @@ * Add 'safety' aliases for rm -i, mv -i, etc. * Fill local.yml for direct role application +* Install fasd (zz, etc. autocompletion aliases) + diff --git a/files/bashrc.d/70-util-darcs.sh b/files/bashrc.d/70-util-darcs.sh index 260f4ee..ec2c2a4 100644 --- a/files/bashrc.d/70-util-darcs.sh +++ b/files/bashrc.d/70-util-darcs.sh @@ -1,4 +1,6 @@ # Help darcs on network mounts +if hash darcs >/dev/null 2>&1 ; then export DARCS_SLOPPY_LOCKS=1 +fi diff --git a/files/bashrc.d/90-prompt.sh b/files/bashrc.d/90-prompt.sh index 46f5dae..36bbd64 100644 --- a/files/bashrc.d/90-prompt.sh +++ b/files/bashrc.d/90-prompt.sh @@ -22,19 +22,21 @@ ps1_vcs_branch() { local vcs_root_url="" local vcs_branch_url="" - if hash git && git rev-parse > /dev/null 2>&1; then - vcs="git" - vcs_branch=$(git branch |sed -n "s/\* \(.*\)/\1/p") - elif hash hg && hg -q status > /dev/null 2>&1; then - vcs="hg" - vcs_branch=$(hg branch) - elif hash svn && svn info > /dev/null 2>&1; then - vcs="svn" - vcs_root_path=$(LANG=C LC_ALL=C svn info |sed -n "s/^Working Copy Root Path: //p") - vcs_root_url=$(cd "$vcs_root" ; LANG=C LC_ALL=C svn info |sed -n "s/^Repository Root: //p") - vcs_branch_url=$(cd "$vcs_root" ; LANG=C LC_ALL=C svn info |sed -n "s/^URL: //p") - vcs_branch=$(echo "$vcs_branch_url" |sed "s#^$vcs_root_url/##") - fi + { + if hash git && git rev-parse; then + vcs='git' + vcs_branch=$(git branch |sed -n "s/\* \(.*\)/\1/p") + elif hash hg && hg -q status; then + vcs='hg' + vcs_branch=$(hg branch) + elif hash svn && svn info; then + vcs='svn' + vcs_root_path=$(LANG=C LC_ALL=C svn info |sed -n 's/^Working Copy Root Path: //p') + vcs_root_url=$(cd "$vcs_root" ; LANG=C LC_ALL=C svn info |sed -n 's/^Repository Root: //p') + vcs_branch_url=$(cd "$vcs_root" ; LANG=C LC_ALL=C svn info |sed -n 's/^URL: //p') + vcs_branch=$(echo "$vcs_branch_url" |sed "s#^$vcs_root_url/##") + fi + } >/dev/null 2>&1 if [ -z "$vcs" ]; then echo "" @@ -45,6 +47,7 @@ ps1_vcs_branch() { #export PS1=" \t [#\#]\n[\u@\h \w]\\$ " #PS1='\[\033[1;32m\][\t|\d]\[\033[1;33m\][\u@\h] \[\033[0;36m\]\w\$\[\033[0m\]\n ' + PS1="$ps1_context ." PS1=$PS1": \[\e[1;33m\]\w\[\e[0m\] :" PS1=$PS1"\`ps1_show ': \[\e[1;34m\]%s\[\e[0m\] :' ps1_vcs_branch\`" # vcs branch @@ -54,3 +57,4 @@ PS1=$PS1": \[\e[0;31m\]\u@\h " #username PS1=$PS1"("`uname -m`")\[\e[0m\] :" # architecture PS1=$PS1":.\n\$ " export PS1 +