diff --git a/users/pbsds/home/modules/jump.nix b/users/pbsds/home/modules/jump.nix index e48dd3b..2d91f0f 100644 --- a/users/pbsds/home/modules/jump.nix +++ b/users/pbsds/home/modules/jump.nix @@ -35,26 +35,29 @@ in { programs = let rcScript = '' - 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 + function _mark_choose() { + ${lib.getExe pkgs.fd} . "$_JUMP_MARKPATH" --type l -X ${lib.getExe pkgs.gum} choose --ordered {/} + } + function jump() { + local target="''${1:-$(_mark_choose)}" + if test -n "$target"; then pushd . > /dev/null - cd -P "$_JUMP_MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" + cd -P "$_JUMP_MARKPATH/$target" 2>/dev/null || echo "No such mark: $target" fi } - function mark { + function mark() { mkdir -p "$_JUMP_MARKPATH" && test ! -L "$_JUMP_MARKPATH/$1" \ && ln -s "$(pwd)" "$_JUMP_MARKPATH/$1" \ || echo "mark already exists!" } - function unmark { - test ! -z "$1" \ - && rm -i "$_JUMP_MARKPATH/$1" + function unmark() { + local target="''${1:-$(_mark_choose)}" + if test -n "$target"; then + rm -i "$_JUMP_MARKPATH/$target" + fi } - function marks { + function marks() { #ls -l "$_JUMP_MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo command ls --color=always -l "$_JUMP_MARKPATH" | tr -s ' ' | cut -d' ' -f9- | sed -e 's/ -> /§/g' | column -t -s '§' -o ' -> ' }