chore: Update setup.sh

This commit is contained in:
Fabio Lenherr / DashieTM 2024-02-11 15:53:22 +01:00
parent 45ca8d534f
commit 7884a29617
32 changed files with 296 additions and 151 deletions

View file

@ -6,7 +6,7 @@ function _tide_detect_os
printf %s\n  D6D6D6 333333 # from apple.com header
case freebsd openbsd dragonfly
printf %s\n  FFFFFF AB2B28 # https://freebsdfoundation.org/about-us/about-the-foundation/project/
case 'cygwin*'
case 'cygwin*' 'mingw*_nt*' 'msys_nt*'
printf %s\n  FFFFFF 00CCFF # https://answers.microsoft.com/en-us/windows/forum/all/what-is-the-official-windows-8-blue-rgb-or-hex/fd57144b-f69b-42d8-8c21-6ca911646e44
case linux
if test (uname -o) = Android
@ -53,11 +53,11 @@ function _tide_detect_os_linux_cases -a file key
printf %s\n  FFFFFF 262F45 # https://wiki.mageia.org/en/Artwork_guidelines
case manjaro
printf %s\n  FFFFFF 35BF5C # from https://gitlab.manjaro.org/artwork/branding/logo/-/blob/master/logo.svg
case mint
case mint linuxmint
printf %s\n  FFFFFF 69B53F # extracted from https://linuxmint.com/web/img/favicon.ico
case nixos
printf %s\n  FFFFFF 5277C3 # https://github.com/NixOS/nixos-artwork/tree/master/logo
case opensuse-leap opensuse-tumbleweed
case opensuse-leap opensuse-tumbleweed opensuse-microos
printf %s\n  73BA25 173f4f # https://en.opensuse.org/openSUSE:Artwork_brand
case raspbian
printf %s\n  FFFFFF A22846 # https://static.raspberrypi.org/files/Raspberry_Pi_Visual_Guidelines_2020.pdf

View file

@ -0,0 +1,7 @@
function _tide_item_direnv
set -q DIRENV_DIR || return
direnv status | string match -q 'Found RC allowed false' \
&& set -lx tide_direnv_color $tide_direnv_color_denied \
&& set -lx tide_direnv_bg_color $tide_direnv_bg_color_denied
_tide_print_item direnv $tide_direnv_icon
end

View file

@ -0,0 +1,4 @@
function _tide_item_distrobox
test -e /etc/profile.d/distrobox_profile.sh && test -e /run/.containerenv &&
_tide_print_item distrobox $tide_distrobox_icon' ' (string match -rg 'name="(.*)"' </run/.containerenv)
end

View file

@ -0,0 +1,4 @@
function _tide_item_elixir
path is $_tide_parent_dirs/mix.exs &&
_tide_print_item elixir $tide_elixir_icon' ' (elixir --short-version)
end

View file

@ -0,0 +1,8 @@
function _tide_item_gcloud
set -q CLOUDSDK_CONFIG || set -l CLOUDSDK_CONFIG ~/.config/gcloud
path is $CLOUDSDK_CONFIG/active_config \
&& read -l config <$CLOUDSDK_CONFIG/active_config \
&& path is $CLOUDSDK_CONFIG/configurations/config_$config \
&& string match -qr '^\s*project\s*=\s*(?<project>.*)' <$CLOUDSDK_CONFIG/configurations/config_$config \
&& _tide_print_item gcloud $tide_gcloud_icon' ' $project
end

View file

