Update.
authorFrancois Fleuret <francois@fleuret.org>
Fri, 27 Dec 2013 21:04:59 +0000 (22:04 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Fri, 27 Dec 2013 21:04:59 +0000 (22:04 +0100)
bashrc

diff --git a/bashrc b/bashrc
index 067fdf5..86a1f88 100644 (file)
--- a/bashrc
+++ b/bashrc
@@ -243,7 +243,6 @@ function ua () {
     while [[ "$1" ]]; do
 
         case "$1" in
-
             *.tgz|*.tar.gz|*.tbz|*.tar.bz2)
                 tar xvf "$1"
                 ;;
@@ -406,7 +405,7 @@ function netup () {
             UPPED_WIFI=1
         fi
 
-        sudo iwlist ${WIFI_INTERFACE} scan|grep ESS\|Quali\|Encry
+        sudo iwlist ${WIFI_INTERFACE} scan | \grep -E 'ESS|Quali|Encry' | sed -e 's/^[ \t]*//'
 
         if [[ ${UPPED_WIFI} ]]; then
             sudo ifconfig ${WIFI_INTERFACE} down
@@ -761,12 +760,13 @@ function git-fm () {
     echo "Visited ${NB_SUBDIR} directories."
 }
 
+# Update all the directories provided as argument in their respective
+# versionning systems (SVN and GIT for now)
+
 function vcup () {
     if [[ "$1" ]]; then
-        CURRENT=${PWD}
         while [[ "$1" ]]; do
-            cd ${CURRENT}
-            cd $1
+            pushd > /dev/null "$1"
             if [[ -d ".git" ]]; then
                 echo "${PWD} is under GIT"
                 git pull
@@ -774,8 +774,9 @@ function vcup () {
                 echo "${PWD} is under SVN"
                 svn update
             else
-                echo "No known versioning system."
+                echo "No known versioning system here."
             fi
+            popd > /dev/null 
             shift
         done
         cd ${CURRENT}
@@ -891,6 +892,26 @@ function histfile_cue () {
 
 PS1="\[${VT_YELLOW_BG}\]\${HISTORY_CUE}\[${VT_RESET}\]${PS1}"
 
+######################################################################
+
+# parse_git_branch () {
+  # git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
+# }
+
+# parse_git_tag () {
+  # git describe --tags 2> /dev/null
+# }
+
+# parse_git_branch_or_tag() {
+  # local OUT="$(parse_git_branch)"
+  # if [ "$OUT" == " ((no branch))" ]; then
+    # OUT="($(parse_git_tag))";
+  # fi
+  # echo $OUT
+# }
+
+# PS1="${PS1}\$(parse_git_branch_or_tag)"
+
 ######################################################################
 # The dus command is available on my web site
 #
@@ -935,22 +956,46 @@ function selector-printer () {
 
 function lsn () {
     LSN_MEMORY=".lsn-state"
+
     if  [[ $1 == "--mem" ]] || [[ "$1" == "-m" ]]; then
+
         \ls -pa | sort > ${LSN_MEMORY}
         echo "State updated." >&2
+
+    elif [[ $1 == "+" ]]; then
+
+        shift
+
+        TMP=$(mktemp /tmp/lsn.XXXXXX)
+        \ls -d $* > ${TMP}
+        cat ${LSN_MEMORY} >> ${TMP}
+        sort -u ${TMP} > ${LSN_MEMORY}
+        \rm ${TMP}
+
     elif [[ -n "$1" ]]; then
-        echo "lsn [--mem|-m]" >&2
+
+        echo "lsn [--mem|-m] [+ <file> ...]" >&2
         return 1
+
     else
+
         if [[ -f ${LSN_MEMORY} ]]; then
-            comm -1 -3 ${LSN_MEMORY} <(\ls -pa | sort)
-            comm -2 -3 ${LSN_MEMORY} <(\ls -pa | sort) | while read line; do
-                echo "${VT_RED_FG}${VT_BOLD}${line}${VT_RESET} (missing)"
-            done
+            TMP=$(mktemp /tmp/lsn.XXXXXX)
+            \ls -pa | sort > ${TMP}
+            if diff > /dev/null ${TMP} ${LSN_MEMORY}; then
+                echo "${VT_GREEN_FG}${VT_BOLD}No change${VT_RESET}"
+            else
+                \comm -1 -3 ${LSN_MEMORY} ${TMP}
+                \comm -2 -3 ${LSN_MEMORY} ${TMP} | while read line; do
+                    echo "${VT_RED_FG}${VT_BOLD}${line}${VT_RESET} (missing)"
+                done
+            fi
+            \rm ${TMP}
         else
             echo "No lsn state here." >&2
             return 1
         fi
+
     fi
 }