Added jump plugin

This commit is contained in:
Charles Thorley 2013-12-10 17:55:51 -08:00
parent 14788bcd4b
commit 3b56be3e26
6 changed files with 68 additions and 0 deletions

7
plugins/jump/README.md Normal file
View File

@ -0,0 +1,7 @@
jump
====
A port of [Jeroen Janssens' "jump" utility] [1] to the fish shell (and [Oh My Fish!] [2]).
[1]: http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
[2]: https://github.com/bpinto/oh-my-fish

11
plugins/jump/jump.fish Normal file
View File

@ -0,0 +1,11 @@
function jump
if test (count $argv) -ne 1
echo "Usage: jump <MARK_NAME>"
else
if test -d $MARKPATH/$argv[1] -a -L $MARKPATH/$argv[1]
cd $MARKPATH/$argv[1]
else
echo "No such mark: $argv[1]"
end
end
end

2
plugins/jump/jump.load Normal file
View File

@ -0,0 +1,2 @@
set -x MARKPATH $HOME/.marks
command mkdir -p $MARKPATH

15
plugins/jump/mark.fish Normal file
View File

@ -0,0 +1,15 @@
function mark
if test (count $argv) -eq 1
command ln -s (pwd) $MARKPATH/$argv[1]
else if test (count $argv) -eq 2
if test -d $argv[2]
cd $argv[2]
command ln -s (pwd) $MARKPATH/$argv[1]
cd -
else
echo "$argv[2] is not a valid directory."
end
else
echo "Usage: mark <MARK_NAME> [DIRECTORY]"
end
end

20
plugins/jump/marks.fish Normal file
View File

@ -0,0 +1,20 @@
function marks
if test (count $argv) -gt 0
echo "Usage: marks"
else
set -l file_list (command ls $MARKPATH/)
set -l mark_list
for file in $file_list
if test -d $MARKPATH/$file -a -L $MARKPATH/$file
set mark_list $mark_list $file
end
end
if test (count $mark_list) -eq 0
echo "No marks currently defined."
else
for mark_name in $mark_list
echo "$mark_name -> "(realpath $MARKPATH/$mark_name)
end
end
end
end

13
plugins/jump/unmark.fish Normal file
View File

@ -0,0 +1,13 @@
function unmark
if test (count $argv) -eq 0
echo "Usage: unmark <MARK_NAME>..."
else
for mark_name in $argv
if test -d $MARKPATH/$mark_name -a -L $MARKPATH/$mark_name
command rm -i $MARKPATH/$mark_name
else
echo "No such mark: $mark_name"
end
end
end
end