Update lsn.
authorFrancois Fleuret <francois@fleuret.org>
Wed, 28 Aug 2013 07:22:04 +0000 (09:22 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Wed, 28 Aug 2013 07:22:04 +0000 (09:22 +0200)
bashrc

diff --git a/bashrc b/bashrc
index ad11407..1a947db 100644 (file)
--- a/bashrc
+++ b/bashrc
@@ -938,17 +938,22 @@ function selector-printer () {
 # the current directory
 
 function lsn () {
-    LSN_MEMORY=".lsn-mem"
-    if  [[ $1 == "--mem" ]]; then
-        \ls -p > ${LSN_MEMORY}
+    LSN_MEMORY=".lsn-state"
+    if  [[ $1 == "--mem" ]] || [[ "$1" == "-m" ]]; then
+        \ls -pa | sort > ${LSN_MEMORY}
+        echo "State updated." >&2
+    elif [[ -n "$1" ]]; then
+        echo "lsn [--mem|-m]" >&2
+        return 1
     else
         if [[ -f ${LSN_MEMORY} ]]; then
-            comm -1 -3 ${LSN_MEMORY} <(\ls -p)
-            comm -2 -3 ${LSN_MEMORY} <(\ls -p) | while read line; do
+            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
         else
-            echo "No lsn memory here." >&2
+            echo "No lsn state here." >&2
+            return 1
         fi
     fi
 }