1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-14 22:47:45 +08:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Marc Cornellà
0f6836701d fix(CLI): properly get zsh command in omz update (#9558)
Zsh versions older than 5.3 don't have ZSH_ARGZERO, so use an alternative
method to get the zsh command.

Fixes #9558
2020-12-31 23:20:24 +01:00
hjpotter92
0e7c81316c
feat(grc): source grc.zsh instead of hard-coding its content (#9553)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
2020-12-31 11:07:28 +01:00
3 changed files with 17 additions and 64 deletions

View File

@ -391,7 +391,9 @@ function _omz::update {
# Restart the zsh session
if [[ $ret -eq 0 && "$1" != --unattended ]]; then
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$ZSH_ARGZERO" = -* ]] && exec -l "${ZSH_ARGZERO#-}" || exec "$ZSH_ARGZERO"
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
fi
}

View File

@ -10,28 +10,6 @@ plugins=(... grc)
## Commands
The following commands are wrapped by `grc` so that their output is automatically colored:
- `cc`
- `configure`
- `cvs`
- `df`
- `diff`
- `dig`
- `gcc`
- `gmake`
- `ifconfig`
- `iwconfig`
- `last`
- `ldap`
- `make`
- `mount`
- `mtr`
- `netstat`
- `ping`
- `ping6`
- `ps`
- `traceroute`
- `traceroute6`
- `wdiff`
- `whois`
The plugin sources the bundled alias generator from the installation, available at `/etc/grc.zsh`.
The complete list of wrapped commands may vary depending on the installed version of `grc`, look
at the file mentioned above (`/etc/grc.zsh`) to see which commands are wrapped.

View File

@ -1,44 +1,17 @@
# Adapted from: https://github.com/garabik/grc/blob/master/grc.zsh
#!/usr/bin/env zsh
if [[ "$TERM" = dumb ]] || (( ! $+commands[grc] )); then
return
fi
# Supported commands
cmds=(
cc
configure
cvs
df
diff
dig
gcc
gmake
ifconfig
iwconfig
last
ldap
make
mount
mtr
netstat
ping
ping6
ps
traceroute
traceroute6
wdiff
whois
# common grc.zsh paths
files=(
/etc/grc.zsh # default
/usr/local/etc/grc.zsh # homebrew
)
# Set alias for supported commands
for cmd in $cmds; do
if (( $+commands[$cmd] )); then
eval "function $cmd {
grc --colour=auto \"${commands[$cmd]}\" \"\$@\"
}"
# verify the file is readable and source it
for file in $files; do
if [[ -r "$file" ]]; then
source "$file"
break
fi
done
# Clean up variables
unset cmds cmd
unset file files