@ -1,10 +1,10 @@
function _tide_item_git
if git branch --show-current 2>/dev/null | string replace -r ".+(.{$tide_git_truncation_length})" '…$1' | read -l location
if git branch --show-current 2>/dev/null | string shorten -"$tide_git_truncation_strategy"m$tide_git_truncation_length | read -l location
git rev-parse --git-dir --is-inside-git-dir | read -fL gdir in_gdir
set location $_tide_location_color$location
else if test $pipestatus[1] != 0
return
else if git tag --points-at HEAD | string replace -r ".+(.{$tide_git_truncation_length})" '…$1' | read location
else if git tag --points-at HEAD | string shorten -"$tide_git_truncation_strategy"m$tide_git_truncation_length | read location
git rev-parse --git-dir --is-inside-git-dir | read -fL gdir in_gdir
set location '#'$_tide_location_color$location
else
@ -40,8 +40,8 @@ function _tide_item_git
# Git status/stash + Upstream behind/ahead
test $in_gdir = true && set -l _set_dir_opt -C $gdir/..
# Suppress errors in case we are in a bare repo or there is no upstream
stat=(git $_set_dir_opt --no-optional-locks status --porcelain 2>/dev/null) \
string match -qr '(0|(?<stash>.*))\n(0|(?<conflicted>.*))\n(0|(?<staged>.*))
set -l stat (git $_set_dir_opt --no-optional-locks status --porcelain 2>/dev/null)
string match -qr '(0|(?<stash>.*))\n(0|(?<conflicted>.*))\n(0|(?<staged>.*))
(0|(?<dirty>.*))\n(0|(?<untracked>.*))(\n(0|(?<behind>.*))\t(0|(?<ahead>.*)))?' \
"$(git $_set_dir_opt stash list 2>/dev/null | count
string match -r ^UU $stat | count

View file

@ -0,0 +1,19 @@
function _tide_item_pulumi
if path filter $_tide_parent_dirs/Pulumi.yaml | read -l yaml_path
if command -q sha1sum
echo -n "$yaml_path" | sha1sum | string sub -e40 | read -f path_hash
else if command -q shasum
echo -n "$yaml_path" | shasum | string sub -e40 | read -f path_hash
end
if test -n "$path_hash"
string match -rg 'name: *(.*)' <$yaml_path | read -l project_name
set -l workspace_file "$HOME/.pulumi/workspaces/$project_name-$path_hash-workspace.json"
if test -e $workspace_file
string match -rg '"stack": *"(.*)"' <$workspace_file | read -l stack
_tide_print_item pulumi $tide_pulumi_icon' ' $stack
end
end
end
end

View file

@ -1,3 +1,4 @@
function _tide_item_toolbox
test -e /run/.toolboxenv && _tide_print_item toolbox $tide_toolbox_icon' ' $hostname
test -e /run/.toolboxenv &&
_tide_print_item toolbox $tide_toolbox_icon' ' (string match -rg 'name="(.*)"' </run/.containerenv)
end

View file

@ -26,7 +26,8 @@ eval "function _tide_pwd
set split_output[\$i] \"$color_anchors\$dir_section$reset_to_color_dirs\"
else if test \$_tide_pwd_len -gt \$dist_btwn_sides
set -l trunc
while string match -qr \"(?<trunc>\$trunc.)\" \$dir_section && v=\$parent_dir/\$trunc*/ set -q v[2]
string match -qr \"(?<trunc>\..|.)\" \$dir_section
while v=\$parent_dir/\$trunc*/ set -q v[2] && string match -qr \"(?<trunc>\$trunc.)\" \$dir_section
end
test -n \"\$trunc\" && set split_output[\$i] \"$color_truncated\$trunc$reset_to_color_dirs\" &&
string join / \$split_output | string length -V | read _tide_pwd_len

View file

@ -1,9 +1,13 @@
function _tide_remove_unusable_items
# Remove tool-specific items for tools the machine doesn't have installed
set -l removed_items
for item in aws chruby crystal docker git go java kubectl nix_shell node php rustc terraform toolbox virtual_env
for item in aws chruby crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi rustc terraform toolbox virtual_env
contains $item $tide_left_prompt_items $tide_right_prompt_items || continue
set -l cli_names $item
switch $item
case distrobox # there is no 'distrobox' command inside the container
set cli_names distrobox-export # 'distrobox-export' and 'distrobox-host-exec' are available
case virtual_env
set cli_names python python3
case nix_shell

View file

@ -2,7 +2,7 @@ function tide --description 'Manage your Tide prompt'
argparse --stop-nonopt v/version h/help -- $argv
if set -q _flag_version
echo 'tide, version 5.5.1'
echo 'tide, version 5.6.0'
else if set -q _flag_help
_tide_help
else if functions --query _tide_sub_$argv[1]

View file

