2 files changed,
44 insertions(+),
32 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-03-23 17:31:17 +0200
Parent:
0c66fad
M
config/fish/config.fish
··· 6 6 set -gx RUSTUP_HOME $HOME/.local/share/rustup 7 7 8 8 set -gx NIX_PATH $HOME/.local/nix 9 -set -gx LEDGER_FILE "$HOME/org/finance/$(date +%Y).journal" 10 -set -gx LESS "--mouse" 9 +set -gx LEDGER_FILE "$HOME/org/finance/"(date +%Y)".journal" 11 10 12 -set -gx PATH $GOBIN $PATH 13 -set -gx PATH $CARGO_HOME/bin $PATH 14 -set -gx PATH $HOME/bin $PATH 15 -set -gx PATH $HOME/.local/bin $PATH 16 -set -gx PATH $HOME/.bun/bin $PATH 17 -set -gx PATH node_modules/.bin $PATH 11 +fish_add_path -g $GOBIN 12 +fish_add_path -g $CARGO_HOME/bin 13 +fish_add_path -g $HOME/bin 14 +fish_add_path -g $HOME/.local/bin 15 +fish_add_path -g $HOME/.bun/bin 16 +fish_add_path -g ~/.local/share/mise/shims 17 +fish_add_path -P node_modules/.bin 18 18 19 19 if type -q nvim 20 20 set -gx EDITOR nvim ··· 23 23 24 24 if status is-interactive 25 25 zoxide init fish | source 26 - mise activate fish | source 27 26 direnv hook fish | source 28 27 29 28 function fish_user_key_bindings
M
config/fish/functions/prompt_vcs.fish
··· 1 1 function prompt_vcs 2 - if command -sq jj; and jj root --quiet >/dev/null 2>&1 2 + set -l dir $PWD 3 + set -l repo_root "" 4 + set -l vcs_type "" 5 + set -l depth 0 6 + 7 + while test "$dir" != "/" -a $depth -lt 20 8 + if test -d "$dir/.jj" 9 + set vcs_type jj 10 + set repo_root $dir 11 + break 12 + end 13 + if test -d "$dir/.git" 14 + set vcs_type git 15 + set repo_root $dir 16 + break 17 + end 18 + set dir (path dirname $dir) 19 + set depth (math $depth + 1) 20 + end 21 + 22 + test -n "$vcs_type"; or return 23 + 24 + if test "$vcs_type" = jj; and command -sq jj 3 25 set -l head (jj log --no-graph -r "@" -T "change_id.shortest()" 2>/dev/null) 4 26 printf ' %s(jj: %s%s%s)%s' (set_color normal) (set_color blue) $head (set_color normal) (set_color normal) 5 27 return 6 28 end 7 29 8 - if not command -sq git 9 - return 30 + # git 31 + set -l git_dir "$repo_root/.git" 32 + if test -f "$git_dir" 33 + read -l gitdir_line < "$git_dir" 34 + set git_dir (string replace "gitdir: " "" -- $gitdir_line) 10 35 end 11 36 12 - set -l status_lines (command git status --porcelain=1 -b --ignore-submodules=dirty 2>/dev/null) 13 - if test $status -ne 0; or test (count $status_lines) -eq 0 14 - return 15 - end 37 + set -l head_file "$git_dir/HEAD" 38 + test -f "$head_file"; or return 16 39 17 - set -l branch_line $status_lines[1] 18 - if test -z "$branch_line" 19 - return 20 - end 40 + read -l head_content < "$head_file" 21 41 22 - set -l branch (string replace -r '^## ' '' -- $branch_line) 23 - set branch (string replace -r '\\.{3}.*$' '' -- $branch) 24 - set branch (string replace -r '^No commits yet on ' '' -- $branch) 25 - if string match -qr '^HEAD' -- $branch 26 - set branch (command git rev-parse --short HEAD 2>/dev/null; or echo "HEAD") 27 - end 28 - 29 - set -l dirty "" 30 - if test (count $status_lines) -gt 1 31 - set dirty "*" 42 + if string match -qr '^ref: refs/heads/' -- $head_content 43 + set -l branch (string replace 'ref: refs/heads/' '' -- $head_content) 44 + printf ' %s(%s%s%s)%s' (set_color normal) (set_color blue) $branch (set_color normal) (set_color normal) 45 + else 46 + printf ' %s(%s%s%s)%s' (set_color normal) (set_color blue) (string sub -l 7 -- $head_content) (set_color normal) (set_color normal) 32 47 end 33 - 34 - printf ' %s(%s%s%s%s%s)%s' (set_color normal) (set_color blue) $branch (set_color yellow) $dirty (set_color normal) (set_color normal) 35 48 end