This commit is contained in:
Peder Bergebakken Sundt 2024-04-29 00:00:19 +02:00
parent e56ce07452
commit 13b258a8e3
1 changed files with 14 additions and 11 deletions

View File

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