X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=rc%2Ffunctions;h=6b42f0944894ce8048d9b250676ad28698ca9bfd;hb=28aaed87a992d0b6086bb355ad2c3f20eabd157e;hp=c27274bfca82f05808d094b91ced22095fea0175;hpb=1d922ee420e3465e6a129aafb19ae20f2609dcde;p=clearscm.git diff --git a/rc/functions b/rc/functions index c27274b..6b42f09 100644 --- a/rc/functions +++ b/rc/functions @@ -17,24 +17,15 @@ CR=$(echo "\015") view_name= -function in_git_repo { - pwd=$PWD - - while [ "$pwd" != "/" ]; do - if [ -d "$pwd/.git" ]; then - true; - return; - fi - - pwd=$(dirname $pwd) - done - - false -} # in_git_repo - # Function to set the title bar. Works on the terminal emulators listed. function title_bar { + if [ $# -gt 1 ]; then + ROOT=shift + ROOT="${NORMAL}\($ROOT\)" + fi + prefix="$@" + # Change $HOME -> ~ if [ "${PWD#$HOME*}" != "$PWD" ]; then current_dir="~${PWD#$HOME*}" @@ -55,7 +46,7 @@ function title_bar { # Add GIT info if available if in_git_repo; then - current_dir="git: $(git branch | sed -n -e 's/^\* \(.*\)/\1/p') $current_dir" + current_dir="$current_dir [git: $(git branch | sed -n -e 's/^\* \(.*\)/\1/p')]" fi if [ "$TERM" = "hpterm" -o \ @@ -68,7 +59,8 @@ function title_bar { string=$(echo "${SYSNAME##*:}:$@") echo -n "${ESC}]2;$string\007" elif [ "$TERM" = "cygwin" -o "$TERM" = "vt100" -o "$TERM" = "xterm" ]; then - PS1="\[\e]0;$prefix$current_dir\a\e[01;33m\]$SYSNAME:\[\e[0m\]" + # Here's where we set the prompt with root + PS1="\[\e]0;$prefix$current_dir\a$AQUA\]$ROOT\[$YELLOW\]$SYSNAME:\[$NORMAL\]" fi } # title_bar @@ -111,7 +103,7 @@ function set_title { view_name="" title_bar "$ROOT" else - title_bar "${ROOT}View: $view_name: " + title_bar "$ROOT" "View: $view_name: " fi icon_name "${SYSNAME##*:}" @@ -203,6 +195,18 @@ function ssh { set_prompt } # ssh +function processRunning { + if [ $ARCHITECTURE = "FreeBSD" ]; then + psopts="-aux" + else + psopts="-ef" + fi + + if [ $1 != '' ]; then + return $(ps $psopts | grep "$1" | grep -v "grep $1" | grep -v "grep -d skip" | wc -l) + fi +} # processRunning + function sj { if [ $ARCHITECTURE = "FreeBSD" ]; then psopts="-aux" @@ -256,17 +260,47 @@ function cmdline { } # cmdline function user { + processRunning ypbind; ypbind=$? + processRunning winbind; winbind=$? + if [ $# -gt 0 ]; then - ypcat passwd | grep -i $@ + if [ $ypbind -gt 0 ]; then + ypcat passwd | grep -i $@ + elif [ $winbind -gt 0 ]; then + for user in $(wbinfo -u | grep -i $@); do + wbinfo --user-info $user + done + fi else - ypcat passwd | $PAGER + if [ $ypbind -gt 0 ]; then + ypcat passwd | $PAGER + elif [ $wbind -gt 0 ]; then + for user in $(wbinfo -u); do + wbinfo --user-info $user + done | $PAGER + fi fi } # user function group { + processRunning ypbind; ypbind=$? + processRunning winbind; winbind=$? + if [ $# -gt 0 ]; then - ypcat group | grep -i $@ + if [ $ypbind -gt 0 ]; then + ypcat group | grep -i $@ + elif [ $winbind -gt 0 ]; then + for group in $(wbinfo -g | grep -i $@); do + wbinfo --group-info $group + done + fi else - ypcat group | $PAGER + if [ $ypbind -gt 0 ]; then + ypcat group | $PAGER + elif [ $winbind -gt 0 ]; then + for group in $(wbinfo -g); do + wbinfo --group-info $group + done | $PAGER + fi fi } # group