jump: use gum

This commit is contained in:
Peder Bergebakken Sundt 2024-02-01 00:58:20 +01:00
parent 4336b974a4
commit 75d95fe20e
1 changed files with 14 additions and 9 deletions

View File

@ -36,8 +36,13 @@ in {
programs = let programs = let
rcScript = '' rcScript = ''
function jump { function jump {
if test -z "$1"; then
test -n "$_JUMP_RECURSE" && return 1
_JUMP_RECURSE=1 jump "$(${lib.getExe pkgs.fd} . "$_JUMP_MARKPATH" --type l -X ${lib.getExe pkgs.gum} choose --ordered {/})"
else
pushd . > /dev/null pushd . > /dev/null
cd -P "$_JUMP_MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" cd -P "$_JUMP_MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
fi
} }
function mark { function mark {
mkdir -p "$_JUMP_MARKPATH" && mkdir -p "$_JUMP_MARKPATH" &&
@ -55,7 +60,7 @@ in {
} }
_complete_jump_marks() { _complete_jump_marks() {
local curw=''${COMP_WORDS[COMP_CWORD]} local curw=''${COMP_WORDS[COMP_CWORD]}
local wordlist=$(find $_JUMP_MARKPATH -type l -printf "%f\n") local wordlist=$(find "$_JUMP_MARKPATH" -type l -printf "%f\n")
COMPREPLY=($(compgen -W ''\'''${wordlist[@]}' -- "$curw")) COMPREPLY=($(compgen -W ''\'''${wordlist[@]}' -- "$curw"))
return 0 return 0
} }