Created
May 23, 2022 18:00
-
-
Save archae0pteryx/376c7e78662c89e222dc59b0d757bfdb to your computer and use it in GitHub Desktop.
Script to select random oh-my-posh theme on shell init
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POSH_THEME_DIR="$(brew --prefix oh-my-posh)/themes" | |
LIST_OF_THEMES=() | |
while IFS='' read -r line; do LIST_OF_THEMES+=("$line"); done < <(find "$POSH_THEME_DIR" -type f -print) | |
TOTAL_NUM_THEMES=${#LIST_OF_THEMES[@]} | |
RAND_NUM=$(( RANDOM % TOTAL_NUM_THEMES )) | |
SELECTED_THEME="${LIST_OF_THEMES[$RAND_NUM]}" | |
echo "${SELECTED_THEME}" | |
eval "$(oh-my-posh --init --shell zsh --config ${SELECTED_THEME})" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ex. usage
curl -o https://gist.github.com/archae0pteryx/376c7e78662c89e222dc59b0d757bfdb ~/.config/random-posh-theme
~/.zshrc
like sosource ~/.config/random-posh-theme
source ~/.zshrc
When you find one you like, you can copy the
eval "$(...)"
line with the path to the theme output when the shell loaded directly into your~/.zshrc