merge shell grab and mac shell

This commit is contained in:
nojhan 2012-08-13 22:37:27 +02:00
commit b882e1550e

View File

@ -37,11 +37,11 @@
# See the README.md file for a summary of features. # See the README.md file for a summary of features.
WORKING_SHELL=$(ps -p $$ | awk '{n=$NF}END{print n}') WORKING_SHELL=${SHELL##*/}
# A login shell starts with a "-" # A login shell starts with a "-"
if [[ "$WORKING_SHELL" == "-bash" ]]; then if [[ "$WORKING_SHELL" == "-bash" ]]; then
WORKING_SHELL="bash" WORKING_SHELL="bash"
fi fi
if [[ "$WORKING_SHELL" == "bash" ]]; then if [[ "$WORKING_SHELL" == "bash" ]]; then
@ -212,7 +212,7 @@ __cpunum_Darwin()
__cpunum_SunOS() __cpunum_SunOS()
{ {
kstat -m cpu_info | grep "module: cpu_info" | wc -l kstat -m cpu_info | grep -c "module: cpu_info"
} }
__CPUNUM=$(__cpunum_$OS) __CPUNUM=$(__cpunum_$OS)
@ -273,8 +273,8 @@ __user()
__connection() __connection()
{ {
THIS_TTY=tty$(ps aux | grep $$ | grep bash | awk '{ print $7 }') THIS_TTY=tty$(ps aux | awk -v pid=$$ '$0 ~ pid && /bash/{ print $7 }')
SESS_SRC=$(who | grep $THIS_TTY | awk '{ print $6 }') SESS_SRC=$(who | awk -v thistty="$THIS_TTY" '$0 ~ thistty { print $6 }')
# Are we in an SSH connexion? # Are we in an SSH connexion?
SSH_FLAG=0 SSH_FLAG=0
@ -455,8 +455,8 @@ __permissions_color()
# or detached screens sessions running on the host # or detached screens sessions running on the host
__jobcount_color() __jobcount_color()
{ {
local running=$(jobs -r | wc -l | tr -d " ") local running=$(( $(jobs -r | wc -l) ))
local stopped=$(jobs -s | wc -l | tr -d " ") local stopped=$(( $(jobs -s | wc -l) ))
local screens=$(screen -ls 2> /dev/null | grep -c Detach ) local screens=$(screen -ls 2> /dev/null | grep -c Detach )
local m_detached="d" local m_detached="d"
local m_stop="z" local m_stop="z"
@ -579,7 +579,7 @@ __hg_branch_color()
command -v hg >/dev/null 2>&1 || return 1; command -v hg >/dev/null 2>&1 || return 1;
branch=$(__hg_branch) branch=$(__hg_branch)
if [[ ! -z "$branch" ]] ; then if [[ ! -z "$branch" ]] ; then
if [[ $(hg status --quiet -n | wc -l | sed -e "s/ //g") = 0 ]] ; then if [[ $(( $(hg status --quiet -n | wc -l) )) = 0 ]] ; then
ret="${GREEN}${branch}${NO_COL}" ret="${GREEN}${branch}${NO_COL}"
else else
ret="${RED}${branch}${NO_COL}" # changes to commit ret="${RED}${branch}${NO_COL}" # changes to commit
@ -597,8 +597,8 @@ __svn_branch()
infos=$(svn info --xml 2>/dev/null) infos=$(svn info --xml 2>/dev/null)
ret=$? ret=$?
if [[ $ret -eq 0 ]] ; then if [[ $ret -eq 0 ]] ; then
root=$(echo "$infos" | grep "^<root>" | sed "s/^<root>.*\/\([^\/]*\)<\/root>$/\1/") root=$(echo "$infos" | awk -v FS=">|</" '/^<root>/ { print $2 }')
subrep=$(echo "$infos" | grep "^<url>" | sed "s/^<url>.*\/$root\/\(.*\)<\/url>$/\1/") subrep=$(echo "$infos" | awk -v FS=">|</" '/^<url>/ { print $2 }')
if [[ "$subrep" == *"url>"* ]] ; then if [[ "$subrep" == *"url>"* ]] ; then
echo -n $root echo -n $root
else else
@ -618,8 +618,7 @@ __svn_branch_color()
command -v svn >/dev/null 2>&1 || return 1; command -v svn >/dev/null 2>&1 || return 1;
branch=$(__svn_branch) branch=$(__svn_branch)
if [[ ! -z "$branch" ]] ; then if [[ ! -z "$branch" ]] ; then
commits=$(svn status | grep -v "?" | wc -l) commits=$(( $(svn status | grep -v "?" -c) ))
commits=$((commits))
if [[ $commits = 0 ]] ; then if [[ $commits = 0 ]] ; then
ret="${GREEN}${branch}${NO_COL}" ret="${GREEN}${branch}${NO_COL}"
else else