@ -24,10 +24,24 @@ tide_context_hostname_parts 1
tide_crystal_bg_color 444444
tide_crystal_color FFFFFF
tide_crystal_icon
tide_direnv_bg_color 444444
tide_direnv_bg_color_denied 444444
tide_direnv_color $_tide_color_gold
tide_direnv_color_denied FF0000
tide_direnv_icon
tide_distrobox_bg_color 444444
tide_distrobox_color FF00FF
tide_distrobox_icon
tide_docker_bg_color 444444
tide_docker_color 2496ED
tide_docker_default_contexts default colima
tide_docker_icon
tide_elixir_bg_color 444444
tide_elixir_color 4E2A8E
tide_elixir_icon
tide_gcloud_bg_color 444444
tide_gcloud_color 4285F4
tide_gcloud_icon
tide_git_bg_color 444444
tide_git_bg_color_unstable 444444
tide_git_bg_color_urgent 444444
@ -41,6 +55,7 @@ tide_git_color_untracked $_tide_color_light_blue
tide_git_color_upstream $_tide_color_green
tide_git_icon
tide_git_truncation_length 24
tide_git_truncation_strategy
tide_go_bg_color 444444
tide_go_color 00ACD7
tide_go_icon
@ -80,6 +95,9 @@ tide_prompt_color_separator_same_color 949494
tide_prompt_icon_connection ' '
tide_prompt_min_cols 34
tide_prompt_pad_items true
tide_pulumi_bg_color 444444
tide_pulumi_color F7BF2A
tide_pulumi_icon ''
tide_pwd_bg_color 444444
tide_pwd_color_anchors $_tide_color_light_blue
tide_pwd_color_dirs $_tide_color_dark_blue
@ -89,7 +107,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled true
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi chruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir
tide_right_prompt_prefix
tide_right_prompt_separator_diff_color
tide_right_prompt_separator_same_color

View file

@ -12,8 +12,18 @@ tide_context_color_root bryellow
tide_context_color_ssh yellow
tide_crystal_bg_color black
tide_crystal_color brwhite
tide_direnv_bg_color black
tide_direnv_bg_color_denied black
tide_direnv_color bryellow
tide_direnv_color_denied brred
tide_distrobox_bg_color black
tide_distrobox_color brmagenta
tide_docker_bg_color black
tide_docker_color blue
tide_elixir_bg_color black
tide_elixir_color magenta
tide_gcloud_bg_color black
tide_gcloud_color blue
tide_git_bg_color black
tide_git_bg_color_unstable black
tide_git_bg_color_urgent black
@ -45,6 +55,8 @@ tide_private_mode_bg_color black
tide_private_mode_color brwhite
tide_prompt_color_frame_and_connection brblack
tide_prompt_color_separator_same_color brblack
tide_pulumi_bg_color black
tide_pulumi_color yellow
tide_pwd_bg_color black
tide_pwd_color_anchors brcyan
tide_pwd_color_dirs cyan

View file

@ -24,10 +24,24 @@ tide_context_hostname_parts 1
tide_crystal_bg_color normal
tide_crystal_color FFFFFF
tide_crystal_icon
tide_direnv_bg_color normal
tide_direnv_bg_color_denied normal
tide_direnv_color $_tide_color_gold
tide_direnv_color_denied FF0000
tide_direnv_icon
tide_distrobox_bg_color normal
tide_distrobox_color FF00FF
tide_distrobox_icon
tide_docker_bg_color normal
tide_docker_color 2496ED
tide_docker_default_contexts default colima
tide_docker_icon
tide_elixir_bg_color normal
tide_elixir_color 4E2A8E
tide_elixir_icon
tide_gcloud_bg_color normal
tide_gcloud_color 4285F4
tide_gcloud_icon
tide_git_bg_color normal
tide_git_bg_color_unstable normal
tide_git_bg_color_urgent normal
@ -41,6 +55,7 @@ tide_git_color_untracked $_tide_color_light_blue
tide_git_color_upstream $_tide_color_green
tide_git_icon
tide_git_truncation_length 24
tide_git_truncation_strategy
tide_go_bg_color normal
tide_go_color 00ACD7
tide_go_icon
@ -80,6 +95,9 @@ tide_prompt_color_separator_same_color 949494
tide_prompt_icon_connection ' '
tide_prompt_min_cols 34
tide_prompt_pad_items false
tide_pulumi_bg_color normal
tide_pulumi_color F7BF2A
tide_pulumi_icon ''
tide_pwd_bg_color normal
tide_pwd_color_anchors $_tide_color_light_blue
tide_pwd_color_dirs $_tide_color_dark_blue
@ -89,7 +107,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled false
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi chruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir
tide_right_prompt_prefix ' '
tide_right_prompt_separator_diff_color ' '
tide_right_prompt_separator_same_color ' '

