From 1cae96dbcaf032d417ebf8d7e49a8577c84ad9f9 Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sat, 19 Apr 2014 02:30:49 +0200 Subject: Added 2 zsh functions and play.sh skip now the copy and sleep process if file exists in --- bin/play | 106 +++++++++++++++++++++++++++++++++-------------------------- zsh/.zsh_prg | 25 ++++++++++++++ 2 files changed, 85 insertions(+), 46 deletions(-) create mode 100644 zsh/.zsh_prg diff --git a/bin/play b/bin/play index 83e6460..e88eb63 100755 --- a/bin/play +++ b/bin/play @@ -11,12 +11,13 @@ printhelp(){ echo "Bash script to play and cache files from a slow network ressource" echo "" - echo "-y move to archiv without question" - echo "-n don't ask for moving" - echo "-o ask for a different archiv" - echo "-r only remove the file in /tmp" - echo "-d don't ask for downloading" - echo "-h prints this help" + echo " -d only remove the file in /tmp" + echo " -g don't ask for downloading" + echo " -h prints this help" + echo " -n don't ask for moving" + echo " -y move to archiv without question" + echo " -o ask for a different archiv" + echo " -no-cache Not caching the file, instead play's directly" exit 0 } @@ -54,6 +55,16 @@ if [ $# -eq 0 ]; then printhelp fi +if [ $# -gt 1 ]; then + echo "Do not commit more than one file." + exit 1 +fi + +if [ ! -f "$1" ]; then + echo "No valid file input." + exit +fi + player[0]=$(command -v mpv) #media player of choice player[1]=$(command -v mplayer) player[2]=$(command -v vlc) #you shouldn't use vlc @@ -101,7 +112,7 @@ if [ $cache -gt 0 ]; then wget -q -O "file" "$@" & echo "Starting download. Ready to play in 2 sec." sleep 2 - mpv file + mpv $file echo "TODO: Moving to archiv. Not implemented yet." exit 0 elif [[ $player =~ mpv$ ]] && [ $download ] && ( [ ! $download = "n" ] && [ ! $download = "N" ] && [ ! $download = "no" ] && [ ! $download = "nein" ] && [ ! $download = "NO" ]); then @@ -119,16 +130,23 @@ if [ $cache -gt 0 ]; then exit 1 fi else - cp "$@" "$tmp" & + file=$(basename "$@") + if [ -f "$tmp/$file" ]; then + skip=true + fi + cp -u -i "$@" "$tmp" & cd "$tmp" - file=${@##*/} - - echo -n "Preparing the awesome! Starting playback in.." - echo -n " 2," - sleep 1 - echo -n " 1" - sleep 1 - echo " Start!" + #file=${@##*/} + + if [ ! $skip ]; then + echo -n "Preparing the awesome! Starting playback in.." + echo -n " 2," + sleep 1 + echo -n " 1 " + sleep 1 + fi + + echo "Start!" fi else echo -n "Preparing the awesome! Starting playback in.." @@ -138,44 +156,40 @@ fi $player "$file" if [ $? -eq 0 ]; then - if [ $cache -gt 0 ]; then - if [ -d $ARCHIV ] && [ -w $ARCHIV ] && [ $ARCHIV ]; then - echo "Finished $file succesfull." - if [ ! $verify ]; then - read -p "Should we move everything to the archiv? ($ARCHIV) [Y/n/rm/other] " verify + if [ -d $ARCHIV ] && [ -w $ARCHIV ] && [ $ARCHIV ]; then + echo "Finished $file succesfull." + if [ ! $verify ]; then + read -p "Should we move everything to the archiv? ($ARCHIV) [Y/n/rm/other] " verify + fi + if [ ! $verify ] || [ $verify = "ja" ] || [ $verify = "yes" ] || [ $verify = "j" ] || [ $verify = "y" ] || [ $verify = "Y" ]; then + echo "Moving the stuff to $ARCHIV." + mv -v "$file" "$ARCHIV" + if [ $? -eq 0 ]; then + cd "$pwd" + rm -v "$@" fi - if [ ! $verify ] || [ $verify = "ja" ] || [ $verify = "yes" ] || [ $verify = "j" ] || [ $verify = "y" ] || [ $verify = "Y" ]; then - echo "Moving the stuff to $ARCHIV." - mv -v "$file" "$ARCHIV" + elif [ $verify = "other" ] || [ $verify = "o" ] || [ $verify = "O" ] || [ $verify = "OTHER" ]; then + read -p "Please tell us the absolute path: " path + if [ -d $path ] && [ -w $path ]; then + echo "Moving to $path." + mv -v "$file" "$path" if [ $? -eq 0 ]; then cd "$pwd" - rm -v "$@" - fi - elif [ $verify = "other" ] || [ $verify = "o" ] || [ $verify = "O" ] || [ $verify = "OTHER" ]; then - read -p "Please tell us the absolute path: " path - if [ -d $path ] && [ -w $path ]; then - echo "Moving to $path." - mv -v "$file" "$path" - if [ $? -eq 0 ]; then - cd "$pwd" - rm -v "$@" - fi - else - echo "Sorry, \"$path\" doesn't exist." - exit 1 - fi - elif [ $verify = "r" ] || [ $verify = "rm" ] || [ $verify = "remove" ] || [ $verify = "RM" ] || [ $verify = "R" ]; then - echo "Cleaning the mess up. Only removing files from $tmp." - rm -v "$file" + rm -v "$@" + fi else - echo "Okay, don't touching the files." + echo "Sorry, \"$path\" doesn't exist." + exit 1 fi + elif [ $verify = "r" ] || [ $verify = "rm" ] || [ $verify = "remove" ] || [ $verify = "RM" ] || [ $verify = "R" ]; then + echo "Cleaning the mess up. Only removing files from $tmp." + rm -v "$file" else - echo "Can't move to \"$ARCHIV\". Directory doesn't exist or you don't have write permission." - exit 1 + echo "Okay, don't touching the files." fi else - echo "Nothing was cached, nothing is touched." + echo "Can't move to \"$ARCHIV\". Directory doesn't exist or you don't have write permission." + exit 1 fi else echo "Something is broken with the media player!" diff --git a/zsh/.zsh_prg b/zsh/.zsh_prg new file mode 100644 index 0000000..51f63f5 --- /dev/null +++ b/zsh/.zsh_prg @@ -0,0 +1,25 @@ +ex () +{ + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via ex()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +calc(){ + echo "scale=3;$@" | bc -l +} -- cgit v1.2.3 From b8bc1ad2af6aab7f9dd3937c78dab76b0c32bdca Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sun, 27 Apr 2014 18:14:37 +0200 Subject: Vim mapping and zsh alias. --- vim/.vimrc | 4 ++++ zsh/.zsh_aliases | 1 + zsh/.zsh_prg | 25 ------------------------- zsh/.zsh_prog | 25 +++++++++++++++++++++++++ zsh/.zshrc | 8 ++++++++ 5 files changed, 38 insertions(+), 25 deletions(-) delete mode 100644 zsh/.zsh_prg create mode 100644 zsh/.zsh_prog diff --git a/vim/.vimrc b/vim/.vimrc index c6da008..19c8833 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -13,3 +13,7 @@ syntax enable set encoding=utf8 "map! jj +command W w +command Q q +command WQ wq +command Wq wq diff --git a/zsh/.zsh_aliases b/zsh/.zsh_aliases index ad3cd8e..ef59608 100644 --- a/zsh/.zsh_aliases +++ b/zsh/.zsh_aliases @@ -16,3 +16,4 @@ alias nano='nano -wc' alias du='du -h' alias down='sudo shutdown -hP now' alias df='df -h' +alias lll='ls -lisa' diff --git a/zsh/.zsh_prg b/zsh/.zsh_prg deleted file mode 100644 index 51f63f5..0000000 --- a/zsh/.zsh_prg +++ /dev/null @@ -1,25 +0,0 @@ -ex () -{ - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar xjf $1 ;; - *.tar.gz) tar xzf $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) unrar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xf $1 ;; - *.tbz2) tar xjf $1 ;; - *.tgz) tar xzf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1;; - *.7z) 7z x $1 ;; - *) echo "'$1' cannot be extracted via ex()" ;; - esac - else - echo "'$1' is not a valid file" - fi -} - -calc(){ - echo "scale=3;$@" | bc -l -} diff --git a/zsh/.zsh_prog b/zsh/.zsh_prog new file mode 100644 index 0000000..51f63f5 --- /dev/null +++ b/zsh/.zsh_prog @@ -0,0 +1,25 @@ +ex () +{ + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via ex()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +calc(){ + echo "scale=3;$@" | bc -l +} diff --git a/zsh/.zshrc b/zsh/.zshrc index 612f5c1..95c5018 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -3325,3 +3325,11 @@ fi if [ -f ~/.zsh_dirstack ]; then . ~/.zsh_dirstack fi + +if [ -f ~/.zsh_prog ]; then + . ~/.zsh_prog +fi + +if [ -f ~/.zshrc_orig ]; then + . ~/.zshrc_orig +fi -- cgit v1.2.3 From abc2cb5d9ccad98c563968519c89b19f3640fc4a Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sun, 27 Apr 2014 18:27:19 +0200 Subject: Improved dirhist. --- bin/dirhistory.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/dirhistory.sh b/bin/dirhistory.sh index cc652d2..d449539 100644 --- a/bin/dirhistory.sh +++ b/bin/dirhistory.sh @@ -1,2 +1,4 @@ #!/bin/zsh -for ((i=1; i<=$DIRSTACKSIZE; i++)) echo "$i $dirstack[$i]" + +echo "Printing directory stack: " +for ((i=1; i<=$DIRSTACKSIZE-1; i++)), do echo "$i $dirstack[$i]"; done -- cgit v1.2.3 From 09c97f22ecbcbdf152308c60c79e0f9fea5e63e3 Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sun, 27 Apr 2014 18:37:48 +0200 Subject: Fixed typo --- bin/dirhistory.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 bin/dirhistory.sh diff --git a/bin/dirhistory.sh b/bin/dirhistory.sh old mode 100644 new mode 100755 index d449539..06e82c2 --- a/bin/dirhistory.sh +++ b/bin/dirhistory.sh @@ -1,4 +1,7 @@ #!/bin/zsh echo "Printing directory stack: " -for ((i=1; i<=$DIRSTACKSIZE-1; i++)), do echo "$i $dirstack[$i]"; done +for ((i=1; i<$DIRSTACKSIZE; i++)) +do + echo "$i $dirstack[$i]" +done -- cgit v1.2.3