changeset 1038:6ab26ddbf78d

feat: add fish shell
author Zeger Van de Vannet <zeger@vandevan.net>
date Fri, 26 Apr 2024 18:43:22 +0200
parents 38b8060cdf24
children ebd5e7683e1e
files .chezmoiexternal.toml .chezmoiscripts/run_onchange_after_15-install-ubuntu-packages.sh.tmpl .chezmoiscripts/run_onchange_after_22-install-devtools.sh.tmpl dot_config/private_fish/config.fish dot_config/private_fish/functions/fish_prompt.fish dot_config/private_fish/functions/fish_right_prompt.fish dot_config/private_fish/functions/fzf_hg_status_files.fish dot_config/private_fish/functions/fzf_last_command_output.fish system/ubuntu/fish
diffstat 9 files changed, 104 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/.chezmoiexternal.toml	Sun Jun 16 20:25:12 2024 +0200
+++ b/.chezmoiexternal.toml	Fri Apr 26 18:43:22 2024 +0200
@@ -70,6 +70,14 @@
   type = "file"
   url = "https://git.zx2c4.com/password-store/plain/src/completion/pass.zsh-completion"
 
+[".config/fish/completions/chezmoi.fish"]
+  type = "file"
+  url = "https://raw.githubusercontent.com/twpayne/chezmoi/v2.47.4/completions/chezmoi.fish"
+
+[".config/fish/completions/hx.fish"]
+  type = "file"
+  url = "https://raw.githubusercontent.com/helix-editor/helix/23.03/contrib/completion/hx.fish"
+
 [".config/helix/runtime/queries/tcl/highlights.scm"]
   type = "file"
   url = "https://github.com/lewis6991/tree-sitter-tcl/raw/ac8b94b7a89825ddbdd6f8fc0a81c67c065be851/queries/tcl/highlights.scm"
--- a/.chezmoiscripts/run_onchange_after_15-install-ubuntu-packages.sh.tmpl	Sun Jun 16 20:25:12 2024 +0200
+++ b/.chezmoiscripts/run_onchange_after_15-install-ubuntu-packages.sh.tmpl	Fri Apr 26 18:43:22 2024 +0200
@@ -29,11 +29,13 @@
 
 {{ $ppa := list
 	"ppa:maveonair/helix-editor"
-	"ppa:mozillateam/ppa" -}}
+	"ppa:mozillateam/ppa" 
+	"ppa:fish-shell/release-3" -}}
 
 {{ $extra_packages := list
 	"helix"
-	"firefox" -}}
+	"firefox" 
+	"fish" -}}
 #!/usr/bin/env bash
 
 set -xe
--- a/.chezmoiscripts/run_onchange_after_22-install-devtools.sh.tmpl	Sun Jun 16 20:25:12 2024 +0200
+++ b/.chezmoiscripts/run_onchange_after_22-install-devtools.sh.tmpl	Fri Apr 26 18:43:22 2024 +0200
@@ -30,4 +30,8 @@
 popd
 rm -rf $DOWNLOAD_DIR
 
+FISH_COMPLETIONS=$HOME/.config/fish/completions
+$INSTALL_DIR/rg --generate=complete-fish > $FISH_COMPLETIONS/rg.fish
+$INSTALL_DIR/fd --gen-completions fish > $FISH_COMPLETIONS/fd.fish
+
 {{ end }}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dot_config/private_fish/config.fish	Fri Apr 26 18:43:22 2024 +0200
@@ -0,0 +1,26 @@
+set -x EDITOR hx
+set -x HGEDITOR hx
+
+set -x RIPGREP_CONFIG_PATH $HOME/.config/ripgrep/ripgreprc
+set -x BAT_CONFIG_PATH $HOME/.config/bat/config
+
+set -x PS_FORMAT 'pid,pgid,state,start_time,%cpu,command'
+
+set -x PATH $HOME/.local/bin $HOME/bin $PATH
+
+if test -e "$HOME/bin/mise"
+    $HOME/bin/mise activate fish | source
+end
+
+direnv hook fish | source
+
+if status is-interactive
+    # Commands to run in interactive sessions can go here
+
+    # Select modified paths via fzf on alt+g
+    bind \eg fzf_hg_status_files
+    # Select output lines from last command
+    bind \er fzf_last_command_output
+
+    abbr hgst hg status
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dot_config/private_fish/functions/fish_prompt.fish	Fri Apr 26 18:43:22 2024 +0200
@@ -0,0 +1,24 @@
+set fish_prompt_pwd_dir_length 2
+set -g fish_prompt_pwd_full_dirs 5
+function fish_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
+
+    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 (set_color cyan)(date +%H:%M:%S) (set_color red)(prompt_hostname) (set_color blue)(prompt_pwd)(set_color normal)
+
+    set -l active_jobs (jobs | wc -l)
+    echo "$active_jobs$prompt_status -> "
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dot_config/private_fish/functions/fish_right_prompt.fish	Fri Apr 26 18:43:22 2024 +0200
@@ -0,0 +1,18 @@
+function fish_right_prompt
+    if not command -sq hg
+        return 1
+    end
+
+    set -l root (fish_print_hg_root)
+    or return 1
+
+    # In stead of running this command, cat the branch and topic name from the .hg folder
+    # echo (set_color yellow)(HGPLAIN= HGRCPATH= hg --config extensions.topic= log -r 'wdir()' --template='{fqbn}' 2>/dev/null) (set_color normal)
+    set -l branch (cat $root/branch 2>/dev/null; or echo default)
+    if set -l topic (cat $root/topic 2>/dev/null)
+        set branch "$branch//$topic"
+    end
+    # TODO: add topic namespace when available
+
+    echo (set_color green)"$branch "(set_color normal)
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dot_config/private_fish/functions/fzf_hg_status_files.fish	Fri Apr 26 18:43:22 2024 +0200
@@ -0,0 +1,7 @@
+function fzf_hg_status_files
+    set result (HGRCPATH= rhg status -n --color=always --config commands.status.relative=yes| fzf --ansi -m --header "Select the file(s) to insert in the command line")
+    if test -n "$result"
+        commandline -i (string join " " -- $result "") # adds a space after the inserted line output
+    end
+    commandline -f repaint
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dot_config/private_fish/functions/fzf_last_command_output.fish	Fri Apr 26 18:43:22 2024 +0200
@@ -0,0 +1,10 @@
+function fzf_last_command_output
+    set cmd (history | fzf --header "Choose the command to rerun.")
+    if test -n "$cmd"
+        set result (eval $cmd | fzf -m --header "Choose the line(s) from the repeated command\'s output to paste into the current command-line. (The order matters!)")
+        if test -n "$result"
+            commandline -i (string join " " -- $result "") # adds a space after the inserted line output
+        end
+    end
+    commandline -f repaint
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/system/ubuntu/fish	Fri Apr 26 18:43:22 2024 +0200
@@ -0,0 +1,3 @@
+Package: *
+Pin: release o=LP-PPA-fish-shell
+Pin-Priority: 1001