diff --git a/config/scripts/.local/scripts/change-colortheme b/config/scripts/.local/scripts/change-colortheme index 3c7a970..6322837 100755 --- a/config/scripts/.local/scripts/change-colortheme +++ b/config/scripts/.local/scripts/change-colortheme @@ -48,7 +48,12 @@ SCRIPTS = { "nwg-look": [CONFIG_DIR / "nwg-look" / "apply-color"], "mako": [CONFIG_DIR / "mako" / "apply-color"], "niri": [CONFIG_DIR / "niri" / "apply-color"], - "oh-my-posh": [CONFIG_DIR / "fish" / "apply-color-omp"], # borrowing fish's directory + "oh-my-posh": [ + CONFIG_DIR / "fish" / "apply-color-omp" + ], # borrowing fish's directory + "starship": [ + CONFIG_DIR / "fish" / "apply-color-starship" + ], # borrowing fish's directory "quickshell": [CONFIG_DIR / "quickshell" / "apply-color"], "rofi": [CONFIG_DIR / "rofi" / "apply-color"], "waybar": [CONFIG_DIR / "waybar" / "apply-color"], @@ -68,7 +73,7 @@ success_count_lock = Lock() def hex2rgb(hex_color: str) -> tuple[int, int, int]: """#rrggbb to (r, g, b)""" - return tuple(int(hex_color[i: i + 2], 16) for i in (0, 2, 4)) # type: ignore + return tuple(int(hex_color[i : i + 2], 16) for i in (0, 2, 4)) # type: ignore def clamp(x, minimum, maximum) -> float: diff --git a/config/shell/.config/fish/apply-color-starship b/config/shell/.config/fish/apply-color-starship new file mode 100755 index 0000000..6b8c915 --- /dev/null +++ b/config/shell/.config/fish/apply-color-starship @@ -0,0 +1,21 @@ +#!/bin/bash + +[ -f "$HOME/.local/snippets/apply-color-helper" ] || { + echo "Missing helper script: $HOME/.local/snippets/apply-color-helper" + exit 1 +} +. "$HOME/.local/snippets/apply-color-helper" + +file="$path"/../starship.toml + +sed -i \ + -e "s/^palette\s*=.*/palette = '${palette}'/" \ + -e "/^\[palettes\.${palette}\]/,/^\[/{s/^accent\s*=.*/accent = \"#${colorHex}\"/}" \ + "$file" + +if [ $? -ne 0 ]; then + log_error "Failed to edit ${file}" + exit 1 +fi + +log_success "starship" diff --git a/config/shell/.config/fish/conf.d/50-prompt.fish b/config/shell/.config/fish/conf.d/50-prompt.fish index d35f874..6f6db5b 100644 --- a/config/shell/.config/fish/conf.d/50-prompt.fish +++ b/config/shell/.config/fish/conf.d/50-prompt.fish @@ -9,4 +9,6 @@ end # oh-my-posh if test -f $HOME/.config/posh_theme.omp.json; and type -q oh-my-posh eval (oh-my-posh init fish --config $HOME/.config/posh_theme.omp.json) +else if type -q starship + eval (starship init fish) end diff --git a/config/shell/.config/posh_theme.omp.json b/config/shell/.config/posh_theme.omp.json index 1d7db8b..3ea853b 100755 --- a/config/shell/.config/posh_theme.omp.json +++ b/config/shell/.config/posh_theme.omp.json @@ -37,7 +37,7 @@ }, { "foreground": "#a6e3a1", - "powerline_symbol": "\ue0b1", + "powerline_symbol": "❯", "options": { "branch_icon": "\ue725 ", "fetch_status": true, @@ -54,7 +54,7 @@ }, { "foreground": "#f9e2af", - "powerline_symbol": "\ue0b1", + "powerline_symbol": "❯", "template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ", "style": "powerline", "type": "python" @@ -97,4 +97,4 @@ "template": "# " }, "version": 3 -} \ No newline at end of file +} diff --git a/config/shell/.config/starship.toml b/config/shell/.config/starship.toml new file mode 100644 index 0000000..410467a --- /dev/null +++ b/config/shell/.config/starship.toml @@ -0,0 +1,331 @@ +"$schema" = 'https://starship.rs/config-schema.json' + +format = """ +$os\ +$username\ +$hostname\ +$directory\ +$shell\ +$git_branch\ +$git_status\ +$c\ +$rust\ +$golang\ +$nodejs\ +$php\ +$java\ +$kotlin\ +$haskell\ +$python\ +$conda\ +$line_break\ +$character""" + +right_format = """ +$status\ +$cmd_duration""" + +palette = 'catppuccin-mocha' + +add_newline = false + +[profiles] +transient = """ +$character""" + +[os] +disabled = false +style = "fg:accent" + +[os.symbols] +Alpaquita = " " +Alpine = " " +AlmaLinux = " " +Amazon = " " +Android = " " +AOSC = " " +Arch = " " +Artix = " " +CachyOS = " " +CentOS = " " +Debian = " " +DragonFly = " " +Elementary = " " +Emscripten = " " +EndeavourOS = " " +Fedora = " " +FreeBSD = " " +Garuda = "󰛓 " +Gentoo = " " +HardenedBSD = "󰞌 " +Illumos = "󰈸 " +Ios = "󰀷 " +Kali = " " +Linux = " " +Mabox = " " +Macos = " " +Manjaro = " " +Mariner = " " +MidnightBSD = " " +Mint = " " +NetBSD = " " +NixOS = " " +Nobara = " " +OpenBSD = "󰈺 " +openSUSE = " " +OracleLinux = "󰌷 " +Pop = " " +Raspbian = " " +Redhat = " " +RedHatEnterprise = " " +RockyLinux = " " +Redox = "󰀘 " +Solus = "󰠳 " +SUSE = " " +Ubuntu = " " +Unknown = " " +Void = " " +Windows = "󰍲 " +Zorin = " " + +[username] +show_always = true +style_user = "fg:accent" +style_root = "fg:red" +format = '[$user]($style)' + +[hostname] +ssh_only = false +style = "fg:accent" +format = '[@$hostname]($style)' + + +[directory] +style = "fg:teal" +format = "[  $path ]($style)" +truncation_length = 3 +truncation_symbol = "…/" + +[directory.substitutions] +"Documents" = "󰈙 " +"Downloads" = " " +"Music" = "󰝚 " +"Pictures" = " " +"Developer" = "󰲋 " + +[shell] +disabled = false +format = '[❯ $indicator ]($style)' +style = "fg:sky" +bash_indicator = "bash" +fish_indicator = "fish" +zsh_indicator = "zsh" +powershell_indicator = "pwsh" +pwsh_indicator = "pwsh" + +[git_branch] +symbol = "" +style = "fg:yellow" +format = '[❯ $symbol $branch ]($style)' + +[git_status] +style = "fg:yellow" +format = '[($all_status$ahead_behind )]($style)' + +[nodejs] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version) ]($style)' + +[c] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version) ]($style)' + +[rust] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version) ]($style)' + +[golang] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version) ]($style)' + +[php] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version) ]($style)' + +[java] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version) ]($style)' + +[kotlin] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version) ]($style)' + +[haskell] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version) ]($style)' + +[python] +symbol = "" +style = "fg:green" +format = '[❯ $symbol( $version)(\(#$virtualenv\)) ]($style)' + +[docker_context] +symbol = "" +style = "fg:sapphire" +format = '[❯ $symbol( $context) ]($style)' + +[conda] +symbol = "  " +style = "fg:sapphire" +format = '[$symbol$environment ]($style)' +ignore_base = false + +[line_break] +disabled = false + +[status] +disabled = false +success_style = "fg:accent" +failure_style = "fg:red" +format = '[$status ]($style)' + + +[character] +disabled = false +success_symbol = '[#](bold fg:accent)' +error_symbol = '[#](bold fg:red)' +vimcmd_symbol = '[❮](bold fg:green)' +vimcmd_replace_one_symbol = '[❮](bold fg:lavender)' +vimcmd_replace_symbol = '[❮](bold fg:lavender)' +vimcmd_visual_symbol = '[❮](bold fg:yellow)' + +[cmd_duration] +min_time = 0 +show_milliseconds = true +format = "[in $duration]($style)" +style = "fg:accent" +disabled = false + +[palettes.catppuccin-mocha] +rosewater = "#f5e0dc" +flamingo = "#f2cdcd" +pink = "#f5c2e7" +mauve = "#cba6f7" +red = "#f38ba8" +maroon = "#eba0ac" +peach = "#fab387" +yellow = "#f9e2af" +green = "#a6e3a1" +teal = "#94e2d5" +sky = "#89dceb" +sapphire = "#74c7ec" +blue = "#89b4fa" +lavender = "#b4befe" +text = "#cdd6f4" +subtext1 = "#bac2de" +subtext0 = "#a6adc8" +overlay2 = "#9399b2" +overlay1 = "#7f849c" +overlay0 = "#6c7086" +surface2 = "#585b70" +surface1 = "#45475a" +surface0 = "#313244" +base = "#1e1e2e" +mantle = "#181825" +crust = "#11111b" +accent = "#89b4fa" + +[palettes.catppuccin-frappe] +rosewater = "#f2d5cf" +flamingo = "#eebebe" +pink = "#f4b8e4" +mauve = "#ca9ee6" +red = "#e78284" +maroon = "#ea999c" +peach = "#ef9f76" +yellow = "#e5c890" +green = "#a6d189" +teal = "#81c8be" +sky = "#99d1db" +sapphire = "#85c1dc" +blue = "#8caaee" +lavender = "#babbf1" +text = "#c6d0f5" +subtext1 = "#b5bfe2" +subtext0 = "#a5adce" +overlay2 = "#949cbb" +overlay1 = "#838ba7" +overlay0 = "#737994" +surface2 = "#626880" +surface1 = "#51576d" +surface0 = "#414559" +base = "#303446" +mantle = "#292c3c" +crust = "#232634" +accent = "#8caaee" + +[palettes.catppuccin-latte] +rosewater = "#dc8a78" +flamingo = "#dd7878" +pink = "#ea76cb" +mauve = "#8839ef" +red = "#d20f39" +maroon = "#e64553" +peach = "#fe640b" +yellow = "#df8e1d" +green = "#40a02b" +teal = "#179299" +sky = "#04a5e5" +sapphire = "#209fb5" +blue = "#1e66f5" +lavender = "#7287fd" +text = "#4c4f69" +subtext1 = "#5c5f77" +subtext0 = "#6c6f85" +overlay2 = "#7c7f93" +overlay1 = "#8c8fa1" +overlay0 = "#9ca0b0" +surface2 = "#acb0be" +surface1 = "#bcc0cc" +surface0 = "#ccd0da" +base = "#eff1f5" +mantle = "#e6e9ef" +crust = "#dce0e8" +accent = "#1e66f5" + +[palettes.catppuccin-macchiato] +rosewater = "#f4dbd6" +flamingo = "#f0c6c6" +pink = "#f5bde6" +mauve = "#c6a0f6" +red = "#ed8796" +maroon = "#ee99a0" +peach = "#f5a97f" +yellow = "#eed49f" +green = "#a6da95" +teal = "#8bd5ca" +sky = "#91d7e3" +sapphire = "#7dc4e4" +blue = "#8aadf4" +lavender = "#b7bdf8" +text = "#cad3f5" +subtext1 = "#b8c0e0" +subtext0 = "#a5adcb" +overlay2 = "#939ab7" +overlay1 = "#8087a2" +overlay0 = "#6e738d" +surface2 = "#5b6078" +surface1 = "#494d64" +surface0 = "#363a4f" +base = "#24273a" +mantle = "#1e2030" +crust = "#181926" +accent = "#8aadf4" diff --git a/config/shell/.config/zsh/conf.d/01-options.zsh b/config/shell/.config/zsh/conf.d/01-options.zsh index a6c9fe9..4a1b4a9 100644 --- a/config/shell/.config/zsh/conf.d/01-options.zsh +++ b/config/shell/.config/zsh/conf.d/01-options.zsh @@ -13,7 +13,7 @@ setopt HIST_VERIFY setopt AUTO_CD EXTENDED_GLOB NOTIFY INTERACTIVE_COMMENTS bindkey -e -WORDCHARS=${WORDCHARS//[\/=\*-]/} +WORDCHARS=${WORDCHARS//[\/=\*\.-]/} # Rookie keybindings :) bindkey '^[[1;5D' backward-word # C-Left diff --git a/config/shell/.config/zsh/conf.d/50-prompt.zsh b/config/shell/.config/zsh/conf.d/50-prompt.zsh index 6141439..ac07f90 100644 --- a/config/shell/.config/zsh/conf.d/50-prompt.zsh +++ b/config/shell/.config/zsh/conf.d/50-prompt.zsh @@ -1,7 +1,25 @@ # Fallback prompt (if oh-my-posh is not available) PROMPT='%F{blue}%n@%m%f %F{cyan}%~%f > ' +# starship +if (( $+commands[starship] )); then + eval "$(starship init zsh)" + + autoload -Uz add-zle-hook-widget + add-zle-hook-widget zle-line-finish transient-prompt + + function transient-prompt() { + local file palette color + file=${STARSHIP_CONFIG:-"$HOME/.config/starship.toml"} + palette=$(sed -n "s/^palette\s*=\s*'\(.*\)'/\1/p" "$file") + color=$(sed -n "/^\[palettes\.${palette}\]/,/^\[/{s/^accent\s*=\s*\"\(.*\)\"/\1/p}" "$file") + + PROMPT="%F{$color}#%f " zle .reset-prompt + } + + # oh-my-posh -if [[ -f "$HOME/.config/posh_theme.omp.json" ]] && (( $+commands[oh-my-posh] )); then - eval "$(oh-my-posh init zsh --config "$HOME/.config/posh_theme.omp.json")" +elif [[ -f "$HOME/.config/posh_theme.omp.json" ]] && (( $+commands[oh-my-posh] )); then + eval "$(oh-my-posh init zsh --config "$HOME/.config/posh_theme.omp.json")" fi +