# exit 0
# fi
-export ARCHIVED_PICS="$*"
+export ARCHIVED_PICS="$@"
set -e
# alias ll='ls --color -lth'
alias lt='ls --color -gohtr --time-style="+%Y %b %d %H:%M"'
alias ll='ls --color -goh --time-style="+%Y %b %d %H:%M"'
+ alias lll='ls --color -lth'
alias l='ls --color -I "*~" -I "*.o"'
alias less='less -R'
else
# alias ll='ls -lth'
alias lt='ls -gohtr --time-style="+%Y %b %d %H:%M"'
alias ll='ls -goh --time-style="+%Y %b %d %H:%M"'
+ alias lll='ls -lth'
alias l='ls -I "*~" -I "*.o"'
fi
function fn () {
name=$1
shift
- find $* -name "*${name}*";
+ find "$@" -name "*${name}*";
}
# Create a dir and cd there
# Capture the screen in a dated png
function cap () {
- name="capture-$(date +%s).png"
+ if [[ $2 ]]; then
+ name=$2
+ else
+ name="capture-$(date +%s).png"
+ fi
+ echo "Waiting $1 s and saving to ${name}."
[[ $1 ]] && sleep $1
+ echo "Please click on the window to capture."
xwd | convert - ${name}
\ls -l ${name}
}
function pho () {
PHO_BIN=/usr/bin/pho
TEMP=$(mktemp /tmp/pho.XXXXXXX)
- ${PHO_BIN} $* | tee ${TEMP}
+ ${PHO_BIN} "$@" | tee ${TEMP}
PHO_NOTE_1=$(grep ^"Note 1: " ${TEMP} | sed -e "s/^[^:]*: //")
PHO_NOTE_2=$(grep ^"Note 2: " ${TEMP} | sed -e "s/^[^:]*: //")
PHO_NOTE_3=$(grep ^"Note 3: " ${TEMP} | sed -e "s/^[^:]*: //")
echo "${VT_BOLD}${VT_GREEN_FG}This is the bash function ifup from .bashrc${VT_RESET}"
if [[ "$1" == "-s" ]]; then
chosen_ifup=$(mktemp /tmp/chosen_ifup.XXXXXX)
- selector -o ${chosen_ifup} <(cat ${IFUPRC} | sort | uniq)
+ selector -i -d -o ${chosen_ifup} ${IFUPRC}
ARGS=$(cat ${chosen_ifup})
rm -f ${chosen_ifup}
echo ${ARGS} >> ${IFUPRC}
function lr () {
HEIGHT=$(stty size | awk '{print $1}')
WIDTH=$(stty size | awk '{print $2}')
- \ls -goth --time-style="+%Y %b %d %H:%M" $* | head -$((HEIGHT-2)) | cut -b1-${WIDTH}
- # \ls -lth $* | head -$((HEIGHT-2)) | cut -b1-${WIDTH}
+ \ls -goth --time-style="+%Y %b %d %H:%M" "$@" | \
+ head -$((HEIGHT-2)) | \
+ cut -b1-${WIDTH}
}
######################################################################
-e "s/Quality=\([0-9]*\).*$/QUALITY,\1/" \
-e "s/Encryption key:/ENCRYPTION,/" | \
awk 'BEGIN { FS="," }
- {
- if($1 == "ESSID") { essid=$2 }
+ {
+ if($1 == "ESSID") { essid=$2 }
else if($1 == "AP") { ap=$2 }
else if($1 == "QUALITY") { quality=$2; }
else if($1 == "ENCRYPTION") {
exit 1
fi
+trap cleanup-before-quit EXIT
+
stty_state=$(stty -g)
trap sigint-handler SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
;;
"\ e")
- process-key "down"
- ;;
+ process-key "down"
+ ;;
"\10")
- process-key "up"
- ;;
+ process-key "up"
+ ;;
"\e") #$'\033'")
- current_keymap=escape
- ;;
+ current_keymap=escape
+ ;;
*)
- ;;
- esac
- ;;
+ ;;
+ esac
+ ;;
- escape) ##################################################
- case ${CHAR} in
- "$'\033'")
+ escape) ##################################################
+ case ${CHAR} in
+ "$'\033'")
process-key "esc-esc"
;;
- "[")
+ "[")
current_keymap=cursor
;;
- *)
+ *)
current_keymap=default
;;
- esac
- ;;
+ esac
+ ;;
- cursor) ##################################################
+ cursor) ##################################################
- current_keymap=default
+ current_keymap=default
- case ${CHAR} in
- A)
+ case ${CHAR} in
+ A)
process-key "up"
;;
- B)
+ B)
process-key "down"
;;
- *)
- ;;
- esac
- ;;
-
*)
- echo "Unknown keymap. This is an internal and weird bug."
- cont=0
- ;;
- esac
+ ;;
+ esac
+ ;;
- done
+ *)
+ echo "Unknown keymap. This is an internal and weird bug."
+ cont=0
+ ;;
+ esac
- cleanup-before-quit
+done
set -e
echo "(From html)"
+echo
elinks -no-numbering -no-references -dump -dump-width 80 -dump-charset utf-8 | \
sed -e "s/\[IMG\]//g" -e "s/^[ \t]*$//" -e "s/^ //" | \
awk '/^$/{ if (! blank++) print; next } { blank=0; print }'
- # | \
- # sed -e "s/^ *//"
+
opts=""
printing_cmd="lpr"
-for arg in $*; do
+function cleanup-before-exit () {
+ rm ${tmp}
+}
+
+trap cleanup-before-exit EXIT
+
+for arg in "$@"; do
if [ "${arg}" == "-h" ] || [ "${arg}" == "--help" ]; then
echo "Contact <francois.fleuret@epfl.ch>"
echo "Version \$Id: print.sh,v 1.19 2006-11-10 15:53:23 fleuret Exp $"
- \rm ${tmp}
exit 0
elif [[ ${arg} == "-"* ]]; then
# else, it is a filename to print
- if [ -e ${arg} ]; then
+ if [ -e "${arg}" ]; then
- TYPE=$(file -L ${arg})
+ TYPE=$(file -L "${arg}")
noprint=""
case $TYPE in
*"image data"*)
- convert ${arg} ps:${tmp}
+ convert "${arg}" ps:${tmp}
;;
*"TeX DVI"*)
- dvips -o ${tmp} ${arg}
+ dvips -o ${tmp} "${arg}"
;;
*"FIG image"*)
- fig2dev -L ps ${arg} > ${tmp}
+ fig2dev -L ps "${arg}" > ${tmp}
;;
*"PostScript"*)
- cp ${arg} ${tmp}
+ cp "${arg}" ${tmp}
;;
*"PDF"*)
- pdf2ps ${arg} ${tmp}
+ pdf2ps "${arg}" ${tmp}
;;
*" text"*)
- # a2ps -B -R --columns=1 -f 8 -o ${tmp} ${arg}
- a2ps --media=A4 --user-option=lp -o ${tmp} ${arg}
+ # a2ps -B -R --columns=1 -f 8 -o ${tmp} "${arg}"
+ # if isutf8 -q ${tmp}; then
+ # echo "Can not print uf8 text."
+ # exit 1
+ # else
+ a2ps --media=A4 --user-option=lp -o ${tmp} "${arg}"
+ # fi
;;
*"gzip compressed"*)
echo "Unzipping "
- zcat ${arg} > ${tmp}
+ zcat "${arg}" > ${tmp}
noprint=1
$0 ${opts} ${tmp}
;;
;;
*)
echo "Unknown option $f"
- \rm ${tmp}
exit 1;;
esac
done
done
-\rm ${tmp}
-
if [[ ${show_queue} ]]; then
lpq
fi
echo "Created ${TRASH}:"
fi
-mv $* ${TRASH}
-
-# ls -ad ${TRASH}/*
+mv "$@" ${TRASH}
# If no argument is given, we pick the most recent file
-if [[ ! $1 ]]; then
+if [[ ! "$1" ]]; then
file=$(\ls -tQ | head -1 | sed -e s/\"//g)
echo "Most recent is ${file}"
- $0 ${file}
+ $0 "${file}"
exit 0
fi
# If there were arguments, we loop through them
-echo "Viewing $*"
+echo "Viewing $@"
-while [[ $1 ]]; do
+while [[ "$1" ]]; do
- file=$1
+ file="$1"
# file=$(\ls -tQd $1 | head -1 | sed -e s/\"//g)
- # if [[ ! -a ${file} ]]; then
+ # if [[ ! -a "${file}" ]]; then
# echo "Can not find file $1"
# exit 1
# fi
*"FIG image text"*)
echo "${file}"
temp=$(mktemp /tmp/view.XXXXXX)
- fig2dev -L pdf ${file} ${temp}
+ fig2dev -L pdf "${file}" ${temp}
# xpdf -g 800x600+8+8 ${temp}
getgeometry
xpdf -g ${GEOMETRY} ${temp}
*"image"*)
echo "${file}"
- # feh -g 800x600 ${file}
+ # feh -g 800x600 "${file}"
getgeometry
- feh -g ${GEOMETRY} ${file}
+ feh -g ${GEOMETRY} "${file}"
;;
*"TeX DVI"*)
echo "${file}"
- xdvi ${file}
+ xdvi "${file}"
;;
# *"FIG image"*)
# echo "${file}"
- # xfig ${file}
+ # xfig "${file}"
# ;;
*"PostScript"*)
echo "${file}"
- gv ${file}
+ gv "${file}"
;;
*"PDF"*)
echo "${file}"
- # xpdf -g 800x600+8+8 ${file}
+ # xpdf -g 800x600+8+8 "${file}"
getgeometry
- xpdf -g ${GEOMETRY} ${file}
+ xpdf -g ${GEOMETRY} "${file}"
;;
*"WAVE audio"*)
echo "${file}"
- esdplay ${file}
+ esdplay "${file}"
;;
*"MP3"*|*"MPEG"*|*"movie"*|*"video"*|*"AVI"*|*"Microsoft ASF"*)
- mplayer -quiet ${file}
+ mplayer -quiet "${file}"
;;
*" text"*)
HEIGHT=$(stty size | awk '{print $1}')
- if [[ $(wc -l ${file} | cut -f 1 -d' ') -gt $((HEIGHT-2)) ]]; then
- less ${file}
+ if [[ $(wc -l "${file}" | cut -f 1 -d' ') -gt $((HEIGHT-2)) ]]; then
+ less "${file}"
else
- cat ${file}
+ cat "${file}"
fi
;;
*"tar archive"*)
- tar ztf ${file}
+ tar ztf "${file}"
;;
*"Microsoft Word Document"*)
- antiword ${file} | less
+ antiword "${file}" | less
;;
*"directory"*)
- echo "${file}:"; ls -lt ${file}
+ echo ""${file}":"; ls -lt "${file}"
;;
*"gzip compressed"*)
temp=$(mktemp /tmp/view.XXXXXX)
echo "Decompressing to ${temp}"
- zcat ${file} > ${temp}
+ zcat "${file}" > ${temp}
$0 ${temp}
echo "Removing ${temp}"
rm ${temp}