From 6085f0ffb85dd348e1ee999e3e5e676e73ed8c5f Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Sun, 10 Dec 2023 16:16:59 +0100 Subject: [PATCH] fish config --- .config/fish/conf.d/asdf.fish | 1 + .config/fish/config.fish | 11 ++++++ .config/fish/fish_variables | 43 +++++++++++++++++++++ .config/fish/functions/fish_prompt.fish | 51 +++++++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 .config/fish/conf.d/asdf.fish create mode 100644 .config/fish/config.fish create mode 100644 .config/fish/fish_variables create mode 100644 .config/fish/functions/fish_prompt.fish diff --git a/.config/fish/conf.d/asdf.fish b/.config/fish/conf.d/asdf.fish new file mode 100644 index 0000000..941a839 --- /dev/null +++ b/.config/fish/conf.d/asdf.fish @@ -0,0 +1 @@ +source ~/.asdf/asdf.fish diff --git a/.config/fish/config.fish b/.config/fish/config.fish new file mode 100644 index 0000000..4498a9d --- /dev/null +++ b/.config/fish/config.fish @@ -0,0 +1,11 @@ +if status is-interactive + # Commands to run in interactive sessions can go here +end +function multicd + echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../) +end +abbr --add dotdot --regex '^\.\.+$' --function multicd +abbr -a -- gst 'git status' +abbr -a -- gca 'git commit --amend' +abbr -a -- gpf 'git push -f' +abbr -a -- gp 'git pull' diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables new file mode 100644 index 0000000..0d8968c --- /dev/null +++ b/.config/fish/fish_variables @@ -0,0 +1,43 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3400 +SETUVAR fish_color_autosuggestion:4c566a +SETUVAR fish_color_cancel:\x2d\x2dreverse +SETUVAR fish_color_command:81a1c1 +SETUVAR fish_color_comment:434c5e +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:88c0d0 +SETUVAR fish_color_error:ebcb8b +SETUVAR fish_color_escape:00a6b2 +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:\x1d +SETUVAR fish_color_keyword:\x1d +SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:00a6b2 +SETUVAR fish_color_option:\x1d +SETUVAR fish_color_param:eceff4 +SETUVAR fish_color_quote:a3be8c +SETUVAR fish_color_redirection:b48ead +SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_background:\x1d +SETUVAR fish_pager_color_completion:normal +SETUVAR fish_pager_color_description:B3A06D +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_pager_color_secondary_background:\x1d +SETUVAR fish_pager_color_secondary_completion:\x1d +SETUVAR fish_pager_color_secondary_description:\x1d +SETUVAR fish_pager_color_secondary_prefix:\x1d +SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3dbrblack +SETUVAR fish_pager_color_selected_completion:\x1d +SETUVAR fish_pager_color_selected_description:\x1d +SETUVAR fish_pager_color_selected_prefix:\x1d +SETUVAR fish_user_paths:/opt/homebrew/bin diff --git a/.config/fish/functions/fish_prompt.fish b/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..4f28b2c --- /dev/null +++ b/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,51 @@ +function fish_prompt --description 'Write out the prompt' + set -l laststatus $status + + set -l git_info + if set -l git_branch (command git symbolic-ref HEAD 2>/dev/null | string replace refs/heads/ '') + set git_branch (set_color -o blue)"$git_branch" + set -l git_status + if not command git diff-index --quiet HEAD -- + if set -l count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null) + echo $count | read -l ahead behind + if test "$ahead" -gt 0 + set git_status "$git_status"(set_color red)⬆ + end + if test "$behind" -gt 0 + set git_status "$git_status"(set_color red)⬇ + end + end + for i in (git status --porcelain | string sub -l 2 | sort | uniq) + switch $i + case "." + set git_status "$git_status"(set_color green)✚ + case " D" + set git_status "$git_status"(set_color red)✖ + case "*M*" + set git_status "$git_status"(set_color green)✱ + case "*R*" + set git_status "$git_status"(set_color purple)➜ + case "*U*" + set git_status "$git_status"(set_color brown)═ + case "??" + set git_status "$git_status"(set_color red)≠ + end + end + else + set git_status (set_color green): + end + set git_info "(git$git_status$git_branch"(set_color white)")" + end + + # Disable PWD shortening by default. + set -q fish_prompt_pwd_dir_length + or set -lx fish_prompt_pwd_dir_length 0 + + set_color -b black + printf '%s%s%s%s%s%s%s%s%s%s%s%s%s' (set_color -o white) '❰' (set_color green) $USER (set_color white) '❙' (set_color yellow) (prompt_pwd) (set_color white) $git_info (set_color white) '❱' (set_color white) + if test $laststatus -eq 0 + printf "%s✔%s≻%s " (set_color -o green) (set_color white) (set_color normal) + else + printf "%s✘%s≻%s " (set_color -o red) (set_color white) (set_color normal) + end +end