From 359ab04faa13be929b9d9effcf6d60f62748ee48 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Mon, 28 Aug 2023 15:50:06 -0700 Subject: [PATCH] Add fish config --- fish/.gitignore | 5 ++ fish/config.fish | 16 ++++++ fish/fishd_color | 33 ++++++++++++ fish/functions/fish_mode_prompt.fish | 24 +++++++++ fish/functions/fish_prompt.fish | 78 +++++++++++++++++++++++++++ fish/functions/fish_right_prompt.fish | 8 +++ 6 files changed, 164 insertions(+) create mode 100644 fish/.gitignore create mode 100755 fish/config.fish create mode 100755 fish/fishd_color create mode 100755 fish/functions/fish_mode_prompt.fish create mode 100755 fish/functions/fish_prompt.fish create mode 100755 fish/functions/fish_right_prompt.fish diff --git a/fish/.gitignore b/fish/.gitignore new file mode 100644 index 0000000..6242cfe --- /dev/null +++ b/fish/.gitignore @@ -0,0 +1,5 @@ +# Automatically generated or machine specific variables +fish_variables + +# Machine specific fishd +fishd.* diff --git a/fish/config.fish b/fish/config.fish new file mode 100755 index 0000000..0126ede --- /dev/null +++ b/fish/config.fish @@ -0,0 +1,16 @@ +#!/bin/fish + +# Disable the greeting +set fish_greeting + +## Application-specific configurations + +# opam +if test -e ~/.opam/opam-init/init.fish + source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true +end + +# direnv/envrc +if type -q direnv + direnv hook fish | source +end diff --git a/fish/fishd_color b/fish/fishd_color new file mode 100755 index 0000000..581b7da --- /dev/null +++ b/fish/fishd_color @@ -0,0 +1,33 @@ +# This file is automatically generated by the fish. +# Do NOT edit it directly, your changes will be overwritten. +SET __fish_classic_git_prompt_initialized:\x1d +SET __fish_init_2_39_8:\x1d +SET __fish_init_2_3_0:\x1d +SET fish_color_autosuggestion:b2b2b2 +SET fish_color_cancel:\x2dr +SET fish_color_command:ffaf00 +SET fish_color_comment:5C9900 +SET fish_color_cwd:green +SET fish_color_cwd_root:red +SET fish_color_end:005fff +SET fish_color_error:ff5f00 +SET fish_color_escape:bryellow\x1e\x2d\x2dbold +SET fish_color_history_current:\x2d\x2dbold +SET fish_color_host:normal +SET fish_color_match:\x2d\x2dbackground\x3dbrblue +SET fish_color_normal:normal +SET fish_color_operator:bryellow +SET fish_color_param:00afd7 +SET fish_color_quote:00d7af +SET fish_color_redirection:7CB02C +SET fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SET fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SET fish_color_status:red +SET fish_color_user:brgreen +SET fish_color_valid_path:\x2d\x2dunderline +SET fish_greeting:\x1d +SET fish_key_bindings:fish_default_key_bindings +SET fish_pager_color_completion:\x1d +SET fish_pager_color_description:B3A06D\x1eyellow +SET fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SET fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan diff --git a/fish/functions/fish_mode_prompt.fish b/fish/functions/fish_mode_prompt.fish new file mode 100755 index 0000000..c40bd2b --- /dev/null +++ b/fish/functions/fish_mode_prompt.fish @@ -0,0 +1,24 @@ +#!/bin/fish + +function fish_mode_prompt --description 'Displays the current vi mode' + # Do nothing if not in vi mode + if test "$fish_key_bindings" = "fish_vi_key_bindings" + switch $fish_bind_mode + case default + set_color --bold red + echo -n 🅽 + case insert + set_color --bold green + echo -n 🅸 + case replace_one + set_color --bold green + echo -n 🆁 + case visual + set_color --bold brblue + echo -n 🆅 + end + set_color normal + echo -n ' ' + end +end + diff --git a/fish/functions/fish_prompt.fish b/fish/functions/fish_prompt.fish new file mode 100755 index 0000000..d3d9ebb --- /dev/null +++ b/fish/functions/fish_prompt.fish @@ -0,0 +1,78 @@ +#!/bin/fish + +set PROMPTDIRS "~":$HOME + +# +# This function takes the $PROMPTDIRS variable and tries to shorten the +# input (i.e. $argv[1]) w.r.t. the variable. +# +# e.g. If $PROMPTDIRS contains the pair $PR:$HOME/Projects, +# +# (prompt_abbr ~/Projects/Applications) +# +# will show "$PR/Applications", and ~/Projects will be converted to $PR. +# +# To set multiple $PROMPTDIRS entry, use successive (where $ABBR is some +# directory to be abbreviated) +# +# set PROMPTDIRS \$ABBR:$ABBR $PROMPTDIRS +# +# with the outermost directory being set first. +# +function prompt_abbr + set in $argv[1] + + for d in $PROMPTDIRS + set -l kv (string split -m 1 ":" $d) + + switch "$in" + case "$kv[2]/*" + set in (string replace $kv[2] $kv[1] $in) + break + case "$kv[2]" + set in "$kv[1]" + break + case "*" + end + end + echo "$in" +end + +function fish_prompt +# set_color white +# echo -n '[' + + set -l FishStatusCodeCache $status + + set_color -o 00FF00 + echo -n (whoami) + + set_color normal + echo -n '@' + + set_color AFD75F + echo -n (hostname) + + set_color white + echo -n ':' + + set_color 8787FF + echo -n (prompt_abbr $PWD) + + set_color 5F87D7 + echo -n (__fish_vcs_prompt) + + if test $FishStatusCodeCache -eq 0 + #set_color 18C412 + else + set_color E84505 + echo -n " [$FishStatusCodeCache]" + end + +# set_color white +# echo -n "]" + + set_color -o white + echo -n "> " + set_color normal +end diff --git a/fish/functions/fish_right_prompt.fish b/fish/functions/fish_right_prompt.fish new file mode 100755 index 0000000..4fd2d57 --- /dev/null +++ b/fish/functions/fish_right_prompt.fish @@ -0,0 +1,8 @@ +#!/bin/fish + +function fish_right_prompt + set_color grey + printf (date '+%H:%M:%S') + set_color normal +end +