while [[ "$1" ]]; do
case "$1" in
-
*.tgz|*.tar.gz|*.tbz|*.tar.bz2)
tar xvf "$1"
;;
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
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
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}
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
#
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
}