1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-12 08:50:08 +00:00

feat(cli)!: add omz reload command and deprecate zsh_reload plugin (#9078)

BREAKING CHANGE: the `zsh_reload` plugin is deprecated. Instead of using its `src`
function, use `omz reload` or `exec zsh` to reload zsh after making changes to
your `.zshrc` file.

Closes #9078
This commit is contained in:
Monson Shao 2020-07-03 12:16:58 +08:00 committed by Marc Cornellà
parent 56ab66b194
commit be4a952972
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B
3 changed files with 18 additions and 41 deletions

View file

@ -26,6 +26,7 @@ function _omz {
'help:Usage information'
'plugin:Manage plugins'
'pr:Manage Oh My Zsh Pull Requests'
'reload:Reload the current zsh session'
'theme:Manage themes'
'update:Update Oh My Zsh'
)
@ -159,6 +160,7 @@ Available commands:
changelog Print the changelog
plugin <command> Manage plugins
pr <command> Manage Oh My Zsh Pull Requests
reload Reload the current zsh session
theme <command> Manage themes
update Update Oh My Zsh
@ -598,6 +600,16 @@ function _omz::pr::test {
)
}
function _omz::reload {
# Delete current completion cache
command rm -f $_comp_dumpfile $ZSH_COMPDUMP
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
}
function _omz::theme {
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
cat >&2 <<EOF

View file

@ -1,23 +1,3 @@
# zsh_reload plugin
The zsh_reload plugin defines a function to reload the zsh session with
just a few keystrokes.
To use it, add `zsh_reload` to the plugins array in your zshrc file:
```zsh
plugins=(... zsh_reload)
```
## Usage
To reload the zsh session, just run `src`:
```zsh
$ vim ~/.zshrc # enabled a plugin
$ src
re-compiling /home/user/.zshrc.zwc: succeeded
re-compiling /home/user/.oh-my-zsh/cache/zcomp-host.zwc: succeeded
# you now have a fresh zsh session. happy hacking!
```
**This plugin is deprecated.** Use `omz reload` or `exec zsh` instead.

View file

@ -1,22 +1,7 @@
print ${(%):-"%F{yellow}The \`zsh_reload\` plugin is deprecated and will be removed."}
print ${(%):-"Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f"}
src() {
local cache="$ZSH_CACHE_DIR"
autoload -U compinit zrecompile
compinit -i -d "$cache/zcomp-$HOST"
for f in ${ZDOTDIR:-~}/.zshrc "$cache/zcomp-$HOST"; do
zrecompile -p $f && command rm -f $f.zwc.old
done
# Use $SHELL if it's available and a zsh shell
local shell="$ZSH_ARGZERO"
if [[ "${${SHELL:t}#-}" = zsh ]]; then
shell="$SHELL"
fi
# Remove leading dash if login shell and run accordingly
if [[ "${shell:0:1}" = "-" ]]; then
exec -l "${shell#-}"
else
exec "$shell"
fi
print ${(%):-"%F{yellow}$0 is deprecated. Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f\n"}
omz reload
}