From 84e1a45e61ea77896725dacebc2e1f6a22091a94 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 24 Feb 2009 19:21:13 +0100 Subject: removed function keywords and normalized indentation --- .zsh/rc/30functions | 81 +++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 43 deletions(-) (limited to '.zsh') diff --git a/.zsh/rc/30functions b/.zsh/rc/30functions index 9427bfe..b7d0493 100644 --- a/.zsh/rc/30functions +++ b/.zsh/rc/30functions @@ -1,14 +1,14 @@ #-------------------- -# Functions +# Functions #-------------------- # always /etc/rc.d/blub is a bit too much work ;) -rc () { +rc() { sudo /etc/rc.d/$1 $2 } # usefull if you have more machines and want to easily update the config here -update_zshrc () { +update_zshrc() { old_pwd="$PWD" builtin cd "$HOME/.zsh" wget http://flo.server-speed.net/stuff/dotfiles/zshrc -O $HOME/.zshrc @@ -37,7 +37,7 @@ ls () { 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 () { +password() { if [ -z "$1" ]; then count=8 else @@ -114,7 +114,7 @@ hglob() { } # download any package's PKGBUILD and go into that dir -yd (){ +yd(){ if [ -n "$1" ]; then mkdir -p $1 builtin cd $1 @@ -134,35 +134,32 @@ google(){ } # swaps 2 files -function 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 +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 -function 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}') +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}') } -function ii() -{ +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 @@ -176,29 +173,27 @@ function ii() } # short info to display when opening a new shell -function short_ii() -{ +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 } -function repeat() -{ - if [ "$1" = "" ] || [ "$2" = "" ] || [ "$1" = "-h" ]; then - echo -e "${blue}Usage:$NC repeat "; - echo -e "Repeats a command"; - return 1 - fi - local i max - max=$1; shift; - for ((i=1; i <= max ; i++)); do - eval "$@"; - done +repeat() { + if [ "$1" = "" ] || [ "$2" = "" ] || [ "$1" = "-h" ]; then + echo -e "${blue}Usage:$NC repeat "; + echo -e "Repeats a command"; + return 1 + fi + local i max + max=$1; shift; + for ((i=1; i <= max ; i++)); do + eval "$@"; + done } # actually it converts any mp4 or flv to mp3... -youtube2mp3 () { +youtube2mp3() { for file in "$@" do if [ -f ${file} ] ; then -- cgit v1.2.3-24-g4f1b