diff --git a/lib/cli.zsh b/lib/cli.zsh index a9f0a0767..3f3012c78 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -615,12 +615,13 @@ function _omz::pr::test { builtin cd -q "$ZSH" # Get the ohmyzsh git remote - command git remote -v | while read remote url _; do + local found=0 + while read remote url _; do case "$url" in https://github.com/ohmyzsh/ohmyzsh(|.git)) found=1; break ;; git@github.com:ohmyzsh/ohmyzsh(|.git)) found=1; break ;; esac - done + done <<< "$(command git remote -v)" (( $found )) || { _omz::log error "could not find the ohmyzsh git remote. Aborting..." diff --git a/lib/functions.zsh b/lib/functions.zsh index 330b0e3e9..71c787631 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -65,7 +65,9 @@ function takezip() { data="$(mktemp)" curl -L "$1" > "$data" unzip "$data" -d "./" - thedir="$(unzip -l "$data" | awk 'NR==4 {print $4}' | sed 's/\/.*//')" + # Parse the first actual file entry from unzip -l output, skipping header lines and separators + thedir="$(unzip -l "$data" | awk 'NR>3 && !/^-/ && NF>=4 {print $4; exit}')" + thedir="${thedir%%/*}" rm "$data" cd "$thedir" } diff --git a/lib/grep.zsh b/lib/grep.zsh index 1a70de7e5..a7041944b 100644 --- a/lib/grep.zsh +++ b/lib/grep.zsh @@ -10,20 +10,21 @@ else } # Ignore these folders (if the necessary grep flags are available) - EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox,.venv,venv}" + local EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox,.venv,venv}" + local grep_opts # Check for --exclude-dir, otherwise check for --exclude. If --exclude # isn't available, --color won't be either (they were released at the same # time (v2.5): https://git.savannah.gnu.org/cgit/grep.git/tree/NEWS?id=1236f007 if grep-flags-available --color=auto --exclude-dir=.cvs; then - GREP_OPTIONS="--color=auto --exclude-dir=$EXC_FOLDERS" + grep_opts="--color=auto --exclude-dir=$EXC_FOLDERS" elif grep-flags-available --color=auto --exclude=.cvs; then - GREP_OPTIONS="--color=auto --exclude=$EXC_FOLDERS" + grep_opts="--color=auto --exclude=$EXC_FOLDERS" fi - if [[ -n "$GREP_OPTIONS" ]]; then + if [[ -n "$grep_opts" ]]; then # export grep, egrep and fgrep settings - alias grep="grep $GREP_OPTIONS" + alias grep="grep $grep_opts" alias egrep="grep -E" alias fgrep="grep -F" @@ -34,7 +35,6 @@ else fi # Clean up - unset GREP_OPTIONS EXC_FOLDERS unfunction grep-flags-available fi diff --git a/lib/history.zsh b/lib/history.zsh index 781a0e9de..c1833aa6e 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -36,8 +36,8 @@ esac ## History file configuration [ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history" -[ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000 -[ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000 +[ -z "$HISTSIZE" ] || [ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000 +[ -z "$SAVEHIST" ] || [ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000 ## History command configuration setopt extended_history # record timestamp of command in HISTFILE diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 5cfa2e631..09f09f1b7 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -57,8 +57,8 @@ case "$OSTYPE" in # with color and multibyte support) are available from ports. # `colorls` will be installed on purpose and can't be pulled in by installing # coreutils (which might be installed for ), so prefer it to `gls`. - test-ls-args gls --color && alias ls='gls --color=tty' test-ls-args colorls -G && alias ls='colorls -G' + test-ls-args gls --color && alias ls='gls --color=tty' ;; (darwin|freebsd)*) # This alias works by default just using $LSCOLORS diff --git a/plugins/docker/docker.plugin.zsh b/plugins/docker/docker.plugin.zsh index 9d7cf8641..113604450 100644 --- a/plugins/docker/docker.plugin.zsh +++ b/plugins/docker/docker.plugin.zsh @@ -29,7 +29,7 @@ alias 'drm!'='docker container rm -f' alias dsprune='docker system prune' alias dst='docker container start' alias drs='docker container restart' -alias dsta='docker stop $(docker ps -q)' +alias dsta='docker ps -q | xargs -r docker stop' alias dstp='docker container stop' alias dsts='docker stats' alias dtop='docker top' diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 9ef60d69a..9fd957b89 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -167,7 +167,12 @@ alias gcpa='git cherry-pick --abort' alias gcpc='git cherry-pick --continue' alias gclean='git clean --interactive -d' alias gcl='git clone --recurse-submodules' -alias gclf='git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules' +# gclf: clone with --filter and --shallow-submodules, requires Git >= 2.36 for --also-filter-submodules +if is-at-least 2.36.0 "$git_version"; then + alias gclf='git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules' +else + alias gclf='git clone --recursive --shallow-submodules --filter=blob:none' +fi function gccd() { setopt localoptions extendedglob diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index ba371cd87..45af29d92 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -42,6 +42,8 @@ alias kdelf='kubectl delete -f' alias kdelk='kubectl delete -k' alias kge='kubectl get events --sort-by=".lastTimestamp"' alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch' +alias kgen='kubectl get events --sort-by=".metadata.creationTimestamp"' +alias kgenw='kubectl get events --sort-by=".metadata.creationTimestamp" --watch' # Pod management. alias kgp='kubectl get pods' diff --git a/plugins/macos/spotify b/plugins/macos/spotify index ae42db425..84ea0560d 100644 --- a/plugins/macos/spotify +++ b/plugins/macos/spotify @@ -194,7 +194,7 @@ while [ $# -gt 0 ]; do -d "grant_type=client_credentials" \ ) if ! [[ "${SPOTIFY_TOKEN_RESPONSE_DATA}" =~ "access_token" ]]; then - cecho "Authorization failed, please check ${USER_CONFG_FILE}" + cecho "Authorization failed, please check ${USER_CONFIG_FILE}" cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}" showAPIHelp return 1 diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index c333f76ed..7f534324a 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -32,7 +32,7 @@ alias npmF='npm i -f' # Execute command from node_modules folder based on current directory # i.e npmE gulp -alias npmE='PATH="$(npm bin)":"$PATH"' +alias npmE='PATH="$(npm prefix)/node_modules/.bin":"$PATH"' # Check which npm modules are outdated alias npmO="npm outdated"