alias chmod='chmod -c'
alias cp='cp -i -v'
alias rd=rmdir
-alias md='mkdir -v'
+alias md='mkdir -pv'
alias ps='ps uxaf'
alias df='df -hT --sync'
alias grep='grep -i -E --color=auto'
if [ -e "${HOME}/.dircolors" ]; then
eval $(dircolors "${HOME}/.dircolors")
- alias ls='ls --group-directories-first --color'
- 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 ls='ls -p --group-directories-first --color'
+ alias lt='ls -p --color -gohtr --time-style="+%Y %b %d %H:%M"'
+ alias ll='ls -p --color -goh --time-style="+%Y %b %d %H:%M"'
+ alias lll='ls -p --color -lth'
+ alias l='ls -p --color -I "*~" -I "*.o"'
alias less='less -R'
else
- alias ls='ls --group-directories-first'
- 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"'
+ alias ls='ls -p --group-directories-first'
+ alias lt='ls -p -gohtr --time-style="+%Y %b %d %H:%M"'
+ alias ll='ls -p -goh --time-style="+%Y %b %d %H:%M"'
+ alias lll='ls -p -lth'
+ alias l='ls -p -I "*~" -I "*.o"'
fi
export EDITOR=emacsclient
if [[ ${RECENT_LOG} ]]; then
FILEBASE="${RECENT_LOG/.log/}"
- pdflatex "${FILEBASE}"
- bibtex "${FILEBASE}"
- pdflatex "${FILEBASE}"
- pdflatex "${FILEBASE}"
+ if [[ -f "${FILEBASE}.tex" ]]; then
+
+ pdflatex "${FILEBASE}"
+ bibtex "${FILEBASE}"
+ pdflatex "${FILEBASE}"
+ pdflatex "${FILEBASE}"
+
+ if [[ "$1" ]]; then
+ if [[ "$1" == "-v" ]] || [[ "$1" == "--view" ]]; then
+ xpdf "${FILEBASE}.pdf"
+ elif [[ "$1" == "-p" ]] || [[ "$1" == "--print" ]]; then
+ lpr "${FILEBASE}.pdf"
+ else
+ echo "Usage: rl [-v|--view] [-p|--print]" >&2
+ echo "Unknown option $1" >&2
+ return 1
+ fi
+ fi
+
+ else
+
+ echo "Can not find a tex file corresponding to the most recent log (${RECENT_LOG/.log/})." >&2
+ return 1
- if [[ "$1" == "--view" ]]; then
- xpdf "${FILEBASE}.pdf"
- elif [[ "$1" == "--print" ]]; then
- lpr "${FILEBASE}.pdf"
fi
else
return 1
fi
else
- cd $(mktemp -d /tmp/tmp.XXXXXX)
+ dir=$(mktemp -d /tmp/tmp.XXXXXX)
+ link=/tmp/tmp
+ if [[ -h ${link} ]]; then
+ \rm ${link}
+ fi
+ if [[ ! -a ${link} ]]; then
+ ln -s ${dir} ${link}
+ fi
+ cd ${dir}
fi
}
function trash () {
TRASH=$(date +/tmp/trash-%Y-%b-%d-%Hh)
+ LINK=/tmp/trash
- if [[ -d ${TRASH} ]]; then
- echo "Re-use ${TRASH}"
- else
- mkdir ${TRASH}
- echo "Created ${TRASH}"
- fi
+ mkdir -p ${TRASH}
+
+ [[ -h ${LINK} ]] && \rm ${LINK}
+ [[ ! -f ${LINK} ]] && ln -s ${TRASH} ${LINK}
mv "$@" ${TRASH}
echo "Trashed $@"
}
-# alias trash=trash.sh
-
function mmsget () {
mplayer "$1" -dumpstream -dumpfile $(basename "$1")
}
-function quicktex () {
- if [[ $1 ]]; then
- MAIN=$1
- else
- MAIN=$(\ls -t *.tex | head -1 | sed -r -e 's/\.tex//')
- fi
- pdflatex ${MAIN}
- bibtex ${MAIN}
- pdflatex ${MAIN}
- pdflatex ${MAIN}
- xpdf ${MAIN}.pdf
-}
-
######################################################################
# http://www.reddit.com/r/linux/comments/akt3j/a_functional_programming_style_map_function_for/
\rm ${TEMP}
}
-# function rotjpeg () {
-# if [ "$1" == "90" ] || [ "$1" == "180" ] || [ "$1" == "270" ]; then
-# TEMP=$(mktemp /tmp/rotjpeg.XXXXXX)
-# echo jpegtran -rotate "$1" -copy all $2 > ${TEMP}
-# echo cp $2 ${2/jpg/}original.jpg
-# echo cp ${TEMP} $2
-# rm ${TEMP}
-# else
-# echo "Can not rotate with an angle of "$1" degrees."
-# fi
-# }
-
######################################################################
## A version of date that shows the time at home if TZ is set
[[ ${NETUP_HISTORY} ]] || NETUP_HISTORY="${HOME}/.netup_history"
function netup () {
+ WIFI_INTERFACE=wlan0
+
+ if [[ $1 == "--scan" ]]; then
+ if [[ ! $(\ifconfig -s | grep ${WIFI_INTERFACE}) ]]; then
+ sudo ifconfig ${WIFI_INTERFACE} up
+ UPPED_WIFI=1
+ fi
+
+ sudo iwlist ${WIFI_INTERFACE} scan|grep ESS\|Quali\|Encry
+
+ if [[ ${UPPED_WIFI} ]]; then
+ sudo ifconfig ${WIFI_INTERFACE} down
+ fi
+
+ return 0
+ fi
+
if [[ $(\ifconfig -s | grep -v ^"(Iface|lo) ") ]]; then
echo "There is already interface(s) up." >&2
return 1
# cd and ls into a directory
# [from http://www.oreillynet.com/onlamp/blog/2007/01/whats_in_your_bash_history.html]
-# function c () { cd "$@" && lr; }
+function c () { cd "$@" && lr; }
######################################################################
# You can change the xterm background color on the fly!
# the current directory
function lsn () {
- LSN_MEMORY=".lsn-mem"
- if [[ $1 == "--mem" ]]; then
- \ls > ${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)
- comm -2 -3 ${LSN_MEMORY} <(\ls) | 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
}