my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

3 years ago
  1. function theme {
  2. : ${1:=random} # Use random theme if none provided
  3. if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
  4. source "$ZSH_CUSTOM/$1.zsh-theme"
  5. elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
  6. source "$ZSH_CUSTOM/themes/$1.zsh-theme"
  7. elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
  8. source "$ZSH/themes/$1.zsh-theme"
  9. else
  10. echo "$0: Theme '$1' not found"
  11. return 1
  12. fi
  13. }
  14. function _theme {
  15. _arguments "1: :($(lstheme))"
  16. }
  17. compdef _theme theme
  18. function lstheme {
  19. # Resources:
  20. # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
  21. # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers
  22. {
  23. # Show themes inside $ZSH_CUSTOM (in any subfolder)
  24. # Strip $ZSH_CUSTOM/themes/ and $ZSH_CUSTOM/ from the name, so that it matches
  25. # the value that should be written in $ZSH_THEME to load the theme.
  26. print -l "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)
  27. # Show themes inside $ZSH, stripping the head of the path.
  28. print -l "$ZSH"/themes/*.zsh-theme(.N:t:r)
  29. } | sort -u | fmt -w $COLUMNS
  30. }