diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2016-05-10 11:46:33 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2016-05-10 11:46:33 +0200 |
| commit | d646856e07d77ae8c1c67dd8901db58b89f2f9c6 (patch) | |
| tree | 605531309260025239416d929e4128c555d167c9 /config/fish | |
| parent | 0e1320d9f89b7171175b80310d59c12d2f91c418 (diff) | |
| download | dotfiles-d646856e07d77ae8c1c67dd8901db58b89f2f9c6.tar.gz dotfiles-d646856e07d77ae8c1c67dd8901db58b89f2f9c6.zip | |
add upto function and completion
also fix complete path in config.fish
Diffstat (limited to 'config/fish')
| -rw-r--r-- | config/fish/completions/upto.fish | 1 | ||||
| -rw-r--r-- | config/fish/config.fish | 2 | ||||
| -rw-r--r-- | config/fish/functions/upto.fish | 29 |
3 files changed, 31 insertions, 1 deletions
diff --git a/config/fish/completions/upto.fish b/config/fish/completions/upto.fish new file mode 100644 index 0000000..96ba3b2 --- /dev/null +++ b/config/fish/completions/upto.fish @@ -0,0 +1 @@ +complete -c upto -x -a "(string split '/' $PWD)" diff --git a/config/fish/config.fish b/config/fish/config.fish index 736f8bd..37ee23a 100644 --- a/config/fish/config.fish +++ b/config/fish/config.fish @@ -1,6 +1,6 @@ # autoload functions and completions in .dotfiles set fish_function_path $HOME/.dotfiles/config/fish/functions $fish_function_path -set fish_completion_path $HOME/.dotfiles/config/fish/completions $fish_completion_path +set fish_complete_path $HOME/.dotfiles/config/fish/completions $fish_complete_path # add git-alias subdirectory to functions path diff --git a/config/fish/functions/upto.fish b/config/fish/functions/upto.fish new file mode 100644 index 0000000..9c3bc25 --- /dev/null +++ b/config/fish/functions/upto.fish @@ -0,0 +1,29 @@ +function upto --description 'go up in directory tree' --argument expr + if test -z $expr + echo "A directory expression must be provided." >&2 + return 1 + end + if test $expr = "/" + cd / + return 0 + end + set current_dir $PWD + set matched_dir "" + set matching true + + while test $matching = "true" + if string match -q "*$expr*" $current_dir + set matched_dir $current_dir + set current_dir (dirname $current_dir) + else + set matching false + end + end + if test -n $matched_dir + cd $matched_dir + return 0 + else + echo "No match." >&2 + return 1 + end +end |
