theme_chooser.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. # Zsh Theme Chooser by fox (fox91 at anche dot no)
  3. # This program is free software. It comes without any warranty, to
  4. # the extent permitted by applicable law. You can redistribute it
  5. # and/or modify it under the terms of the Do What The Fuck You Want
  6. # To Public License, Version 2, as published by Sam Hocevar. See
  7. # http://sam.zoy.org/wtfpl/COPYING for more details.
  8. THEMES_DIR="$ZSH/themes"
  9. FAVLIST="${HOME}/.zsh_favlist"
  10. function noyes() {
  11. read -p "$1 [y/N] " a
  12. if [[ $a == "N" || $a == "n" || $a = "" ]]; then
  13. return 0
  14. fi
  15. return 1
  16. }
  17. function theme_preview() {
  18. THEME=$1
  19. export ZDOTDIR="$(mktemp -d tmp.zshXXXX)"
  20. cat <<-EOF >"$ZDOTDIR/.zshrc"
  21. source ~/.zshrc
  22. source "$THEMES_DIR/$THEME"
  23. EOF
  24. zsh
  25. rm -rf "$ZDOTDIR"
  26. echo
  27. noyes "Do you want to add it to your favourite list ($FAVLIST)?" || \
  28. echo $THEME >> $FAVLIST
  29. echo
  30. }
  31. echo
  32. echo "╺━┓┏━┓╻ ╻ ╺┳╸╻ ╻┏━╸┏┳┓┏━╸ ┏━╸╻ ╻┏━┓┏━┓┏━┓┏━╸┏━┓"
  33. echo "┏━┛┗━┓┣━┫ ┃ ┣━┫┣╸ ┃┃┃┣╸ ┃ ┣━┫┃ ┃┃ ┃┗━┓┣╸ ┣┳┛"
  34. echo "┗━╸┗━┛╹ ╹ ╹ ╹ ╹┗━╸╹ ╹┗━╸ ┗━╸╹ ╹┗━┛┗━┛┗━┛┗━╸╹┗╸"
  35. echo
  36. for i in $(ls $THEMES_DIR); do
  37. echo "Now showing theme $i"
  38. theme_preview $i
  39. done