Skip to content

Commit

Permalink
fix: clean command
Browse files Browse the repository at this point in the history
It was removing all bookmarks =(

Closes #11
  • Loading branch information
joehillen committed Apr 25, 2023
1 parent e0c5822 commit a84843a
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions functions/to.fish
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,20 @@ end

function __to_resolve
readlink (__to_bm_path $argv)
return $status
end

function __to_print
__to_resolve $argv | string replace -r "^$HOME" "~" | string replace -r '^~$' "$HOME"
__to_resolve $argv | string replace -r "^$HOME" "~" | string replace -r '^~$' $HOME
end

function __to_ls
set -l dir (__to_dir)
if test -d "$dir"
for bm in $dir/.* $dir/*
basename $bm
end
for l in (__to_dir)/*
basename $l
end
end

function __to_rm
rm (__to_bm_path $argv[1]); or return $status
command rm -v (__to_bm_path $argv[1]); or return $status
__to_update_bookmark_completions
end

Expand Down Expand Up @@ -193,16 +189,15 @@ function to -d 'Bookmarking tool'
return 1
end

mv -n (__to_bm_path $old) (__to_bm_path $new); or return $status
command mv -n (__to_bm_path $old) (__to_bm_path $new); or return $status
__to_update_bookmark_completions
return 0

# Clean
case clean
for bm in (__to_ls)
set -l dest (__to_expand $bm)
if not test -d "$dest"
rm -v (__to_bm_path $bm)
if not test -d (__to_resolve $bm)
__to_rm $bm
end
end
return 0
Expand All @@ -226,7 +221,7 @@ function to -d 'Bookmarking tool'
end

set -l dest (__to_resolve $name)
if test -z $dest
if test -z "$dest"
if test -d "$name"
echo "cd \"$name\"" | source -
else
Expand Down

0 comments on commit a84843a

Please sign in to comment.