functions.zsh 1000 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function zsh_stats() {
  2. history | awk '{print $2}' | sort | uniq -c | sort -rn | head
  3. }
  4. function uninstall_oh_my_zsh() {
  5. /bin/sh $ZSH/tools/uninstall.sh
  6. }
  7. function upgrade_oh_my_zsh() {
  8. /bin/sh $ZSH/tools/upgrade.sh
  9. }
  10. function take() {
  11. mkdir -p $1
  12. cd $1
  13. }
  14. function extract() {
  15. unset REMOVE_ARCHIVE
  16. if test "$1" = "-r"; then
  17. REMOVE=1
  18. shift
  19. fi
  20. if [[ -f $1 ]]; then
  21. case $1 in
  22. *.tar.bz2) tar xvjf $1;;
  23. *.tar.gz) tar xvzf $1;;
  24. *.tar.xz) tar xvJf $1;;
  25. *.tar.lzma) tar --lzma -xvf $1;;
  26. *.bz2) bunzip $1;;
  27. *.rar) unrar $1;;
  28. *.gz) gunzip $1;;
  29. *.tar) tar xvf $1;;
  30. *.tbz2) tar xvjf $1;;
  31. *.tgz) tar xvzf $1;;
  32. *.zip) unzip $1;;
  33. *.Z) uncompress $1;;
  34. *.7z) 7z x $1;;
  35. *) echo "'$1' cannot be extracted via >extract<";;
  36. esac
  37. if [[ $REMOVE_ARCHIVE -eq 1 ]]; then
  38. echo removing "$1";
  39. /bin/rm "$1";
  40. fi
  41. else
  42. echo "'$1' is not a valid file"
  43. fi
  44. }