aboutsummaryrefslogtreecommitdiffstats
path: root/.zsh.after/functions.zsh
diff options
context:
space:
mode:
authorDavid Runge <david.runge@frqrec.com>2013-11-03 12:30:45 +0100
committerDavid Runge <david.runge@frqrec.com>2013-11-03 12:30:45 +0100
commit67b0ec5741d327d27afe88783d85fcf2c4c4f204 (patch)
tree4ea47807c5e775927b96eb79933c09fbfcd0468e /.zsh.after/functions.zsh
downloaddotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.gz
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.bz2
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.xz
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.zip
First commit
Diffstat (limited to '.zsh.after/functions.zsh')
-rw-r--r--.zsh.after/functions.zsh182
1 files changed, 182 insertions, 0 deletions
diff --git a/.zsh.after/functions.zsh b/.zsh.after/functions.zsh
new file mode 100644
index 0000000..1a87ab5
--- /dev/null
+++ b/.zsh.after/functions.zsh
@@ -0,0 +1,182 @@
+# < FUNCTIONS
+
+## BACKUP
+ function etcbackup() {
+ BACKUPDIR=$HOME/dropbox/backup
+ HOSTNAME=$(hostname)
+ FILE=$1
+
+ if [ -f $FILE ]
+ then
+ FILENAME=$(echo $FILE | sed 's/\///' | sed 's/\//_/g')
+ cp -v $FILE $BACKUPDIR/$HOSTNAME/$FILENAME
+ else
+ echo $FILE does not exist
+ fi
+ }
+
+## COMPRESSION
+ function tar_tgz {
+ tar cvfz $1.tgz $1
+ }
+ function tar_tbz {
+ tar cvfj $1.tbz $1
+ }
+ function tar_tlz {
+ tar --lzma -cvf $1.tlz $1
+ }
+
+## DOTFILES
+ function update_dot() {
+ for i in $HOME/dropbox/dot/[a-zA-Z]*;
+ do
+ if [ -f $i ];
+ then
+ echo file $i
+ base=`basename $i`
+ dst=$HOME/.$base
+ bak=$HOME/.${base}_bak
+
+ case $base in
+ vimrc|zshrc|*tgz)
+ echo nothing $i
+ ;;
+ *)
+ if [ -L $dst ];
+ then
+ rm $dst
+ else
+ mv $dst $bak
+ fi
+ ln -s $i $dst
+ ;;
+ esac
+
+ else
+ if [ -d $i ];
+ then
+ echo dir $i
+ base=`basename $i | sed 's/_/\//'`
+ dst=$HOME/.$base
+ bak=$HOME/.${base}_bak
+
+ case $base in
+ "vim")
+ echo nothing $i
+ ;;
+ *)
+ if [ -e $dst ];
+ then
+ if [ -L $dst ];
+ then
+ rm $dst
+ else
+ mv $dst $bak
+ fi
+ fi
+ ln -s $i $dst
+ ;;
+ esac
+ else
+ echo unknown $i
+ fi
+ fi
+ done
+ }
+
+## PDF/LATEX
+ function mkpdf()
+ {
+ pdflatex -shell-escape $1
+ # latex --output-format=pdf $1
+ name=`echo $1 | sed 's/.tex//'`
+ EXT=(aux log)
+ for i in $EXT;
+ do
+ rm -v $name.$i
+ done
+ }
+
+ function gsmerge()
+ {
+ target=$1
+ echo "target: $target"
+ sleep 1
+ shift
+
+ /usr/bin/gs \
+ -sDEVICE=pdfwrite \
+ -dCompatibilityLevel=1.4 \
+ -dNOPAUSE \
+ -dBATCH \
+ -sPAPERSIZE=a4 \
+ -sOUTPUTFILE=$target $*
+ }
+
+ function gsmerge_medium()
+ {
+ target=$1
+ echo "target: $target"
+ sleep 1
+ shift
+
+ /usr/bin/gs \
+ -sDEVICE=pdfwrite \
+ -dPDFSETTINGS=/ebook \
+ -dCompatibilityLevel=1.4 \
+ -dNOPAUSE \
+ -dBATCH \
+ -sPAPERSIZE=a4 \
+ -sOutputFile=$target $*
+ }
+
+## USABILITY
+ function lvim()
+ {
+ noglob vim $(echo $1 | awk -F":" '{ print $1" +"$2 }' )
+ }
+
+ function mkcd()
+ {
+ mkdir $1
+ cd $1
+ }
+
+ function cpwd()
+ {
+ pwd >! /tmp/pwd
+ }
+
+ function ppwd()
+ {
+ cd "`cat /tmp/pwd`"
+ }
+
+ function cp2wd()
+ {
+ cp $@ "`cat /tmp/pwd`"
+ }
+
+function publish() {
+ [ -f $1 ] || return
+
+ DIR=`dirname $1`
+ FILE=`basename $1`
+ mute pushd $DIR
+ scp $FILE pool:public_html/
+ echo "http://www-pool.math.tu-berlin.de/~runge/$FILE"
+ echo "http://www-pool.math.tu-berlin.de/~runge/$FILE"|xcp
+ mute popd
+}
+
+function securium {
+ port=44350
+ chromium --proxy-server="socks://localhost:$port" &
+ exit
+}
+
+## ZSH
+ refresh() {
+ source $HOME/.zshrc
+ }
+# FUNCTIONS >