Merge pull request #103 from tripleplus/jump-plugin

Jump plugin
This commit is contained in:
Bruno 2014-01-09 21:48:08 -08:00
commit 43a7839350
6 changed files with 83 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 -gx MARKPATH $HOME/.marks
command mkdir -p $MARKPATH

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

@ -0,0 +1,22 @@
function mark
if test (count $argv) -eq 0 -o (count $argv) -gt 2
echo "Usage: mark <MARK_NAME> [DIRECTORY]"
else if test -e $MARKPATH/$argv[1]
if test -d $MARKPATH/$argv[1] -a -L $MARKPATH/$argv[1]
echo "A mark named $argv[1] already exists."
else
echo "$MARKPATH/$argv[1] already exists."
end
else 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]
set -l current_dir (pwd)
cd $argv[2]
command ln -s (pwd) $MARKPATH/$argv[1]
cd $current_dir
else
echo "$argv[2] is not a valid directory."
end
end
end

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

@ -0,0 +1,28 @@
function marks
if test (count $argv) -gt 0
echo "Usage: marks"
else
set -l file_list (command ls $MARKPATH)
if test (count $file_list) -eq 0
echo "No marks currently defined."
else
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
set -l current_dir (pwd)
for mark_name in $mark_list
cd $MARKPATH/$mark_name
set -l real_path (pwd)
echo "$mark_name -> $real_path"
end
cd $current_dir
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