From 8cee2197d73332d51a82b5f1a67aae185964688d Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 12 Jul 2009 16:08:22 +0200 Subject: move all zshrc stuff into .zshrc and use folding nothing else changed --- .zsh/rc/30functions | 209 ---------------------------------------------------- 1 file changed, 209 deletions(-) delete mode 100644 .zsh/rc/30functions (limited to '.zsh/rc/30functions') diff --git a/.zsh/rc/30functions b/.zsh/rc/30functions deleted file mode 100644 index 4345412..0000000 --- a/.zsh/rc/30functions +++ /dev/null @@ -1,209 +0,0 @@ -#-------------------- -# Functions -#-------------------- - -# always /etc/rc.d/blub is a bit too much work ;) -rc() { - sudo /etc/rc.d/$1 $2 -} - -# usefull if you have more machines and want to easily update the config here -update_zshrc() { - old_pwd="$PWD" - builtin cd "$HOME/.zsh" - wget http://flo.server-speed.net/stuff/dotfiles/zshrc -O $HOME/.zshrc - wget http://flo.server-speed.net/stuff/dotfiles/zsh/filelist -O /tmp/zsh_filelist - wget -B "http://flo.server-speed.net/stuff/dotfiles/zsh/" -i /tmp/zsh_filelist -x --cut-dirs=3 -nH - rm /tmp/zsh_fileslist - rm **/index.html - builtin cd "$old_pwd" - exec zsh -} - -# add current time to a file -mbk() { - mv -b "${1}" "$(echo $1 | sed "s/\./_`date +%Y-%m-%d_%T`./")" -} - -# easily make backups -bk() { - cp -b "${1}" "$(echo $1 | sed "s/\./_`date +%Y-%m-%d_%T`./")" -} - -# chpwd () => a function which is executed whenever the directory is changed -chpwd() { - ls -} - -# idea by Gigamo http://bbs.archlinux.org/viewtopic.php?pid=478094#p478094 -ls () { - /bin/ls -rhbtF --color=auto $@ && - echo "${PURPLE}Files: ${BLUE}$(/bin/ls -l $@ | grep -v "^[l|d|total]" | wc -l) ${GREEN}--- ${PURPLE}Directories: ${BLUE}$(/bin/ls -l $@ | grep "^d" | wc -l)${NC}" -} - -password() { - if [ -z "$1" ]; then - count=8 - else - count="$1" - fi - < /dev/urandom tr -dc A-Za-z0-9_ | head -c$count -} - -# jump between directories -# Copyright 2005 Nikolai Weibull -# notice: option AUTO_PUSHD has to be set -d(){ - emulate -L zsh - autoload -U colors - local color=$fg_bold[blue] - integer i=0 - dirs -p | while read dir; do - local num="${$(printf "%-4d " $i)/ /.}" - printf " %s $color%s$reset_color\n" $num $dir - (( i++ )) - done - integer dir=-1 - read -r 'dir?Jump to directory: ' || return - (( dir == -1 )) && return - if (( dir < 0 || dir >= i )); then - echo d: no such directory stack entry: $dir - return 1 - fi - cd ~$dir -} - -# from the grml zshrc iirc -hglob() { - echo -e " - / directories - . plain files - @ symbolic links - = sockets - p named pipes (FIFOs) - * executable plain files (0100) - % device files (character or block special) - %b block special files - %c character special files - r owner-readable files (0400) - w owner-writable files (0200) - x owner-executable files (0100) - A group-readable files (0040) - I group-writable files (0020) - E group-executable files (0010) - R world-readable files (0004) - W world-writable files (0002) - X world-executable files (0001) - s setuid files (04000) - S setgid files (02000) - t files with the sticky bit (01000) - print *(m-1) # Dateien, die vor bis zu einem Tag modifiziert wurden. - print *(a1) # Dateien, auf die vor einem Tag zugegriffen wurde. - print *(@) # Nur Links - print *(Lk+50) # Dateien die ueber 50 Kilobytes grosz sind - print *(Lk-50) # Dateien die kleiner als 50 Kilobytes sind - print **/*.c # Alle *.c - Dateien unterhalb von \$PWD - print **/*.c~file.c # Alle *.c - Dateien, aber nicht 'file.c' - print (foo|bar).* # Alle Dateien mit 'foo' und / oder 'bar' am Anfang - print *~*.* # Nur Dateien ohne '.' in Namen - chmod 644 *(.^x) # make all non-executable files publically readable - print -l *(.c|.h) # Nur Dateien mit dem Suffix '.c' und / oder '.h' - print **/*(g:users:) # Alle Dateien/Verzeichnisse der Gruppe >users< - echo /proc/*/cwd(:h:t:s/self//) # Analog zu >ps ax | awk '{print $1}'<" -} - -# let vim highlight any file for us and save it as html -2html() { - vim -n -c ':syntax on' -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 > /dev/null 2> /dev/null -} - -# download any package's PKGBUILD and go into that dir -yd(){ - pbget --aur $1 - builtin cd $1 -} - -# some script to make this damn agent work easier -if [ "x$DISPLAY" != "x" ]; then - source ${HOME}/bin/gpg-agent.sh -fi - -# yeah I know you shouldn't use it... -google(){ - firefox "http://www.google.com/search?&num=100&q=$*" & - disown firefox -} - -# swaps 2 files -swap() { - if [ "$1" = "" ] || [ "$2" = "" ] || [ "$1" = "-h" ]; then - echo -e "${blue}Usage:$NC swap "; - echo -e "Swaps files"; - return 1 - fi - if [ -f $1 ] && [ -f $2 ]; then - local TMPFILE=tmp.$$ - mv "$1" $TMPFILE - mv "$2" "$1" - mv $TMPFILE "$2" - else - echo -e "${RED}Error:$NC One or more files don't exist" - return 1 - fi -} - -# get your internal and external IPs -# also found somewhere on the net -my_ip() { - MY_IP=$(/sbin/ifconfig eth0 | awk '/inet/ { print $2 } ' | \ - sed -e s/addr://) - MY_ISP=$(curl www.wieistmeineip.de | awk '(/[0-9]?[0-9]?[0-9]\.[0-9]?[0-9]?[0-9]\.[0-9]?[0-9]?[0-9]\.[0-9]?[0-9]?[0-9]/) {print}' | awk 'gsub(/[>||<]/," ")' | awk '{print $3}') -} - -ii() { - echo -e "\nUser ${RED}"${USER:-"N/A"}"$NC on "${RED}${HOST:-"N/A"}"$NC" - echo -e "\n${RED}Additionnal information:$NC " ; uname -a - echo -e "\n${RED}Users logged on:$NC " ; w -h - echo -e "\n${RED}Current date:$NC " ; date - echo -e "\n${RED}Machine stats:$NC " ; uptime - echo -e "\n${RED}Memory stats:$NC " ; free - my_ip 2>&- ; - echo -e "\n${RED}Local IP Address:$NC" ; echo ${MY_IP:-"N/A"} - echo -e "\n${RED}ISP Address:$NC" ; echo ${MY_ISP:-"N/A"} - echo -} - -# short info to display when opening a new shell -short_ii() { - echo -e "\nUser ${RED}"${USER:-"N/A"}"$NC on "${RED}${HOST:-"N/A"}"$NC" - echo -e "\n${RED}Machine stats:$NC " ; uptime - echo -} - -# actually it converts any mp4 or flv to mp3... -youtube2mp3() { - for file in "$@" - do - if [ -f "${file}" ] ; then - title=$(echo ${file} | sed 's/\(.*\)\..*/\1/') - case $(file -b --mime-type "${file}") in - video/mp4) - faad "${file}" && - lame "${title}.wav" "${title}.mp3" && - rm "${title}.wav" - ;; - video/x-flv) - ffmpeg -i "${file}" -vn -acodec copy "${title}.mp3" - ;; - *) - echo -e "${RED}Error:$NC No rule how to convert \"${file}\"" - ;; - esac - else - echo -e "${RED}Error:$NC \"${file}\" doesn't exist" - fi - done -} - - -# vim: set ft=zsh: -- cgit v1.2.3-24-g4f1b