From 8e32253d5d79c89ecc2111e3e2f3cc629d1f33b4 Mon Sep 17 00:00:00 2001 From: davidpkj Date: Tue, 3 Sep 2024 18:45:07 +0200 Subject: August 2024 Updates --- fish/.config/fish/config.fish | 54 ++++++++++++++++++++++++++++ fish/.config/fish/fish_variables | 33 +++++++++++++++++ fish/.config/fish/functions/fish_prompt.fish | 31 ++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 fish/.config/fish/config.fish create mode 100644 fish/.config/fish/fish_variables create mode 100644 fish/.config/fish/functions/fish_prompt.fish (limited to 'fish') diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish new file mode 100644 index 0000000..2c990fa --- /dev/null +++ b/fish/.config/fish/config.fish @@ -0,0 +1,54 @@ +if status is-interactive + # Commands to run in interactive sessions can go here + source ~/.bash_aliases + source ~/.config/env + + function su + command su --shell=/usr/bin/fish $argv + end + + function sudo --description "Replacement for Bash 'sudo !!' command to run last command using sudo." + if test "$argv" = !! + echo sudo $history[1] + eval command sudo $history[1] + else + command sudo $argv + end + end + + function fish_prompt --description 'Write out the prompt' + set -l normal (set_color normal) + set -q fish_color_status + or set -g fish_color_status red + + # Color the prompt differently when we're root + set -l color_cwd $fish_color_cwd + set -l suffix '$' + if functions -q fish_is_root_user; and fish_is_root_user + if set -q fish_color_cwd_root + set color_cwd $fish_color_cwd_root + end + set suffix '#' + end + + echo -n -s '< '(prompt_login)' > ' (set_color $color_cwd) (basename (prompt_pwd)) $normal (fish_vcs_prompt) $normal " "$suffix " " + end + + function fish_right_prompt + set -l last_pipestatus $pipestatus + set -lx __fish_last_status $status # Export for __fish_print_pipestatus. + # Write pipestatus + # If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it. + set -l bold_flag --bold + set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation + if test $__fish_prompt_status_generation = $status_generation + set bold_flag + end + set __fish_prompt_status_generation $status_generation + set -l status_color (set_color $fish_color_status) + set -l statusb_color (set_color $bold_flag $fish_color_status) + set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) + + echo $prompt_status + end +end diff --git a/fish/.config/fish/fish_variables b/fish/.config/fish/fish_variables new file mode 100644 index 0000000..7e78b79 --- /dev/null +++ b/fish/.config/fish/fish_variables @@ -0,0 +1,33 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3400 +SETUVAR fish_color_autosuggestion:brblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:blue +SETUVAR fish_color_comment:yellow +SETUVAR fish_color_cwd:magenta +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:green +SETUVAR fish_color_error:brred +SETUVAR fish_color_escape:brcyan +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:blue +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:brcyan +SETUVAR fish_color_param:cyan +SETUVAR fish_color_quote:yellow +SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold +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:blue +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_features:qmark\x2dnoglob +SETUVAR fish_greeting:\x1d +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:normal +SETUVAR fish_pager_color_description:yellow\x1e\x2di +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_selected_background:\x2dr diff --git a/fish/.config/fish/functions/fish_prompt.fish b/fish/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..9c4f6a7 --- /dev/null +++ b/fish/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,31 @@ +function fish_prompt --description 'Write out the prompt' + set -l last_pipestatus $pipestatus + set -lx __fish_last_status $status # Export for __fish_print_pipestatus. + set -l normal (set_color normal) + set -q fish_color_status + or set -g fish_color_status red + + # Color the prompt differently when we're root + set -l color_cwd $fish_color_cwd + set -l suffix '>' + if functions -q fish_is_root_user; and fish_is_root_user + if set -q fish_color_cwd_root + set color_cwd $fish_color_cwd_root + end + set suffix '#' + end + + # Write pipestatus + # If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it. + set -l bold_flag --bold + set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation + if test $__fish_prompt_status_generation = $status_generation + set bold_flag + end + set __fish_prompt_status_generation $status_generation + set -l status_color (set_color $fish_color_status) + set -l statusb_color (set_color $bold_flag $fish_color_status) + set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) + + echo -n -s (prompt_login)' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal " "$prompt_status $suffix " " +end -- cgit v1.2.3