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
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 ' -> '
}