Use sub directory instead of file namespacing

This commit is contained in:
David Heinemeier Hansson
2024-07-03 14:12:12 +02:00
parent 1965e0b609
commit 9f6dd4d39a
15 changed files with 177 additions and 135 deletions

View File

@@ -2,4 +2,6 @@
source $OMAKUB_PATH/ascii.sh
echo "" # Add spacing
source $OMAKUB_PATH/bin/omakub-menu
echo " $(cat $OMAKUB_PATH/version)"
echo "" # Add spacing
source $OMAKUB_PATH/bin/omakub-sub/menu.sh

View File

@@ -1,43 +0,0 @@
set_font() {
local font_name=$1
local url=$2
local file_type=$3
local file_name="${font_name/ Nerd Font/}"
if ! $(fc-list | grep -i "$font_name" > /dev/null); then
cd /tmp
wget -O "$file_name.zip" "$url"
unzip "$file_name.zip" -d "$file_name"
cp "$file_name"/*."$file_type" ~/.local/share/fonts
rm -rf "$file_name.zip" "$file_name"
fc-cache
cd -
fi
gsettings set org.gnome.desktop.interface monospace-font-name "$font_name 10"
cp "$OMAKUB_PATH/fonts/alacritty/$file_name.toml" ~/.config/alacritty/font.toml
sed -i "s/\"editor.fontFamily\": \".*\"/\"editor.fontFamily\": \"$font_name\"/g" ~/.config/Code/User/settings.json
}
if [ "$#" -gt 1 ]; then
choice=${!#}
else
choice=$(gum choose "Cascadia Mono" "Fira Mono" "JetBrains Mono" "Meslo" "<< Back" --height 7 --header "Choose your programming font")
fi
case $choice in
"Cascadia Mono")
set_font "CaskaydiaMono Nerd Font" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/CascadiaMono.zip" "ttf"
;;
"Fira Mono")
set_font "FiraMono Nerd Font" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FiraMono.zip" "otf"
;;
"JetBrains Mono")
set_font "JetBrainsMono Nerd Font" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.zip" "ttf"
;;
"Meslo")
set_font "MesloLGS Nerd Font" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip" "Meslo" "ttf"
;;
esac
source $OMAKUB_PATH/bin/omakub-menu

View File

@@ -1,4 +0,0 @@
INSTALLER=$(gum file $OMAKUB_PATH/install)
[ -n "$INSTALLER" ] && gum confirm "Run installer?" && source $INSTALLER
clear
source $OMAKUB_PATH/bin/omakub

View File

@@ -1,7 +0,0 @@
if [ $# -eq 0 ]; then
SUB=$(gum choose "Theme" "Font" "Install" "Uninstall" "Help" "Update" "Quit" --height 10 --header "" | tr '[:upper:]' '[:lower:]')
else
SUB=$1
fi
[ -n "$SUB" ] && [ "$SUB" != "quit" ] && source $OMAKUB_PATH/bin/omakub-$SUB

View File

@@ -0,0 +1,8 @@
choice=$(gum choose {7..14} "<< Back" --height 11 --header "Choose your terminal font size")
if [[ $choice =~ ^[0-9]+$ ]]; then
sed -i "s/^size = .*$/size = $choice/g" ~/.config/alacritty/font-size.toml
source $OMAKUB_PATH/bin/omakub-sub/font-size.sh
else
source $OMAKUB_PATH/bin/omakub-sub/font.sh
fi

49
bin/omakub-sub/font.sh Normal file
View File

@@ -0,0 +1,49 @@
set_font() {
local font_name=$1
local url=$2
local file_type=$3
local file_name="${font_name/ Nerd Font/}"
if ! $(fc-list | grep -i "$font_name" >/dev/null); then
cd /tmp
wget -O "$file_name.zip" "$url"
unzip "$file_name.zip" -d "$file_name"
cp "$file_name"/*."$file_type" ~/.local/share/fonts
rm -rf "$file_name.zip" "$file_name"
fc-cache
cd -
clear
source $OMAKUB_PATH/ascii.sh
fi
gsettings set org.gnome.desktop.interface monospace-font-name "$font_name 10"
cp "$OMAKUB_PATH/configs/alacritty/fonts/$file_name.toml" ~/.config/alacritty/font.toml
sed -i "s/\"editor.fontFamily\": \".*\"/\"editor.fontFamily\": \"$font_name\"/g" ~/.config/Code/User/settings.json
}
if [ "$#" -gt 1 ]; then
choice=${!#}
else
choice=$(gum choose "Cascadia Mono" "Fira Mono" "JetBrains Mono" "Meslo" "> Change size" "<< Back" --height 8 --header "Choose your programming font")
fi
case $choice in
"Cascadia Mono")
set_font "CaskaydiaMono Nerd Font" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/CascadiaMono.zip" "ttf"
;;
"Fira Mono")
set_font "FiraMono Nerd Font" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FiraMono.zip" "otf"
;;
"JetBrains Mono")
set_font "JetBrainsMono Nerd Font" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.zip" "ttf"
;;
"Meslo")
set_font "MesloLGS Nerd Font" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip" "ttf"
;;
"> Change size")
source $OMAKUB_PATH/bin/omakub-sub/font-size.sh
exit
;;
esac
source $OMAKUB_PATH/bin/omakub-sub/menu.sh

View File

@@ -1,3 +1,3 @@
HELP=$(gum choose "Hotkeys" "Commands" "Tactile" --header "What do you need help with?" --height 5 | tr '[:upper:]' '[:lower:]')
[ -n "$HELP" ] && gum pager --soft-wrap <$OMAKUB_PATH/help/$HELP.md
source $OMAKUB_PATH/bin/omakub-menu
source $OMAKUB_PATH/bin/omakub-sub/menu.sh

45
bin/omakub-sub/install.sh Normal file
View File

@@ -0,0 +1,45 @@
CHOICES=(
"Dev Language Install programming language environment"
"Dev Database Install development database in Docker"
"1password Manage your passwords securely across devices"
"Brave Chrome-based browser with built-in ad blocking"
"Dropbox Sync files across computers with ease"
"OBS Studio Record screencasts with inputs from both display + webcam"
"Audacity Record and edit audio"
"Ollama Run LLMs, like Meta's Llama3, locally"
"RubyMine IntelliJ's commercial Ruby editor"
"Spotify Stream music from the world's most popular service"
"Steam Play games from Valve's store"
"Zoom Attend and host video chat meetings"
"VirtualBox Virtual machines to run Windows/Linux"
"> All Re-run any of the default installers"
"<< Back "
)
CHOICE=$(gum choose "${CHOICES[@]}" --height 17 --header "Install application")
if [[ "$CHOICE" == "<< Back"* ]] || [[ -z "$CHOICE" ]]; then
# Don't install anything
echo ""
elif [[ "$CHOICE" == "> All"* ]]; then
INSTALLER_FILE=$(gum file $OMAKUB_PATH/install)
[[ -n "$INSTALLER_FILE" ]] &&
gum confirm "Run installer?" &&
source $INSTALLER_FILE &&
gum spin --spinner globe --title "Install completed!" -- sleep 3
else
INSTALLER=$(echo "$CHOICE" | awk -F ' {2,}' '{print $1}' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')
case "$INSTALLER" in
"dev-language") INSTALLER_FILE="$OMAKUB_PATH/install/terminal/select-dev-language.sh" ;;
"dev-database") INSTALLER_FILE="$OMAKUB_PATH/install/terminal/select-dev-storage.sh" ;;
"ollama") INSTALLER_FILE="$OMAKUB_PATH/install/terminal/optional/app-ollama.sh" ;;
*) INSTALLER_FILE="$OMAKUB_PATH/install/desktop/optional/app-$INSTALLER.sh" ;;
esac
source $INSTALLER_FILE && gum spin --spinner globe --title "Install completed!" -- sleep 3
fi
clear
source $OMAKUB_PATH/bin/omakub

7
bin/omakub-sub/menu.sh Normal file
View File

@@ -0,0 +1,7 @@
if [ $# -eq 0 ]; then
SUB=$(gum choose "Theme" "Font" "Update" "Install" "Uninstall" "Help" "Quit" --height 10 --header "" | tr '[:upper:]' '[:lower:]')
else
SUB=$1
fi
[ -n "$SUB" ] && [ "$SUB" != "quit" ] && source $OMAKUB_PATH/bin/omakub-sub/$SUB.sh

15
bin/omakub-sub/migrate.sh Normal file
View File

@@ -0,0 +1,15 @@
cd $OMAKUB_PATH
last_updated_at=$(git log -1 --format=%cd --date=unix)
git pull
for file in $OMAKUB_PATH/migrations/*.sh; do
filename=$(basename "$file")
migrate_at="${filename%.sh}"
if [ $migrate_at -gt $last_updated_at ]; then
echo "Running migration for $migrate_at"
source $file
fi
done
cd -

18
bin/omakub-sub/theme.sh Normal file
View File

@@ -0,0 +1,18 @@
THEME_NAMES=("Tokyo Night" "Catppuccin" "Nord" "Everforest" "Gruvbox" "Kanagawa" "Rose Pine")
THEME=$(gum choose "${THEME_NAMES[@]}" "<< Back" --header "Choose your theme" --height 10 | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')
if [ -n "$THEME" ] && [ "$THEME" != "<<-back" ]; then
cp $OMAKUB_PATH/themes/$THEME/alacritty.toml ~/.config/alacritty/theme.toml
cp $OMAKUB_PATH/themes/$THEME/zellij.kdl ~/.config/zellij/themes/$THEME.kdl
sed -i "s/theme \".*\"/theme \"$THEME\"/g" ~/.config/zellij/config.kdl
cp $OMAKUB_PATH/themes/$THEME/neovim.lua ~/.config/nvim/lua/plugins/theme.lua
source $OMAKUB_PATH/themes/$THEME/gnome.sh
source $OMAKUB_PATH/themes/$THEME/vscode.sh
# Forgo setting the Chrome theme until we might find a less disruptive way of doing it.
# Having to quit Chrome, and all Chrome-based apps, is too much of an inposition.
# source $OMAKUB_PATH/themes/$THEME/chrome.sh
fi
source $OMAKUB_PATH/bin/omakub-sub/menu.sh

View File

@@ -1,4 +1,4 @@
UNINSTALLER=$(gum file $OMAKUB_PATH/uninstall)
[ -n "$UNINSTALLER" ] && gum confirm "Run uninstaller?" && source $UNINSTALLER
[ -n "$UNINSTALLER" ] && gum confirm "Run uninstaller?" && source $UNINSTALLER && gum spin --spinner globe --title "Uninstall completed!" -- sleep 3
clear
source $OMAKUB_PATH/bin/omakub

30
bin/omakub-sub/update.sh Normal file
View File

@@ -0,0 +1,30 @@
CHOICES=(
"Omakub Update Omakub itself and run any migrations"
"Ollama Run LLMs, like Meta's Llama3, locally"
"LazyGit TUI for Git"
"LazyDocker TUI for Docker"
"Neovim Text editor that runs in the terminal"
"Zellij Adds panes, tabs, and sessions to the terminal"
"<< Back "
)
CHOICE=$(gum choose "${CHOICES[@]}" --height 10 --header "Update manually-managed applications")
if [[ "$CHOICE" == "<< Back"* ]] || [[ -z "$CHOICE" ]]; then
# Don't update anything
echo ""
else
INSTALLER=$(echo "$CHOICE" | awk -F ' {2,}' '{print $1}' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')
case "$INSTALLER" in
"omakub") INSTALLER_FILE="$OMAKUB_PATH/bin/omakub-sub/migrate.sh" ;;
"localsend") INSTALLER_FILE="$OMAKUB_PATH/install/desktop/app-localsend.sh" ;;
"ollama") INSTALLER_FILE="$OMAKUB_PATH/install/terminal/optional/app-ollama.sh" ;;
*) INSTALLER_FILE="$OMAKUB_PATH/install/terminal/app-$INSTALLER.sh" ;;
esac
source $INSTALLER_FILE && gum spin --spinner globe --title "Update completed!" -- sleep 3
fi
clear
source $OMAKUB_PATH/bin/omakub

View File

@@ -1,58 +0,0 @@
# Pick a preconfigured theme
THEME_NAMES=("Tokyo Night" "Catppuccin" "Nord" "Everforest" "Gruvbox" "Kanagawa" "Rose Pine")
THEME=$(gum choose "${THEME_NAMES[@]}" "<< Back" --header "Choose your theme" --height 10 | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')
if [ -n "$THEME" ] && [ "$THEME" != "<<-back" ]; then
# Install theme in Gnome, Terminal, and both default editors
source $OMAKUB_PATH/themes/gnome/$THEME.sh
cp $OMAKUB_PATH/themes/alacritty/$THEME.toml ~/.config/alacritty/theme.toml
if [ ! -f ~/.config/nvim/plugin/after/transparency.lua ]; then
mkdir -p ~/.config/nvim/plugin/after
cp $OMAKUB_PATH/configs/neovim/transparency.lua ~/.config/nvim/plugin/after/transparency.lua
fi
# Chrome theme update
if gum confirm "Do you want to update Chrome theme? If yes, Chrome will be restarted!"; then
pkill -f chrome
while pgrep -f chrome > /dev/null; do
sleep 0.1
done
source $OMAKUB_PATH/themes/chrome/$THEME.sh
google-chrome > /dev/null 2>&1 &
fi
cp $OMAKUB_PATH/themes/neovim/$THEME.lua ~/.config/nvim/lua/plugins/theme.lua
sed -i "s/theme \".*\"/theme \"$THEME\"/g" ~/.config/zellij/config.kdl
# Translate to specific VSC theme name
if [ "$THEME" == "gruvbox" ]; then
VSC_THEME="Gruvbox Dark Medium"
VSC_EXTENSION="jdinhlife.gruvbox"
elif [ "$THEME" == "catppuccin" ]; then
VSC_THEME="Catppuccin Macchiato"
VSC_EXTENSION="Catppuccin.catppuccin-vsc"
elif [ "$THEME" == "tokyo-night" ]; then
VSC_THEME="Tokyo Night"
VSC_EXTENSION="enkia.tokyo-night"
elif [ "$THEME" == "everforest" ]; then
VSC_THEME="Everforest Dark"
VSC_EXTENSION="sainnhe.everforest"
elif [ "$THEME" == "rose-pine" ]; then
VSC_THEME="Rosé Pine Dawn"
VSC_EXTENSION="mvllow.rose-pine"
elif [ "$THEME" == "nord" ]; then
VSC_THEME="Nord"
VSC_EXTENSION="arcticicestudio.nord-visual-studio-code"
elif [ "$THEME" == "kanagawa" ]; then
VSC_THEME="Kanagawa"
VSC_EXTENSION="qufiwefefwoyn.kanagawa"
fi
code --install-extension $VSC_EXTENSION > /dev/null
sed -i "s/\"workbench.colorTheme\": \".*\"/\"workbench.colorTheme\": \"$VSC_THEME\"/g" ~/.config/Code/User/settings.json
fi
source $OMAKUB_PATH/bin/omakub-menu

View File

@@ -1,20 +0,0 @@
#!/usr/bin/bash
cd $OMAKUB_PATH
last_updated_at=$(git log -1 --format=%cd --date=unix)
git pull
for file in $OMAKUB_PATH/migrations/*.sh; do
filename=$(basename "$file")
migrate_at="${filename%.sh}"
if [ $migrate_at -gt $last_updated_at ]; then
echo "Running migration for $migrate_at"
source $file
fi
done
cd -
gum spin --spinner globe --title "Update has completed!" -- sleep 3
clear
source $OMAKUB_PATH/bin/omakub