-
-
Notifications
You must be signed in to change notification settings - Fork 25.7k
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
Fix: Plugin knife: Add relative local path for commands which upload files #4240
Conversation
for (( n=${#slashes}; n>0; --n )) | ||
do | ||
test -e "$directory/.chef" && echo "$directory" && return | ||
directory="$directory/.." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use ${directory:h}
to get the parent folder. Then you only need to check if $directory = /
in your loop condition, and you don't need the slashes and the for
.
Updated to use directory:h |
Better 👍 I haven't tested the rest, it would be nice to have some more people test this. |
Will this be merged? Very useful! |
Works fine for me, would be great to be merged! |
Merged. It would be better if those documenting comments where put in a README file. |
Thanks folks, and nice work @kierandoonan :-D |
* 'master' of https://github.com/robbyrussell/oh-my-zsh: (69 commits) Fix: Plugin knife: Add relative local path for commands which upload files (ohmyzsh#4240) Add list-timers to systemd user commands (ohmyzsh#5099) Adds ReactNative plugin 📱 (ohmyzsh#5018) Fix arcanist aliases (ohmyzsh#5110) add plugin react-native (ohmyzsh#4606) installer: fix ordering of cygwin msys git check (ohmyzsh#4557) Use default branch on recently created Mercurial repository. (ohmyzsh#4985) Add zsh completion plugin for rustc (ohmyzsh#3159) Changd `alias gsta='git stash'` to `alias gsta='git stash save'`. added assembly alias (ohmyzsh#5107) Fix styling in cakephp3 completion Better cake3 completion Change vim command to $EDITOR for consistency (ohmyzsh#5063) fixed bower completion error from issue ohmyzsh#2694 (ohmyzsh#5056) vagrant snapshot (ohmyzsh#5032) Arcanist plugin (ohmyzsh#5106) completion: zsh: improve main function selection gitfast: fix the prompt colour gitfast: update to upstream v2.8 Add alias for oneline git tree with --all option ...
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
* upstream/master: Mod: use new debug namespace to avoid deprecation warning (ohmyzsh#4799) Fix: Plugin knife: Add relative local path for commands which upload files (ohmyzsh#4240) Add list-timers to systemd user commands (ohmyzsh#5099) Adds ReactNative plugin 📱 (ohmyzsh#5018) Fix arcanist aliases (ohmyzsh#5110) add plugin react-native (ohmyzsh#4606) installer: fix ordering of cygwin msys git check (ohmyzsh#4557) Use default branch on recently created Mercurial repository. (ohmyzsh#4985) Support bundler
…to robbyrussell-master * 'master' of https://github.com/robbyrussell/oh-my-zsh: (454 commits) znt: update to v2.2.1 (ohmyzsh#5174) emacs plugin tweak to open buffer from stdin (ohmyzsh#5126) Update taskwarrior completion to 2.5.1 (ohmyzsh#5171) Remove undesirable hardcoding of PATH into zshrc (ohmyzsh#4925) Add README for OSX plugin and refactor plugin file Open finder to PWD - part 2 (ohmyzsh#5165) Add ofd() to OSX plugin to open finder on current directory (ohmyzsh#5164) add 'mvn clean install -DskipTests --offline' alias to speed up maven compile (ohmyzsh#5153) Peepcode theme: Don't try to use RVM if it's not available (ohmyzsh#5154) Replace _kitchen completion with the version from zsh-users (ohmyzsh#5011) Mod: use new debug namespace to avoid deprecation warning (ohmyzsh#4799) Fix: Plugin knife: Add relative local path for commands which upload files (ohmyzsh#4240) Add list-timers to systemd user commands (ohmyzsh#5099) Adds ReactNative plugin 📱 (ohmyzsh#5018) Fix arcanist aliases (ohmyzsh#5110) add plugin react-native (ohmyzsh#4606) installer: fix ordering of cygwin msys git check (ohmyzsh#4557) Use default branch on recently created Mercurial repository. (ohmyzsh#4985) Add zsh completion plugin for rustc (ohmyzsh#3159) Changd `alias gsta='git stash'` to `alias gsta='git stash save'`. ...
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
* 'master' of https://github.com/robbyrussell/oh-my-zsh: bundler plugin: Simplify retrieval of cpu count on OSX (ohmyzsh#5180) Fix gfg function completion definition Fix man-preview completion definition Fix issue with `dash` as the default `/bin/sh` script executing program. (ohmyzsh#5177) znt: update to v2.2.1 (ohmyzsh#5174) emacs plugin tweak to open buffer from stdin (ohmyzsh#5126) Update taskwarrior completion to 2.5.1 (ohmyzsh#5171) Remove undesirable hardcoding of PATH into zshrc (ohmyzsh#4925) Add README for OSX plugin and refactor plugin file Open finder to PWD - part 2 (ohmyzsh#5165) Add ofd() to OSX plugin to open finder on current directory (ohmyzsh#5164) add 'mvn clean install -DskipTests --offline' alias to speed up maven compile (ohmyzsh#5153) Peepcode theme: Don't try to use RVM if it's not available (ohmyzsh#5154) Replace _kitchen completion with the version from zsh-users (ohmyzsh#5011) Mod: use new debug namespace to avoid deprecation warning (ohmyzsh#4799) Fix: Plugin knife: Add relative local path for commands which upload files (ohmyzsh#4240)
* source/master: (61 commits) bundler plugin: Simplify retrieval of cpu count on OSX (ohmyzsh#5180) Fix gfg function completion definition Fix man-preview completion definition Fix issue with `dash` as the default `/bin/sh` script executing program. (ohmyzsh#5177) znt: update to v2.2.1 (ohmyzsh#5174) emacs plugin tweak to open buffer from stdin (ohmyzsh#5126) Update taskwarrior completion to 2.5.1 (ohmyzsh#5171) Remove undesirable hardcoding of PATH into zshrc (ohmyzsh#4925) Add README for OSX plugin and refactor plugin file Open finder to PWD - part 2 (ohmyzsh#5165) Add ofd() to OSX plugin to open finder on current directory (ohmyzsh#5164) add 'mvn clean install -DskipTests --offline' alias to speed up maven compile (ohmyzsh#5153) Peepcode theme: Don't try to use RVM if it's not available (ohmyzsh#5154) Replace _kitchen completion with the version from zsh-users (ohmyzsh#5011) Mod: use new debug namespace to avoid deprecation warning (ohmyzsh#4799) Fix: Plugin knife: Add relative local path for commands which upload files (ohmyzsh#4240) Add list-timers to systemd user commands (ohmyzsh#5099) Adds ReactNative plugin 📱 (ohmyzsh#5018) Fix arcanist aliases (ohmyzsh#5110) add plugin react-native (ohmyzsh#4606) ...
* 'master' of https://github.com/robbyrussell/oh-my-zsh: (201 commits) bundler plugin: Simplify retrieval of cpu count on OSX (ohmyzsh#5180) Fix gfg function completion definition Fix man-preview completion definition Fix issue with `dash` as the default `/bin/sh` script executing program. (ohmyzsh#5177) znt: update to v2.2.1 (ohmyzsh#5174) emacs plugin tweak to open buffer from stdin (ohmyzsh#5126) Update taskwarrior completion to 2.5.1 (ohmyzsh#5171) Remove undesirable hardcoding of PATH into zshrc (ohmyzsh#4925) Add README for OSX plugin and refactor plugin file Open finder to PWD - part 2 (ohmyzsh#5165) Add ofd() to OSX plugin to open finder on current directory (ohmyzsh#5164) add 'mvn clean install -DskipTests --offline' alias to speed up maven compile (ohmyzsh#5153) Peepcode theme: Don't try to use RVM if it's not available (ohmyzsh#5154) Replace _kitchen completion with the version from zsh-users (ohmyzsh#5011) Mod: use new debug namespace to avoid deprecation warning (ohmyzsh#4799) Fix: Plugin knife: Add relative local path for commands which upload files (ohmyzsh#4240) Add list-timers to systemd user commands (ohmyzsh#5099) Adds ReactNative plugin 📱 (ohmyzsh#5018) Fix arcanist aliases (ohmyzsh#5110) add plugin react-native (ohmyzsh#4606) ... # Conflicts: # README.md # lib/git.zsh # plugins/branch/branch.plugin.zsh # plugins/ember-cli/README.md # plugins/github/README.md # plugins/github/github.plugin.zsh # plugins/history-substring-search/README.md # plugins/history-substring-search/update-from-upstream.zsh # plugins/zsh-navigation-tools/.config/znt/n-aliases.conf # plugins/zsh-navigation-tools/.config/znt/n-cd.conf # plugins/zsh-navigation-tools/.config/znt/n-env.conf # plugins/zsh-navigation-tools/.config/znt/n-functions.conf # plugins/zsh-navigation-tools/.config/znt/n-history.conf # plugins/zsh-navigation-tools/.config/znt/n-kill.conf # plugins/zsh-navigation-tools/.config/znt/n-list.conf # plugins/zsh-navigation-tools/.config/znt/n-options.conf # plugins/zsh-navigation-tools/.config/znt/n-panelize.conf # plugins/zsh-navigation-tools/README.md # plugins/zsh-navigation-tools/n-aliases # plugins/zsh-navigation-tools/n-cd # plugins/zsh-navigation-tools/n-env # plugins/zsh-navigation-tools/n-functions # plugins/zsh-navigation-tools/n-history # plugins/zsh-navigation-tools/n-kill # plugins/zsh-navigation-tools/n-list # plugins/zsh-navigation-tools/n-list-draw # plugins/zsh-navigation-tools/n-list-input # plugins/zsh-navigation-tools/n-options # plugins/zsh-navigation-tools/n-panelize # plugins/zsh-navigation-tools/znt-history-widget # plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
* 'master' of github.com:sprig/oh-my-zsh: (455 commits) quoted a string znt: update to v2.2.1 (ohmyzsh#5174) emacs plugin tweak to open buffer from stdin (ohmyzsh#5126) Update taskwarrior completion to 2.5.1 (ohmyzsh#5171) Remove undesirable hardcoding of PATH into zshrc (ohmyzsh#4925) Add README for OSX plugin and refactor plugin file Open finder to PWD - part 2 (ohmyzsh#5165) Add ofd() to OSX plugin to open finder on current directory (ohmyzsh#5164) add 'mvn clean install -DskipTests --offline' alias to speed up maven compile (ohmyzsh#5153) Peepcode theme: Don't try to use RVM if it's not available (ohmyzsh#5154) Replace _kitchen completion with the version from zsh-users (ohmyzsh#5011) Mod: use new debug namespace to avoid deprecation warning (ohmyzsh#4799) Fix: Plugin knife: Add relative local path for commands which upload files (ohmyzsh#4240) Add list-timers to systemd user commands (ohmyzsh#5099) Adds ReactNative plugin 📱 (ohmyzsh#5018) Fix arcanist aliases (ohmyzsh#5110) add plugin react-native (ohmyzsh#4606) installer: fix ordering of cygwin msys git check (ohmyzsh#4557) Use default branch on recently created Mercurial repository. (ohmyzsh#4985) Add zsh completion plugin for rustc (ohmyzsh#3159) ...
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
…files (ohmyzsh#4240) * Added autocomplete support for local knife file uploads * Added option to allow for relative path resolution for cookbooks * Updated _chef_root function to use directory:h
Currently any of the
knife * from file
commands autocomplete by the knife plugin only look in the current directory for the relevant files. This fix searches upwards for a .chef folder and then looks in the folder relative to that folder (this is similar to the way knife itself functions). This should affect the following subcommands:knife node from file
knife environment from file
knife role from file
knife data bag from file
It also adds an option (
KNIFE_RELATIVE_PATH
) that letsknife cookbook upload
work in the same way. This is useful when you have multiple local Chef orgs and can't set a path to a single cookbooks folder.