Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One update, lots of comments #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.*.swp
23 changes: 22 additions & 1 deletion functions/to.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function __to_usage
echo ' Default BOOKMARK: name of current directory'
echo ' Default DEST: path to current directory'
echo ' to add DEST Create a bookmark for DEST if it is a directory'
echo ' to here Shows bookmark for current directory'
echo ' to ls List all bookmarks'
echo ' to mv OLD NEW Change the name of a bookmark from OLD to NEW'
echo ' to rm BOOKMARK Remove BOOKMARK'
Expand Down Expand Up @@ -68,6 +69,21 @@ function __to_ls
end
end

function __to_here
set -x currentdir (pwd)
set -x wholepath (ls -l $TO_DIR | grep $currentdir | cut -d':' -f 2 | cut -d' ' -f 2,4 )
for line in $wholepath
set -x inner (echo $line | cut -d' ' -f 2)
if [ $inner = $currentdir ]
set -x result (echo $line | cut -d' ' -f 1)
echo $currentdir '->' $result
end
end
if not test $result
echo 'there is no to-fish link for this directory'
end
end

function __to_rm
command rm -v (__to_bm_path $argv[1]); or return $status
__to_update_bookmark_completions
Expand Down Expand Up @@ -184,7 +200,7 @@ function to -d 'Bookmarking tool'
set -l numargs (count $argv)
switch $cmd
# subcommands that don't take an argument
case ls help clean
case ls help clean here
if not test $numargs -eq 1
echo "Usage: to $cmd"
return 1
Expand Down Expand Up @@ -219,6 +235,11 @@ function to -d 'Bookmarking tool'
__to_add $argv[2..-1]
return $status

# Show bookmark for current dir
case here
__to_here
return $status

# Remove a bookmark
case rm
__to_rm $argv[2]
Expand Down