mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
offer a menu for selecting themes
This commit is contained in:
parent
d136c535f1
commit
fe416f56fc
1 changed files with 33 additions and 16 deletions
|
|
@ -1,29 +1,46 @@
|
||||||
ZSH_THEMES=$ZSH/themes
|
export ZSH_THEMES_PATH=$ZSH/themes
|
||||||
|
|
||||||
function change_theme() {
|
# Directly change a theme
|
||||||
|
function usetheme() {
|
||||||
if [ $1 ] && theme_name=${1%.zsh-theme}; then
|
if [ $1 ] && theme_name=${1%.zsh-theme}; then
|
||||||
printf "Changing theme... "
|
printf "Changing theme to $1... "
|
||||||
|
|
||||||
if [ -f $ZSH_THEMES/$theme_name.zsh-theme ]; then
|
if [ -f $ZSH_THEMES_PATH/$theme_name.zsh-theme ]; then
|
||||||
source $ZSH_THEMES/$theme_name.zsh-theme
|
source $ZSH_THEMES_PATH/$theme_name.zsh-theme
|
||||||
export ZSH_THEME=$theme_name
|
export ZSH_THEME=$theme_name
|
||||||
echo "$fg_bold[green]Done"
|
echo "$fg_bold[green]Done"
|
||||||
else
|
else
|
||||||
printf "$fg_bold[red]Notice$reset_color: "
|
printf "$fg_bold[red]Error$reset_color: "
|
||||||
echo "Could not find theme: '$theme_name.zsh-theme' in $ZSH_THEMES"
|
echo "Could not find theme: '$theme_name.zsh-theme' in $ZSH_THEMES_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "change_theme: no theme given"
|
echo "No theme given"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function list_themes() {
|
# Change themes through a menu style prompt
|
||||||
more < <(
|
function changetheme() {
|
||||||
echo "Themes available (press 'q' to quit)"
|
theme_files=($ZSH_THEMES_PATH/*)
|
||||||
echo "===================================="
|
theme_names=(${${theme_files[@]##*/}[@]%.zsh-theme})
|
||||||
for theme ($ZSH_THEMES/*)
|
|
||||||
do
|
PS3="Enter your selection: "
|
||||||
echo "${${theme%.zsh-theme}##*/}"
|
SELECTION=""
|
||||||
done)
|
|
||||||
|
echo "Themes available:"
|
||||||
|
select theme in ${theme_names[@]} Quit
|
||||||
|
do
|
||||||
|
case $theme in
|
||||||
|
Quit)
|
||||||
|
echo "Exiting... "
|
||||||
|
exit;;
|
||||||
|
*)
|
||||||
|
SELECTION=$REPLY
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
theme="${theme_names[$SELECTION]}"
|
||||||
|
usetheme $theme
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue