From 1b0f26329b8be590379d8627b3d686bfe86b16ef Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Fri, 23 Feb 2024 12:57:28 -0600 Subject: [PATCH] added fish configurations --- fish/.config/fish/config.fish | 15 ++ fish/.config/fish/fish_variables | 39 +++++ fish/.config/fish/functions/doc2pdf.fish | 3 + fish/.config/fish/functions/fish_prompt.fish | 139 ++++++++++++++++++ .../functions/fish_user_key_bindings.fish | 4 + .../fish/functions/fzf_key_bindings.fish | 1 + fish/.config/fish/functions/grep.fish | 4 + fish/.config/fish/functions/la.fish | 3 + fish/.config/fish/functions/ll.fish | 3 + fish/.config/fish/functions/pyactivate.fish | 3 + fish/.config/fish/functions/say.fish | 3 + fish/.config/fish/functions/slideshow.fish | 3 + fish/.config/fish/functions/sshmnt.fish | 3 + fish/.config/fish/functions/tmux.fish | 3 + fish/.config/fish/functions/tre.fish | 3 + fish/.config/fish/functions/vim.fish | 3 + fish/.config/fish/functions/vimdiff.fish | 3 + 17 files changed, 235 insertions(+) create mode 100644 fish/.config/fish/config.fish create mode 100644 fish/.config/fish/fish_variables create mode 100644 fish/.config/fish/functions/doc2pdf.fish create mode 100644 fish/.config/fish/functions/fish_prompt.fish create mode 100644 fish/.config/fish/functions/fish_user_key_bindings.fish create mode 120000 fish/.config/fish/functions/fzf_key_bindings.fish create mode 100644 fish/.config/fish/functions/grep.fish create mode 100644 fish/.config/fish/functions/la.fish create mode 100644 fish/.config/fish/functions/ll.fish create mode 100644 fish/.config/fish/functions/pyactivate.fish create mode 100644 fish/.config/fish/functions/say.fish create mode 100644 fish/.config/fish/functions/slideshow.fish create mode 100644 fish/.config/fish/functions/sshmnt.fish create mode 100644 fish/.config/fish/functions/tmux.fish create mode 100644 fish/.config/fish/functions/tre.fish create mode 100644 fish/.config/fish/functions/vim.fish create mode 100644 fish/.config/fish/functions/vimdiff.fish diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish new file mode 100644 index 0000000..ad262d7 --- /dev/null +++ b/fish/.config/fish/config.fish @@ -0,0 +1,15 @@ +if status is-interactive + #because fish_add_path realpaths the input, anything relative to home must + #be done globably instead of universallly. + fish_add_path -g ~/.local/bin/ + fish_add_path -g ~/.cargo/bin/ + if type -q pyenv + set -gx PYENV_ROOT $HOME/.pyenv + fish_add_path -g $PYENV_ROOT/bin + pyenv init - | source + end + type -q zoxide; and zoxide init fish | source + type -q starship; and starship init fish | source + #ssh-agent systemd service + set -gx SSH_AUTH_SOCK "$XDG_RUNTIME_DIR/ssh-agent.socket" +end diff --git a/fish/.config/fish/fish_variables b/fish/.config/fish/fish_variables new file mode 100644 index 0000000..2679d26 --- /dev/null +++ b/fish/.config/fish/fish_variables @@ -0,0 +1,39 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR --export EDITOR:nvim +SETUVAR --export PAGER:less +SETUVAR --export PIPENV_VENV_IN_PROJECT:1 +SETUVAR --export POETRY_VIRTUALENVS_IN_PROJECT:1 +SETUVAR --export TIMEFMT:\x25J\x20\x20\x25\x2aU\x20user\x20\x25\x2aS\x20system\x20\x25P\x20cpu\x20\x25\x2aE\x20total +SETUVAR --export VISUAL:nvim +SETUVAR --export WWW_HOME:duckduckgo\x2ecom/lite/ +SETUVAR __fish_initialized:3400 +SETUVAR fish_color_autosuggestion:brblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:blue +SETUVAR fish_color_comment:red +SETUVAR fish_color_cwd:green +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:normal +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:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_key_bindings:fish_vi_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 +SETUVAR fish_user_paths:/home/gabe/\x2efzf/bin diff --git a/fish/.config/fish/functions/doc2pdf.fish b/fish/.config/fish/functions/doc2pdf.fish new file mode 100644 index 0000000..8bf9b16 --- /dev/null +++ b/fish/.config/fish/functions/doc2pdf.fish @@ -0,0 +1,3 @@ +function doc2pdf --wraps='loffice --convert-to pdf --headless *.docx' --description 'alias doc2pdf loffice --convert-to pdf --headless *.docx' + loffice --convert-to pdf --headless *.docx $argv +end diff --git a/fish/.config/fish/functions/fish_prompt.fish b/fish/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..b7d38e6 --- /dev/null +++ b/fish/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,139 @@ +function fish_prompt + # This prompt shows: + # - green lines if the last return command is OK, red otherwise + # - your user name, in red if root or yellow otherwise + # - your hostname, in cyan if ssh or blue otherwise + # - the current path (with prompt_pwd) + # - date +%X + # - the current virtual environment, if any + # - the current git status, if any, with fish_git_prompt + # - the current battery state, if any, and if your power cable is unplugged, and if you have "acpi" + # - current background jobs, if any + + # It goes from: + # ┬─[nim@Hattori:~]─[11:39:00] + # ╰─>$ echo here + + # To: + # ┬─[nim@Hattori:~/w/dashboard]─[11:37:14]─[V:django20]─[G:master↑1|●1✚1…1]─[B:85%, 05:41:42 remaining] + # │ 2 15054 0% arrêtée sleep 100000 + # │ 1 15048 0% arrêtée sleep 100000 + # ╰─>$ echo there + + set -l retc red + test $status = 0; and set retc green + + set -q __fish_git_prompt_showupstream + or set -g __fish_git_prompt_showupstream auto + + function _nim_prompt_wrapper + set retc $argv[1] + set -l field_name $argv[2] + set -l field_value $argv[3] + + set_color normal + set_color $retc + echo -n '─' + set_color -o green + echo -n '[' + set_color normal + test -n $field_name + and echo -n $field_name: + set_color $retc + echo -n $field_value + set_color -o green + echo -n ']' + end + + set_color $retc + echo -n '┬─' + set_color -o green + echo -n [ + + if functions -q fish_is_root_user; and fish_is_root_user + set_color -o red + else + set_color -o yellow + end + + echo -n $USER + set_color -o white + echo -n @ + + if test -z "$SSH_CLIENT" + set_color -o blue + else + set_color -o cyan + end + + echo -n (prompt_hostname) + set_color -o white + echo -n :(prompt_pwd) + set_color -o green + echo -n ']' + + # Date + _nim_prompt_wrapper $retc '' (date +%X) + + # Vi-mode + # The default mode prompt would be prefixed, which ruins our alignment. + function fish_mode_prompt + end + + if test "$fish_key_bindings" = fish_vi_key_bindings + or test "$fish_key_bindings" = fish_hybrid_key_bindings + set -l mode + switch $fish_bind_mode + case default + set mode (set_color --bold red)N + case insert + set mode (set_color --bold green)I + case replace_one + set mode (set_color --bold green)R + echo '[R]' + case replace + set mode (set_color --bold cyan)R + case visual + set mode (set_color --bold magenta)V + end + set mode $mode(set_color normal) + _nim_prompt_wrapper $retc '' $mode + end + + + # Virtual Environment + set -q VIRTUAL_ENV_DISABLE_PROMPT + or set -g VIRTUAL_ENV_DISABLE_PROMPT true + set -q VIRTUAL_ENV + and _nim_prompt_wrapper $retc V (basename "$VIRTUAL_ENV") + + # git + set -l prompt_git (fish_git_prompt '%s') + test -n "$prompt_git" + and _nim_prompt_wrapper $retc G $prompt_git + + # Battery status + type -q acpi + and test (acpi -a 2> /dev/null | string match -r off) + and _nim_prompt_wrapper $retc B (acpi -b | cut -d' ' -f 4-) + + # New line + echo + + # Background jobs + set_color normal + + for job in (jobs) + set_color $retc + echo -n '│ ' + set_color brown + echo $job + end + + set_color normal + set_color $retc + echo -n '╰─>' + set_color -o red + echo -n '$ ' + set_color normal +end diff --git a/fish/.config/fish/functions/fish_user_key_bindings.fish b/fish/.config/fish/functions/fish_user_key_bindings.fish new file mode 100644 index 0000000..c53e599 --- /dev/null +++ b/fish/.config/fish/functions/fish_user_key_bindings.fish @@ -0,0 +1,4 @@ +function fish_user_key_bindings +end + +fzf_key_bindings diff --git a/fish/.config/fish/functions/fzf_key_bindings.fish b/fish/.config/fish/functions/fzf_key_bindings.fish new file mode 120000 index 0000000..29b449d --- /dev/null +++ b/fish/.config/fish/functions/fzf_key_bindings.fish @@ -0,0 +1 @@ +/home/gabe/.fzf/shell/key-bindings.fish \ No newline at end of file diff --git a/fish/.config/fish/functions/grep.fish b/fish/.config/fish/functions/grep.fish new file mode 100644 index 0000000..ed9412d --- /dev/null +++ b/fish/.config/fish/functions/grep.fish @@ -0,0 +1,4 @@ +function grep --description 'alias grep grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} --exclude={.bzr,CVS,.git,.hg,.svn}' + command grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} --exclude={.bzr,CVS,.git,.hg,.svn} $argv + +end diff --git a/fish/.config/fish/functions/la.fish b/fish/.config/fish/functions/la.fish new file mode 100644 index 0000000..76becaa --- /dev/null +++ b/fish/.config/fish/functions/la.fish @@ -0,0 +1,3 @@ +function la --wraps='ls -a' --description 'alias la ls -a' + ls -lha $argv +end diff --git a/fish/.config/fish/functions/ll.fish b/fish/.config/fish/functions/ll.fish new file mode 100644 index 0000000..6cefac8 --- /dev/null +++ b/fish/.config/fish/functions/ll.fish @@ -0,0 +1,3 @@ +function ll --wraps='ls -lh' --description 'alias ll ls -lh' + ls -lh $argv +end diff --git a/fish/.config/fish/functions/pyactivate.fish b/fish/.config/fish/functions/pyactivate.fish new file mode 100644 index 0000000..5130e9a --- /dev/null +++ b/fish/.config/fish/functions/pyactivate.fish @@ -0,0 +1,3 @@ +function pyactivate --wraps='source ./.venv/bin/activate.fish' --description 'alias pyactivate source ./.venv/bin/activate.fish' + source ./.venv/bin/activate.fish $argv +end diff --git a/fish/.config/fish/functions/say.fish b/fish/.config/fish/functions/say.fish new file mode 100644 index 0000000..c4ad595 --- /dev/null +++ b/fish/.config/fish/functions/say.fish @@ -0,0 +1,3 @@ +function say --wraps='espeak -p 10 -s 150 -a 200 2> /dev/null' --description 'alias say espeak -p 10 -s 150 -a 200 2> /dev/null' + espeak -p 10 -s 150 -a 200 2> /dev/null $argv +end diff --git a/fish/.config/fish/functions/slideshow.fish b/fish/.config/fish/functions/slideshow.fish new file mode 100644 index 0000000..519b249 --- /dev/null +++ b/fish/.config/fish/functions/slideshow.fish @@ -0,0 +1,3 @@ +function slideshow --wraps='feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay' --description 'alias slideshow feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay' + feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay $argv +end diff --git a/fish/.config/fish/functions/sshmnt.fish b/fish/.config/fish/functions/sshmnt.fish new file mode 100644 index 0000000..9bff679 --- /dev/null +++ b/fish/.config/fish/functions/sshmnt.fish @@ -0,0 +1,3 @@ +function sshmnt --wraps='sshfs -o idmap=user,compression=no,reconnect,follow_symlinks,dir_cache=yes,ServerAliveInterval=15' --description 'alias sshmnt sshfs -o idmap=user,compression=no,reconnect,follow_symlinks,dir_cache=yes,ServerAliveInterval=15' + sshfs -o idmap=user,compression=no,reconnect,follow_symlinks,dir_cache=yes,ServerAliveInterval=15 $argv +end diff --git a/fish/.config/fish/functions/tmux.fish b/fish/.config/fish/functions/tmux.fish new file mode 100644 index 0000000..c4270d7 --- /dev/null +++ b/fish/.config/fish/functions/tmux.fish @@ -0,0 +1,3 @@ +function tmux --description 'alias tmux tmux -u' + command tmux -u $argv +end diff --git a/fish/.config/fish/functions/tre.fish b/fish/.config/fish/functions/tre.fish new file mode 100644 index 0000000..97010fa --- /dev/null +++ b/fish/.config/fish/functions/tre.fish @@ -0,0 +1,3 @@ +function tre + command tre $argv -e; and source /tmp/tre_aliases_$USER ^/dev/null +end diff --git a/fish/.config/fish/functions/vim.fish b/fish/.config/fish/functions/vim.fish new file mode 100644 index 0000000..bb30961 --- /dev/null +++ b/fish/.config/fish/functions/vim.fish @@ -0,0 +1,3 @@ +function vim --wraps=nvim --description 'alias vim nvim' + nvim $argv +end diff --git a/fish/.config/fish/functions/vimdiff.fish b/fish/.config/fish/functions/vimdiff.fish new file mode 100644 index 0000000..4c55f0c --- /dev/null +++ b/fish/.config/fish/functions/vimdiff.fish @@ -0,0 +1,3 @@ +function vimdiff --wraps='nvim -d' --description 'alias vimdiff nvim -d' + nvim -d $argv +end