X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=rc%2Ffunctions;h=88a4ba09e4d23e3565242fb4e37532f56c406540;hb=72f3158ec449d74cdd75accb575ab9634cf6fccd;hp=fd373a2da2d5b4f21c6135b8e920ae129127d873;hpb=020a4a5ea2be725b155cae3a2cadc9aba3911b9b;p=clearscm.git diff --git a/rc/functions b/rc/functions index fd373a2..88a4ba0 100644 --- a/rc/functions +++ b/rc/functions @@ -19,6 +19,11 @@ view_name= # 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 @@ -38,6 +43,11 @@ function title_bar { current_dir="$current_dir ($(cat CVS/Root | tr -d $CR))" fi + # Add GIT info if available + if in_git_repo; then + current_dir="$current_dir [git: $(git branch | sed -n -e 's/^\* \(.*\)/\1/p')]" + fi + if [ "$TERM" = "hpterm" -o \ "$TERM" = "hp" -o \ "$TERM" = "2392A" ]; then @@ -47,8 +57,11 @@ function title_bar { "$TERM" = "vt221" ]; then 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\]" + elif [ "$TERM" = "cygwin" -o \ + "$TERM" = "vt100" -o \ + "$TERM" = "xterm" -o \ + "$TERM" = "xterm-256color" ]; then + PS1="\[\e]0;$prefix$current_dir\007\]\[$RED\]$ROOT\[$LIGHT_CYAN\]$SYSNAME:\[$WHITE\]" fi } # title_bar @@ -106,17 +119,19 @@ function set_prompt { "$TERM" = "dtterm" -o \ ! -z "$DTTERM" ]; then ROOT="${RED}Wizard$NORMAL " - elif [ "$TERM" = "vt100" -o \ - "$TERM" = "xterm" -o \ - "$TERM" = "vt220" ]; then + elif [ "$TERM" = "vt100" -o \ + "$TERM" = "xterm" -o \ + "$TERM" = "xterm-256color" -o \ + "$TERM" = "vt220" ]; then ROOT="${BOLD}${BLINK}Wizard$NORMAL " fi else ROOT="" fi - if [ "$TERM" = "vt100" -o \ - "$TERM" = "xterm" -o \ + if [ "$TERM" = "vt100" -o \ + "$TERM" = "xterm" -o \ + "$TERM" = "xterm-256color" -o \ "$TERM" = "vt220" ]; then PS1="$ROOT$BOLD$SYSNAME:$NORMAL" else @@ -183,8 +198,20 @@ 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 [ $ARCH = "FreeBSD" ]; then + if [ $ARCHITECTURE = "FreeBSD" ]; then psopts="-aux" else psopts="-ef" @@ -236,17 +263,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