Skip to content

Instantly share code, notes, and snippets.

@MRDGH2821
Last active September 11, 2024 11:14
Show Gist options
  • Save MRDGH2821/47294f0c61f3c9f061e8ffd28e1a538b to your computer and use it in GitHub Desktop.
Save MRDGH2821/47294f0c61f3c9f061e8ffd28e1a538b to your computer and use it in GitHub Desktop.
A random theme loader for Oh My Posh for bash shell
# Oh my posh random theme initializer
export PATH=~/bin:$PATH #provide path to oh-my-posh install folder
omp_themes_dir="$HOME/.cache/oh-my-posh/themes" #provide path to oh-my-posh installed themes
# Get a list of all JSON theme files in the directory
omp_themes=($(ls $omp_themes_dir/*.json))
# Get the number of JSON theme files
num_files=${#omp_themes[@]}
# Generate a random index
random_index=$((RANDOM % num_files))
# Select a random theme
random_omp_theme=${omp_themes[$random_index]}
# Set the selected theme
eval "$(oh-my-posh init bash --config $random_omp_theme)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment