2011-08-03 09:42:16 +02:00
|
|
|
|
#!/bin/zsh
|
2011-07-19 21:47:26 +02:00
|
|
|
|
|
|
|
|
|
# Zsh Theme Chooser by fox (fox91 at anche dot no)
|
|
|
|
|
# This program is free software. It comes without any warranty, to
|
|
|
|
|
# the extent permitted by applicable law. You can redistribute it
|
|
|
|
|
# and/or modify it under the terms of the Do What The Fuck You Want
|
|
|
|
|
# To Public License, Version 2, as published by Sam Hocevar. See
|
2018-08-07 20:42:02 +02:00
|
|
|
|
# http://www.wtfpl.net/txt/copying/ for more details.
|
2011-07-19 21:47:26 +02:00
|
|
|
|
|
|
|
|
|
THEMES_DIR="$ZSH/themes"
|
2011-07-19 22:02:34 +02:00
|
|
|
|
FAVLIST="${HOME}/.zsh_favlist"
|
2011-08-03 09:42:16 +02:00
|
|
|
|
source $ZSH/oh-my-zsh.sh
|
2011-07-19 21:47:26 +02:00
|
|
|
|
|
|
|
|
|
function noyes() {
|
2011-08-03 09:42:16 +02:00
|
|
|
|
read "a?$1 [y/N] "
|
2011-07-19 21:47:26 +02:00
|
|
|
|
if [[ $a == "N" || $a == "n" || $a = "" ]]; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function theme_preview() {
|
|
|
|
|
THEME=$1
|
2011-08-03 09:42:16 +02:00
|
|
|
|
THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//`
|
|
|
|
|
print "$fg[blue]${(l.((${COLUMNS}-${#THEME_NAME}-5))..─.)}$reset_color $THEME_NAME $fg[blue]───$reset_color"
|
|
|
|
|
source "$THEMES_DIR/$THEME"
|
2013-09-10 11:28:31 +02:00
|
|
|
|
cols=$(tput cols)
|
2021-04-06 12:23:59 +02:00
|
|
|
|
(exit 1)
|
2013-09-10 11:28:31 +02:00
|
|
|
|
print -P "$PROMPT $RPROMPT"
|
2011-08-03 09:42:16 +02:00
|
|
|
|
}
|
2011-07-19 21:47:26 +02:00
|
|
|
|
|
2011-08-03 09:42:16 +02:00
|
|
|
|
function banner() {
|
2011-07-19 21:47:26 +02:00
|
|
|
|
echo
|
2011-08-03 09:42:16 +02:00
|
|
|
|
echo "[0;1;35;95m╺━[0;1;31;91m┓┏[0;1;33;93m━┓[0;1;32;92m╻[0m [0;1;36;96m╻[0m [0;1;35;95m╺┳[0;1;31;91m╸╻[0m [0;1;33;93m╻[0;1;32;92m┏━[0;1;36;96m╸┏[0;1;34;94m┳┓[0;1;35;95m┏━[0;1;31;91m╸[0m [0;1;32;92m┏━[0;1;36;96m╸╻[0m [0;1;34;94m╻[0;1;35;95m┏━[0;1;31;91m┓┏[0;1;33;93m━┓[0;1;32;92m┏━[0;1;36;96m┓┏[0;1;34;94m━╸[0;1;35;95m┏━[0;1;31;91m┓[0m"
|
|
|
|
|
echo "[0;1;31;91m┏━[0;1;33;93m┛┗[0;1;32;92m━┓[0;1;36;96m┣━[0;1;34;94m┫[0m [0;1;31;91m┃[0m [0;1;33;93m┣[0;1;32;92m━┫[0;1;36;96m┣╸[0m [0;1;34;94m┃[0;1;35;95m┃┃[0;1;31;91m┣╸[0m [0;1;36;96m┃[0m [0;1;34;94m┣[0;1;35;95m━┫[0;1;31;91m┃[0m [0;1;33;93m┃┃[0m [0;1;32;92m┃[0;1;36;96m┗━[0;1;34;94m┓┣[0;1;35;95m╸[0m [0;1;31;91m┣┳[0;1;33;93m┛[0m"
|
|
|
|
|
echo "[0;1;33;93m┗━[0;1;32;92m╸┗[0;1;36;96m━┛[0;1;34;94m╹[0m [0;1;35;95m╹[0m [0;1;33;93m╹[0m [0;1;32;92m╹[0m [0;1;36;96m╹[0;1;34;94m┗━[0;1;35;95m╸╹[0m [0;1;31;91m╹[0;1;33;93m┗━[0;1;32;92m╸[0m [0;1;34;94m┗━[0;1;35;95m╸╹[0m [0;1;31;91m╹[0;1;33;93m┗━[0;1;32;92m┛┗[0;1;36;96m━┛[0;1;34;94m┗━[0;1;35;95m┛┗[0;1;31;91m━╸[0;1;33;93m╹┗[0;1;32;92m╸[0m"
|
2011-07-19 21:47:26 +02:00
|
|
|
|
echo
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-03 09:42:16 +02:00
|
|
|
|
function usage() {
|
|
|
|
|
echo "Usage: $0 [options] [theme]"
|
|
|
|
|
echo
|
|
|
|
|
echo "Options"
|
|
|
|
|
echo " -l List available themes"
|
|
|
|
|
echo " -s Show all themes"
|
|
|
|
|
echo " -h Get this help message"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function list_themes() {
|
|
|
|
|
for THEME in $(ls $THEMES_DIR); do
|
|
|
|
|
THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//`
|
|
|
|
|
echo $THEME_NAME
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function insert_favlist() {
|
|
|
|
|
if grep -q "$THEME_NAME" $FAVLIST 2> /dev/null ; then
|
|
|
|
|
echo "Already in favlist"
|
|
|
|
|
else
|
|
|
|
|
echo $THEME_NAME >> $FAVLIST
|
|
|
|
|
echo "Saved to favlist"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
}
|
2011-07-19 21:47:26 +02:00
|
|
|
|
|
2011-08-03 09:42:16 +02:00
|
|
|
|
function theme_chooser() {
|
|
|
|
|
for THEME in $(ls $THEMES_DIR); do
|
|
|
|
|
echo
|
|
|
|
|
theme_preview $THEME
|
|
|
|
|
echo
|
|
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
|
noyes "Do you want to add it to your favourite list ($FAVLIST)?" || \
|
|
|
|
|
insert_favlist $THEME_NAME
|
|
|
|
|
echo
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while getopts ":lhs" Option
|
|
|
|
|
do
|
|
|
|
|
case $Option in
|
|
|
|
|
l ) list_themes ;;
|
|
|
|
|
s ) theme_chooser 0 ;;
|
|
|
|
|
h ) usage ;;
|
|
|
|
|
* ) usage ;; # Default.
|
|
|
|
|
esac
|
2011-07-19 21:47:26 +02:00
|
|
|
|
done
|
2011-08-03 09:42:16 +02:00
|
|
|
|
|
|
|
|
|
if [[ -z $Option ]]; then
|
|
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
|
banner
|
|
|
|
|
echo
|
|
|
|
|
theme_chooser
|
|
|
|
|
else
|
|
|
|
|
theme_preview $1".zsh-theme"
|
|
|
|
|
fi
|
|
|
|
|
fi
|