# 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
}