View file

@ -12,8 +12,18 @@ tide_context_color_root bryellow
tide_context_color_ssh yellow
tide_crystal_bg_color normal
tide_crystal_color brwhite
tide_direnv_bg_color normal
tide_direnv_bg_color_denied normal
tide_direnv_color bryellow
tide_direnv_color_denied brred
tide_distrobox_bg_color normal
tide_distrobox_color brmagenta
tide_docker_bg_color normal
tide_docker_color blue
tide_elixir_bg_color normal
tide_elixir_color magenta
tide_gcloud_bg_color normal
tide_gcloud_color blue
tide_git_bg_color normal
tide_git_bg_color_unstable normal
tide_git_bg_color_urgent normal
@ -45,6 +55,8 @@ tide_private_mode_bg_color normal
tide_private_mode_color brwhite
tide_prompt_color_frame_and_connection brblack
tide_prompt_color_separator_same_color brblack
tide_pulumi_bg_color normal
tide_pulumi_color yellow
tide_pwd_bg_color normal
tide_pwd_color_anchors brcyan
tide_pwd_color_dirs cyan

View file

@ -24,10 +24,24 @@ tide_context_hostname_parts 1
tide_crystal_bg_color FFFFFF
tide_crystal_color 000000
tide_crystal_icon
tide_direnv_bg_color $_tide_color_gold
tide_direnv_bg_color_denied FF0000
tide_direnv_color 000000
tide_direnv_color_denied 000000
tide_direnv_icon
tide_distrobox_bg_color FF00FF
tide_distrobox_color 000000
tide_distrobox_icon
tide_docker_bg_color 2496ED
tide_docker_color 000000
tide_docker_default_contexts default colima
tide_docker_icon
tide_elixir_bg_color 4E2A8E
tide_elixir_color 000000
tide_elixir_icon
tide_gcloud_bg_color 4285F4
tide_gcloud_color 000000
tide_gcloud_icon
tide_git_bg_color 4E9A06
tide_git_bg_color_unstable C4A000
tide_git_bg_color_urgent CC0000
@ -41,6 +55,7 @@ tide_git_color_untracked 000000
tide_git_color_upstream 000000
tide_git_icon
tide_git_truncation_length 24
tide_git_truncation_strategy
tide_go_bg_color 00ACD7
tide_go_color 000000
tide_go_icon
@ -80,6 +95,9 @@ tide_prompt_color_separator_same_color 949494
tide_prompt_icon_connection ' '
tide_prompt_min_cols 34
tide_prompt_pad_items true
tide_pulumi_bg_color F7BF2A
tide_pulumi_color 000000
tide_pulumi_icon ''
tide_pwd_bg_color 3465A4
tide_pwd_color_anchors E4E4E4
tide_pwd_color_dirs E4E4E4
@ -89,7 +107,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled true
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi chruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir
tide_right_prompt_prefix
tide_right_prompt_separator_diff_color
tide_right_prompt_separator_same_color

View file

@ -12,8 +12,18 @@ tide_context_color_root yellow
tide_context_color_ssh yellow
tide_crystal_bg_color brwhite
tide_crystal_color black
tide_direnv_bg_color bryellow
tide_direnv_bg_color_denied brred
tide_direnv_color black
tide_direnv_color_denied black
tide_distrobox_bg_color brmagenta
tide_distrobox_color black
tide_docker_bg_color blue
tide_docker_color black
tide_elixir_bg_color magenta
tide_elixir_color black
tide_gcloud_bg_color blue
tide_gcloud_color black
tide_git_bg_color green
tide_git_bg_color_unstable yellow
tide_git_bg_color_urgent red
@ -45,6 +55,8 @@ tide_private_mode_bg_color brwhite
tide_private_mode_color black
tide_prompt_color_frame_and_connection brblack
tide_prompt_color_separator_same_color brblack
tide_pulumi_bg_color yellow
tide_pulumi_color black
tide_pwd_bg_color blue
tide_pwd_color_anchors brwhite
tide_pwd_color_dirs brwhite