2024-08-02 11:12:36 +02:00
|
|
|
|
|
|
|
function __jj_in_repo
|
|
|
|
jj --ignore-working-copy --quiet root >>/dev/null 2>&1
|
|
|
|
end
|
|
|
|
|
|
|
|
function vcs_root
|
|
|
|
jj workspace root --ignore-working-copy 2>/dev/null || git rev-parse --show-toplevel 2>/dev/null || pwd
|
|
|
|
end
|
|
|
|
|
|
|
|
function vcs_broot
|
|
|
|
br (vcs_root)
|
|
|
|
commandline -f repaint
|
|
|
|
end
|
|
|
|
|
|
|
|
function vcs_jump
|
|
|
|
set _dir (vcs_root)
|
|
|
|
if [ "$_dir" = "$PWD" ]
|
|
|
|
set _dir (br -f --conf "$HOME/.config/broot/conf.toml")
|
|
|
|
end
|
|
|
|
[ -n "$_dir" ] && pushd $_dir >>/dev/null
|
|
|
|
commandline -f repaint
|
|
|
|
end
|
|
|
|
|
|
|
|
function vcs_status
|
|
|
|
if __jj_in_repo
|
2024-08-07 12:22:47 +02:00
|
|
|
echo
|
2024-09-29 19:40:08 +02:00
|
|
|
printf '\e[38;5;240m\u2504%.0s\e[0m' (seq 1 (tput cols)) '\n'
|
|
|
|
jj show --stat
|
|
|
|
printf '\e[38;5;240m\u2504%.0s\e[0m' (seq 1 (tput cols)) '\n'
|
|
|
|
jj log --ignore-working-copy --limit=20 -T builtin_log_comfortable -r "(main..@) | (main..@)-"
|
2024-08-02 11:12:36 +02:00
|
|
|
else
|
|
|
|
git status -sb
|
|
|
|
end
|
|
|
|
commandline -f repaint
|
|
|
|
end
|
|
|
|
|
|
|
|
function vcs_diff
|
|
|
|
if __jj_in_repo
|
|
|
|
jj show $argv
|
|
|
|
else
|
|
|
|
git diff --stat -p -C --color-words $argv
|
|
|
|
end
|
|
|
|
commandline -f repaint
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function vcs_log
|
|
|
|
if __jj_in_repo
|
|
|
|
jj log --ignore-working-copy $argv
|
|
|
|
else
|
|
|
|
git diff --stat -p -C --color-words $argv
|
|
|
|
end
|
|
|
|
commandline -f repaint
|
|
|
|
end
|
|
|
|
|
|
|
|
# Abbreviations
|
|
|
|
|
|
|
|
abbr -a d vcs_diff
|
|
|
|
abbr -a s vcs_status
|
|
|
|
|
|
|
|
# Bindings
|
|
|
|
bind \c_ vcs_jump
|
|
|
|
bind \ea vcs_log
|
|
|
|
bind \ee vcs_broot
|
|
|
|
bind \eS vcs_diff
|
|
|
|
bind \es vcs_status
|
2025-01-13 18:40:36 +01:00
|
|
|
|
|
|
|
# jj completions
|
|
|
|
|
|
|
|
COMPLETE=fish jj | source
|