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/functions | |
| 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/functions')
| -rw-r--r-- | config/fish/functions/upto.fish | 29 |
1 files changed, 29 insertions, 0 deletions
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 |
