diff options
96 files changed, 1381 insertions, 997 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c6b3e8ce9..6668cd7ce 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,5 @@ # Plugin owners plugins/archlinux/ @ratijas -plugins/aws/ @maksyms plugins/genpass/ @atoponce plugins/git-lfs/ @hellovietduc plugins/gitfast/ @felipec diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57a1e3833..8ee2df3d8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ on: branches: - master push: - branches: + branches: - master concurrency: @@ -27,7 +27,7 @@ jobs: os: [ubuntu-latest, macos-latest] steps: - name: Set up git repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install zsh if: runner.os == 'Linux' run: sudo apt-get update; sudo apt-get install zsh diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index ad83fc4b2..2f3b6bcad 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -57,6 +57,9 @@ function detect-clipboard() { elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } function clippaste() { cat /dev/clipboard; } + elif (( $+commands[clip.exe] )) && (( $+commands[powershell.exe] )); then + function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; } + function clippaste() { powershell.exe -noprofile -command Get-Clipboard; } elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; } function clippaste() { wl-paste; } @@ -81,9 +84,6 @@ function detect-clipboard() { elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then function clipcopy() { tmux load-buffer "${1:--}"; } function clippaste() { tmux save-buffer -; } - elif [[ $(uname -r) = *icrosoft* ]]; then - function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; } - function clippaste() { powershell.exe -noprofile -command Get-Clipboard; } else function _retry_clipboard_detection_or_fail() { local clipcmd="${1}"; shift diff --git a/lib/git.zsh b/lib/git.zsh index be9fa7e67..f049f73c2 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -19,6 +19,7 @@ function git_prompt_info() { local ref ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \ + || ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \ || ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \ || return 0 diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 29d39ca23..e94c2f417 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -143,7 +143,10 @@ fi unset zcompdump_revision zcompdump_fpath zcompdump_refresh # zcompile the completion dump file if the .zwc is older or missing. -zrecompile -q -p "$ZSH_COMPDUMP" && command rm -f "$ZSH_COMPDUMP.zwc.old" +if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then + zrecompile -q -p "$ZSH_COMPDUMP" + command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock" +fi # Load all of the config files in ~/oh-my-zsh that end in .zsh # TIP: Add files you don't want in git to .gitignore diff --git a/plugins/1password/README.md b/plugins/1password/README.md index f6854da53..ace6da8e1 100644 --- a/plugins/1password/README.md +++ b/plugins/1password/README.md @@ -14,16 +14,18 @@ clipboard. ## `opswd` The `opswd` command is a wrapper around the `op` command. It takes a service -name as an argument and copies the password for that service to the clipboard. +name as an argument and copies the username, then the password for that service +to the clipboard, after confirmation on the user part. -If the service also contains a TOTP, it is copied to the clipboard after 10 seconds. -Finally, after 20 seconds, the clipboard is cleared. +If the service also contains a TOTP, it is copied to the clipboard after confirmation +on the user part. Finally, after 20 seconds, the clipboard is cleared. -The function has completion support, so you can use tab completion to select -which service you want to get. +For example, `opswd github.com` will put your GitHub username into your clipboard. Then, +it will ask for confirmation to continue, and copy the password to your clipboard. Finally, +if a TOTP is available, it will be copied to the clipboard after your confirmation. -For example, `opswd github.com` will put your GitHub password into your clipboard, and if -a TOTP is available, it will be copied to the clipboard after 10 seconds. +This function has completion support, so you can use tab completion to select which +service you want to get. > NOTE: you need to be signed in for `opswd` to work. If you are using biometric unlock, > 1Password CLI will automatically prompt you to sign in. See: diff --git a/plugins/1password/opswd b/plugins/1password/opswd index 57672807e..0f667d2ff 100644 --- a/plugins/1password/opswd +++ b/plugins/1password/opswd @@ -14,6 +14,17 @@ function opswd() { # If not logged in, print error and return op user list > /dev/null || return + local username + # Copy the username to the clipboard + if ! username=$(op item get "$service" --fields username 2>/dev/null); then + echo "error: could not obtain username for $service" + return 1 + fi + + echo -n "$username" | clipcopy + echo "✔ username for service $service copied to the clipboard. Press Enter to continue" + read + local password # Copy the password to the clipboard if ! password=$(op item get "$service" --fields password 2>/dev/null); then @@ -22,12 +33,13 @@ function opswd() { fi echo -n "$password" | clipcopy - echo "✔ password for $service copied to clipboard" + echo "✔ password for $service copied to clipboard. Press Enter to continue" + read - # If there's a one time password, copy it to the clipboard after 10 seconds + # If there's a one time password, copy it to the clipboard local totp if totp=$(op item get --otp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then - sleep 10 && echo -n "$totp" | clipcopy + echo -n "$totp" | clipcopy echo "✔ TOTP for $service copied to clipboard" fi diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md index 66fd84584..4e77f67b3 100644 --- a/plugins/aliases/README.md +++ b/plugins/aliases/README.md @@ -15,14 +15,14 @@ Requirements: Python needs to be installed. ## Usage -- `acs`: show all aliases by group. +- `acs`: show all aliases by group -- `acs -h/--help`: print help mesage. +- `acs -h/--help`: print help mesage -- `acs <keyword>`: filter aliases by `<keyword>` and highlight. +- `acs <keyword>`: filter aliases by `<keyword>` and highlight -- `acs -g <group>/--group <group`: show only aliases for group `<group>`. Multiple uses of the flag show all groups, +- `acs -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups -- `acs --groups-only`: show only group names +- `acs --groups`: show only group names ![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index e11f231b6..1b868ee8d 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -1,18 +1,18 @@ declare -a autojump_paths autojump_paths=( - $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation - $HOME/.autojump/share/autojump/autojump.zsh # manual installation - $HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation - /run/current-system/sw/share/autojump/autojump.zsh # NixOS installation - /usr/share/autojump/autojump.zsh # Debian and Ubuntu package - /etc/profile.d/autojump.zsh # manual installation - /etc/profile.d/autojump.sh # Gentoo installation - /usr/local/share/autojump/autojump.zsh # FreeBSD installation - /usr/pkg/share/autojump/autojump.zsh # NetBSD installation - /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts - /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) - /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs) - /etc/profiles/per-user/$USER/bin/autojump # macOS Nix, Home Manager and flakes + $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation + $HOME/.autojump/share/autojump/autojump.zsh # manual installation + $HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation + /run/current-system/sw/share/autojump/autojump.zsh # NixOS installation + /usr/share/autojump/autojump.zsh # Debian and Ubuntu package + /etc/profile.d/autojump.zsh # manual installation + /etc/profile.d/autojump.sh # Gentoo installation + /usr/local/share/autojump/autojump.zsh # FreeBSD installation + /usr/pkg/share/autojump/autojump.zsh # NetBSD installation + /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts + /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) + /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs) + /etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes ) for file in $autojump_paths; do diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 2167f552c..865e82f19 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -146,6 +146,7 @@ function aws_change_access_key() { } function aws_profiles() { + aws --no-cli-pager configure list-profiles 2> /dev/null && return [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g' } diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index 479796dbe..ed2653aa8 100644 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -1,44 +1,79 @@ #!/usr/bin/env zsh -## setup ## +## Setup -[[ -o interactive ]] || return #interactive only! -zmodload zsh/datetime || { print "can't load zsh/datetime"; return } # faster than date() -autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return } +[[ -o interactive ]] || return # don't load on non-interactive shells +[[ -z "$SSH_CLIENT" && -z "$SSH_TTY" ]] || return # don't load on a SSH connection -(( ${+bgnotify_threshold} )) || bgnotify_threshold=5 #default 10 seconds +zmodload zsh/datetime # faster than `date` -## definitions ## +## Zsh Hooks -if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom function override - function bgnotify_formatted { ## args: (exit_status, command, elapsed_seconds) - elapsed="$(( $3 % 60 ))s" - (( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed" - (( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $elapsed" - [ $1 -eq 0 ] && bgnotify "#win (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2" +function bgnotify_begin { + bgnotify_timestamp=$EPOCHSECONDS + bgnotify_lastcmd="${1:-$2}" +} + +function bgnotify_end { + { + local exit_status=$? + local elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) + + # check time elapsed + [[ $bgnotify_timestamp -gt 0 ]] || return + [[ $elapsed -ge $bgnotify_threshold ]] || return + + # check if Terminal app is not active + [[ $(bgnotify_appid) != "$bgnotify_termid" ]] || return + + printf '\a' # beep sound + bgnotify_formatted "$exit_status" "$bgnotify_lastcmd" "$elapsed" + } always { + bgnotify_timestamp=0 } -fi +} + +autoload -Uz add-zsh-hook +add-zsh-hook preexec bgnotify_begin +add-zsh-hook precmd bgnotify_end + + +## Functions -currentAppId () { - if (( $+commands[osascript] )); then - osascript -e 'tell application (path to frontmost application as text) to id' 2>/dev/null +# allow custom function override +(( ${+functions[bgnotify_formatted]} )) || \ +function bgnotify_formatted { + local exit_status=$1 + local cmd="$2" + + # humanly readable elapsed time + local elapsed="$(( $3 % 60 ))s" + (( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed" + (( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed" + + if [[ $1 -eq 0 ]]; then + bgnotify "#win (took $elapsed)" "$2" + else + bgnotify "#fail (took $elapsed)" "$2" fi } -currentWindowId () { - if hash osascript 2>/dev/null; then #osx - osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" - elif (hash notify-send 2>/dev/null || hash kdialog 2>/dev/null); then #ubuntu! - xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0" +# for macOS, output is "app ID, window ID" (com.googlecode.iterm2, 116) +function bgnotify_appid { + if (( ${+commands[osascript]} )); then + osascript -e 'tell application (path to frontmost application as text) to get the {id, id of front window}' 2>/dev/null + elif (( ${+commands[xprop]} )); then + xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5 else - echo $EPOCHSECONDS #fallback for windows + echo $EPOCHSECONDS fi } -bgnotify () { ## args: (title, subtitle) - if hash terminal-notifier 2>/dev/null; then #osx - local term_id="$bgnotify_appid" +function bgnotify { + # $1: title, $2: message + if (( ${+commands[terminal-notifier]} )); then # macOS + local term_id="${bgnotify_termid%%,*}" # remove window id if [[ -z "$term_id" ]]; then case "$TERM_PROGRAM" in iTerm.app) term_id='com.googlecode.iterm2' ;; @@ -46,48 +81,26 @@ bgnotify () { ## args: (title, subtitle) esac fi - ## now call terminal-notifier, (hopefully with $term_id!) if [[ -z "$term_id" ]]; then - terminal-notifier -message "$2" -title "$1" >/dev/null + terminal-notifier -message "$2" -title "$1" &>/dev/null else - terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null + terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" &>/dev/null fi - elif hash growlnotify 2>/dev/null; then #osx growl + elif (( ${+commands[growlnotify]} )); then # macOS growl growlnotify -m "$1" "$2" - elif hash notify-send 2>/dev/null; then #ubuntu gnome! + elif (( ${+commands[notify-send]} )); then # GNOME notify-send "$1" "$2" - elif hash kdialog 2>/dev/null; then #ubuntu kde! + elif (( ${+commands[kdialog]} )); then # KDE kdialog --title "$1" --passivepopup "$2" 5 - elif hash notifu 2>/dev/null; then #cygwyn support! + elif (( ${+commands[notifu]} )); then # cygwin notifu /m "$2" /p "$1" fi } +## Defaults -## Zsh hooks ## - -bgnotify_begin() { - bgnotify_timestamp=$EPOCHSECONDS - bgnotify_lastcmd="${1:-$2}" - bgnotify_appid="$(currentAppId)" - bgnotify_windowid=$(currentWindowId) -} - -bgnotify_end() { - didexit=$? - elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) - past_threshold=$(( elapsed >= bgnotify_threshold )) - if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then - if [[ $(currentAppId) != "$bgnotify_appid" || $(currentWindowId) != "$bgnotify_windowid" ]]; then - print -n "\a" - bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" - fi - fi - bgnotify_timestamp=0 #reset it to 0! -} +# notify if command took longer than 5s by default +bgnotify_threshold=${bgnotify_threshold:-5} -## only enable if a local (non-ssh) connection -if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then - add-zsh-hook preexec bgnotify_begin - add-zsh-hook precmd bgnotify_end -fi +# bgnotify_appid is slow in macOS and the terminal ID won't change, so cache it at startup +bgnotify_termid="$(bgnotify_appid)" diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 9ce2c5bb0..4a42b3d74 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -21,13 +21,16 @@ defined for convenience. | -------- | ------------------------------------- | ------------------------------------------------------------------- | | `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | | `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. | +| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. | | `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. | | `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. | | `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. | | `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. | +| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. | | `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. | | `bubu` | `bubo && bubc` | Do the last two operations above. | | `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). | +| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. | ## Completion diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index ea8900823..8275454a4 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -27,12 +27,16 @@ fi alias bcubc='brew upgrade --cask && brew cleanup' alias bcubo='brew update && brew outdated --cask' +alias bcubc='brew upgrade --cask && brew cleanup' alias brewp='brew pin' alias brewsp='brew list --pinned' alias bubc='brew upgrade && brew cleanup' +alias bugbc='brew upgrade --greedy && brew cleanup' alias bubo='brew update && brew outdated' alias bubu='bubo && bubc' +alias bubug='bubo && bugbc' alias buf='brew upgrade --formula' +alias buz='brew uninstall --zap' function brews() { local formulae="$(brew leaves | xargs brew deps --installed --for-each)" diff --git a/plugins/bridgetown/README.md b/plugins/bridgetown/README.md new file mode 100644 index 000000000..0a41814ee --- /dev/null +++ b/plugins/bridgetown/README.md @@ -0,0 +1,26 @@ +# Bridgetown plugin + +This plugin adds some aliases and autocompletion for common [Bridgetown](https://bridgetownrb.com/) commands. + +To use it, add `bridgetown` to the plugins array in your zshrc file: + +```zsh +plugins=(... bridgetown) +``` + +## Aliases + +| Alias | Command | +|-------|----------------------------| +| br | `bridgetown` | +| bra | `bin/bridgetown apply` | +| brb | `bin/bridgetown build` | +| brc | `bin/bridgetown console` | +| brclean | `bin/bridgetown clean` | +| brd | `bin/bridgetown deploy` | +| brdoc | `bin/bridgetown doctor` | +| brh | `bin/bridgetown help` | +| brn | `bridgetown new` | +| brp | `bridgetown plugins` | +| brpl | `bridgetown plugins list` | +| brs | `bin/bridgetown start` | diff --git a/plugins/bridgetown/bridgetown.plugin.zsh b/plugins/bridgetown/bridgetown.plugin.zsh new file mode 100644 index 000000000..502e9dfe0 --- /dev/null +++ b/plugins/bridgetown/bridgetown.plugin.zsh @@ -0,0 +1,12 @@ +alias br='bridgetown' +alias bra='bin/bridgetown apply' +alias brb='bin/bridgetown build' +alias brc='bin/bridgetown console' +alias brclean='bin/bridgetown clean' +alias brd='bin/bridgetown deploy' +alias brdoc='bin/bridgetown doctor' +alias brh='bin/bridgetown help' +alias brn='bridgetown new' +alias brp='bridgetown plugins' +alias brpl='bridgetown plugins list' +alias brs='bin/bridgetown start' diff --git a/plugins/cakephp3/cakephp3.plugin.zsh b/plugins/cakephp3/cakephp3.plugin.zsh index dbfbeba3b..a1a289fd0 100644 --- a/plugins/cakephp3/cakephp3.plugin.zsh +++ b/plugins/cakephp3/cakephp3.plugin.zsh @@ -1,10 +1,10 @@ # CakePHP 3 basic command completion _cakephp3_get_command_list () { - bin/cake Completion commands + bin/cake completion commands } _cakephp3_get_sub_command_list () { - bin/cake Completion subcommands ${words[2]} + bin/cake completion subcommands ${words[2]} } _cakephp3_get_3rd_argument () { @@ -34,5 +34,5 @@ compdef _cakephp3 cake #Alias alias c3='bin/cake' -alias c3cache='bin/cake orm_cache clear' +alias c3cache='bin/cake schema_cache clear' alias c3migrate='bin/cake migrations migrate' diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index a9da6cf83..12841e0ee 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -23,7 +23,7 @@ colorize_check_requirements() { if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2 return 1 - elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then + elif ! (( $+commands[$ZSH_COLORIZE_TOOL] )); then echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2 return 1 fi diff --git a/plugins/debian/README.md b/plugins/debian/README.md index 1db534f13..c1ebe1c50 100644 --- a/plugins/debian/README.md +++ b/plugins/debian/README.md @@ -21,7 +21,7 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh | ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- | | `age` | `apt-get` | Command line tool for handling packages | | `api` | `aptitude` | Same functionality as `apt-get`, provides extra options | -| `acs` | `apt-cache search` | Command line tool for searching apt software package cache | +| `acse` | `apt-cache search` | Command line tool for searching apt software package cache | | `aps` | `aptitude search` | Searches installed packages using aptitude | | `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format | | `afs` | `apt-file search --regexp` | Search file in packages | diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 2d8c4666e..bab1ae1c6 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -26,7 +26,7 @@ alias age='apt-get' alias api='aptitude' # Some self-explanatory aliases -alias acs="apt-cache search" +alias acse="apt-cache search" alias aps='aptitude search' alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search" @@ -51,7 +51,7 @@ if [[ $use_sudo -eq 1 ]]; then alias au="sudo $apt_pref $apt_upgr" alias ai="sudo $apt_pref install" # Install all packages given on the command line while using only the first word of each line: - # acs ... | ail + # acse ... | ail alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install" alias ap="sudo $apt_pref purge" diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md index 13f3c2cea..bbcff2e0c 100644 --- a/plugins/docker-compose/README.md +++ b/plugins/docker-compose/README.md @@ -11,22 +11,23 @@ plugins=(... docker-compose) ## Aliases -| Alias | Command | Description | -|-----------|--------------------------------|------------------------------------------------------------------| -| dco | `docker-compose` | Docker-compose main command | -| dcb | `docker-compose build` | Build containers | -| dce | `docker-compose exec` | Execute command inside a container | -| dcps | `docker-compose ps` | List containers | -| dcrestart | `docker-compose restart` | Restart container | -| dcrm | `docker-compose rm` | Remove container | -| dcr | `docker-compose run` | Run a command in container | -| dcstop | `docker-compose stop` | Stop a container | -| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service | -| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers | -| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon | -| dcdn | `docker-compose down` | Stop and remove containers | -| dcl | `docker-compose logs` | Show logs of container | -| dclf | `docker-compose logs -f` | Show logs and follow output | -| dcpull | `docker-compose pull` | Pull image of a service | -| dcstart | `docker-compose start` | Start a container | -| dck | `docker-compose kill` | Kills containers | +| Alias | Command | Description | +|-----------|--------------------------------|----------------------------------------------------------------------------------| +| dco | `docker-compose` | Docker-compose main command | +| dcb | `docker-compose build` | Build containers | +| dce | `docker-compose exec` | Execute command inside a container | +| dcps | `docker-compose ps` | List containers | +| dcrestart | `docker-compose restart` | Restart container | +| dcrm | `docker-compose rm` | Remove container | +| dcr | `docker-compose run` | Run a command in container | +| dcstop | `docker-compose stop` | Stop a container | +| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service | +| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers | +| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon | +| dcupdb | `docker-compose up -d --build` | Same as `dcup`, but build images before starting containers and starts as daemon | +| dcdn | `docker-compose down` | Stop and remove containers | +| dcl | `docker-compose logs` | Show logs of container | +| dclf | `docker-compose logs -f` | Show logs and follow output | +| dcpull | `docker-compose pull` | Pull image of a service | +| dcstart | `docker-compose start` | Start a container | +| dck | `docker-compose kill` | Kills containers | diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index b8a4b067d..7a8bf4a03 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -12,6 +12,7 @@ alias dcstop="$dccmd stop" alias dcup="$dccmd up" alias dcupb="$dccmd up --build" alias dcupd="$dccmd up -d" +alias dcupdb="$dccmd up -d --build" alias dcdn="$dccmd down" alias dcl="$dccmd logs" alias dclf="$dccmd logs -f" diff --git a/plugins/docker/README.md b/plugins/docker/README.md index 606690f14..512b5d17c 100644 --- a/plugins/docker/README.md +++ b/plugins/docker/README.md @@ -13,18 +13,15 @@ https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker ## Settings -By default, the completion doesn't allow option-stacking, meaning if you try to -complete `docker run -it <TAB>` it won't work, because you're _stacking_ the -`-i` and `-t` options. +By default, the completion doesn't allow option-stacking, meaning if you try to complete +`docker run -it <TAB>` it won't work, because you're _stacking_ the `-i` and `-t` options. -[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding -the lines below to your zshrc file**, but be aware of the side effects: +[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding the lines below to your zshrc +file**, but be aware of the side effects: -> This enables Zsh to understand commands like `docker run -it -> ubuntu`. However, by enabling this, this also makes Zsh complete -> `docker run -u<tab>` with `docker run -uapprox` which is not valid. The -> users have to put the space or the equal sign themselves before trying -> to complete. +> This enables Zsh to understand commands like `docker run -it ubuntu`. However, by enabling this, this also +> makes Zsh complete `docker run -u<tab>` with `docker run -uapprox` which is not valid. The users have to put +> the space or the equal sign themselves before trying to complete. > > Therefore, this behavior is disabled by default. To enable it: > @@ -35,39 +32,38 @@ the lines below to your zshrc file**, but be aware of the side effects: ## Aliases -| Alias | Command | Description | -| :------ | :-------------------------- | :--------------------------------------------------------------------------------------- | -| dbl | `docker build` | Build an image from a Dockerfile | -| dcin | `docker container inspect` | Display detailed information on one or more containers | -| dlo | `docker container logs` | Fetch the logs of a docker container | -| dcls | `docker container ls` | List all the running docker containers | -| dclsa | `docker container ls -a` | List all running and stopped containers | -| dpo | `docker container port` | List port mappings or a specific mapping for the container | -| dpu | `docker pull` | Pull an image or a repository from a registry | -| dr | `docker container run` | Create a new container and start it using the specified command | -| drit | `docker container run -it` | Create a new container and start it in an interactive shell | -| drm | `docker container rm` | Remove the specified container(s) | -| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) | -| dst | `docker container start` | Start one or more stopped containers | -| dstp | `docker container stop` | Stop one or more running containers | -| dtop | `docker top` | Display the running processes of a container | -| dxc | `docker container exec` | Run a new command in a running container | -| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell | -| | | **Docker Images** | -| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) | -| dii | `docker image inspect` | Display detailed information on one or more images | -| dils | `docker image ls` | List docker images | -| dipu | `docker image push` | Push an image or repository to a remote registry | -| dirm | `docker image rm` | Remove one or more images | -| dit | `docker image tag` | Add a name and tag to a particular image | -| | | **Docker Network** | -| dnc | `docker network create` | Create a new network | -| dncn | `docker network connect` | Connect a container to a network | -| dndcn | `docker network disconnect` | Disconnect a container from a network | -| dni | `docker network inspect` | Return information about one or more networks | -| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts | -| dnrm | `docker network rm` | Remove one or more networks | -| | | **Docker Volume** | -| dvi | `docker volume inspect` | Display detailed information about one or more volumes | -| dvls | `docker volume ls` | List all the volumes known to docker | -| dvprune | `docker volume prune` | Cleanup dangling volumes | +| Alias | Command | Description | +| :------ | :---------------------------- | :--------------------------------------------------------------------------------------- | +| dbl | `docker build` | Build an image from a Dockerfile | +| dcin | `docker container inspect` | Display detailed information on one or more containers | +| dcls | `docker container ls` | List all the running docker containers | +| dclsa | `docker container ls -a` | List all running and stopped containers | +| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) | +| dii | `docker image inspect` | Display detailed information on one or more images | +| dils | `docker image ls` | List docker images | +| dipu | `docker image push` | Push an image or repository to a remote registry | +| dirm | `docker image rm` | Remove one or more images | +| dit | `docker image tag` | Add a name and tag to a particular image | +| dlo | `docker container logs` | Fetch the logs of a docker container | +| dnc | `docker network create` | Create a new network | +| dncn | `docker network connect` | Connect a container to a network | +| dndcn | `docker network disconnect` | Disconnect a container from a network | +| dni | `docker network inspect` | Return information about one or more networks | +| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts | +| dnrm | `docker network rm` | Remove one or more networks | +| dpo | `docker container port` | List port mappings or a specific mapping for the container | +| dpu | `docker pull` | Pull an image or a repository from a registry | +| dr | `docker container run` | Create a new container and start it using the specified command | +| drit | `docker container run -it` | Create a new container and start it in an interactive shell | +| drm | `docker container rm` | Remove the specified container(s) | +| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) | +| dst | `docker container start` | Start one or more stopped containers | +| drs | `docker container restart` | Restart one or more containers +| dsta | `docker stop $(docker ps -q)` | Stop all running containers | +| dstp | `docker container stop` | Stop one or more running containers | +| dtop | `docker top` | Display the running processes of a container | +| dvi | `docker volume inspect` | Display detailed information about one or more volumes | +| dvls | `docker volume ls` | List all the volumes known to docker | +| dvprune | `docker volume prune` | Cleanup dangling volumes | +| dxc | `docker container exec` | Run a new command in a running container | +| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell | diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 8ee35abcf..e6a12d774 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -567,7 +567,7 @@ __docker_container_commands() { "cp:Copy files/folders between a container and the local filesystem" "create:Create a new container" "diff:Inspect changes on a container's filesystem" - "exec:Run a command in a running container" + "exec:Execute a command in a running container" "export:Export a container's filesystem as a tar archive" "inspect:Display detailed information on one or more containers" "kill:Kill one or more running containers" @@ -579,7 +579,7 @@ __docker_container_commands() { "rename:Rename a container" "restart:Restart one or more containers" "rm:Remove one or more containers" - "run:Run a command in a new container" + "run:Create and run a new container from an image" "start:Start one or more stopped containers" "stats:Display a live stream of container(s) resource usage statistics" "stop:Stop one or more running containers" @@ -650,6 +650,7 @@ __docker_container_subcommand() { "($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports" "($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid" "($help)--privileged[Give extended privileges to this container]" + "($help -q --quiet)"{-q,--quiet}"[Suppress the pull output]" "($help)--read-only[Mount the container's root filesystem as read only]" "($help)*--security-opt=[Security options]:security option: " "($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: " @@ -802,7 +803,7 @@ __docker_container_subcommand() { "($help -a --all)"{-a,--all}"[Show all containers]" \ "($help)--before=[Show only container created before...]:containers:__docker_complete_containers" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \ - "($help)--format=[Pretty-print containers using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \ "($help)--no-trunc[Do not truncate output]" \ @@ -907,7 +908,7 @@ __docker_container_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \ - "($help)--format=[Pretty-print images using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help)--no-stream[Disable streaming stats and only pull the first result]" \ "($help)--no-trunc[Do not truncate output]" \ "($help -)*:containers:__docker_complete_running_containers" && ret=0 @@ -973,8 +974,8 @@ __docker_image_commands() { "load:Load an image from a tar archive or STDIN" "ls:List images" "prune:Remove unused images" - "pull:Pull an image or a repository from a registry" - "push:Push an image or a repository to a registry" + "pull:Download an image from a registry" + "push:Upload an image to a registry" "rm:Remove one or more images" "save:Save one or more images to a tar archive (streamed to STDOUT by default)" "tag:Tag an image into a repository" @@ -1060,7 +1061,7 @@ __docker_image_subcommand() { "($help -a --all)"{-a,--all}"[Show all images]" \ "($help)--digests[Show digests]" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_images_filters" \ - "($help)--format=[Pretty-print images using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help)--no-trunc[Do not truncate output]" \ "($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \ "($help -): :__docker_complete_repositories" && ret=0 @@ -1082,7 +1083,7 @@ __docker_image_subcommand() { (push) _arguments $(__docker_arguments) \ $opts_help \ - "($help -a --all-tags)"{-a,--all-tags}"[Push all tagged images in the repository]" \ + "($help -a --all-tags)"{-a,--all-tags}"[Push all tags of an image to the repository]" \ "($help)--disable-content-trust[Skip image signing]" \ "($help -): :__docker_complete_images" && ret=0 ;; @@ -1292,7 +1293,7 @@ __docker_network_subcommand() { $opts_help \ "($help)--no-trunc[Do not truncate the output]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \ - "($help)--format=[Pretty-print networks using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display network IDs]" && ret=0 ;; (prune) @@ -2050,7 +2051,7 @@ __docker_service_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_service_complete_ls_filters" \ - "($help)--format=[Pretty-print services using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 ;; (rm|remove) @@ -2253,7 +2254,7 @@ __docker_stack_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_services_filters" \ - "($help)--format=[Pretty-print services using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \ "($help -):stack:__docker_complete_stacks" && ret=0 ;; @@ -2520,7 +2521,7 @@ __docker_volume_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_volume_complete_ls_filters" \ - "($help)--format=[Pretty-print volumes using a Go template]:template: " \ + "($help)--format=[Format the output using the given Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0 ;; (prune) @@ -2582,10 +2583,8 @@ __docker_context_subcommand() { (create) _arguments $(__docker_arguments) \ $opts_help \ - "($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \ "($help)--description=[Description of the context]:description:" \ "($help)--docker=[Set the docker endpoint]:docker:" \ - "($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \ "($help)--from=[Create context from a named context]:from:__docker_complete_contexts" \ "($help -):name: " && ret=0 ;; @@ -2607,10 +2606,8 @@ __docker_context_subcommand() { (update) _arguments $(__docker_arguments) \ $opts_help \ - "($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \ "($help)--description=[Description of the context]:description:" \ "($help)--docker=[Set the docker endpoint]:docker:" \ - "($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \ "($help -):name:" && ret=0 ;; esac @@ -2734,9 +2731,6 @@ __docker_subcommand() { "($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \ "($help)--bip=[Network bridge IP]:IP address: " \ "($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \ - "($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \ - "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \ - "($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \ "($help)--config-file=[Path to daemon configuration file]:Config File:_files" \ "($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \ "($help)--containerd-namespace=[Containerd namespace to use]:containerd namespace:" \ @@ -2778,7 +2772,7 @@ __docker_subcommand() { "($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \ "($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \ "($help)--raw-logs[Full timestamps without ANSI coloring]" \ - "($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \ + "($help)*--registry-mirror=[Preferred registry mirror]:registry mirror: " \ "($help)--seccomp-profile=[Path to seccomp profile]:path:_files -g \"*.json\"" \ "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \ "($help)--selinux-enabled[Enable selinux support]" \ @@ -2795,22 +2789,6 @@ __docker_subcommand() { "($help)--validate[Validate daemon configuration and exit]" && ret=0 case $state in - (cluster-store) - if compset -P '*://'; then - _message 'host:port' && ret=0 - else - store=('consul' 'etcd' 'zk') - _describe -t cluster-store "Cluster Store" store -qS "://" && ret=0 - fi - ;; - (cluster-store-options) - if compset -P '*='; then - _files && ret=0 - else - opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path') - _describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0 - fi - ;; (users-groups) if compset -P '*:'; then _groups && ret=0 @@ -3095,6 +3073,7 @@ _docker() { _arguments $(__docker_arguments) -C \ "(: -)"{-h,--help}"[Print usage]" \ "($help)--config[Location of client config files]:path:_directories" \ + "($help -c --context)"{-c=,--context=}"[Execute the command in a docker context]:context:__docker_complete_contexts" \ "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \ "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \ @@ -3110,7 +3089,8 @@ _docker() { local host=${opt_args[-H]}${opt_args[--host]} local config=${opt_args[--config]} - local docker_options="${host:+--host $host} ${config:+--config $config}" + local context=${opt_args[-c]}${opt_args[--context]} + local docker_options="${host:+--host $host} ${config:+--config $config} ${context:+--context $context} " case $state in (command) diff --git a/plugins/docker/docker.plugin.zsh b/plugins/docker/docker.plugin.zsh index 9c8ad8a28..8684a9785 100644 --- a/plugins/docker/docker.plugin.zsh +++ b/plugins/docker/docker.plugin.zsh @@ -1,39 +1,33 @@ alias dbl='docker build' -alias dpu='docker pull' -alias dtop='docker top' - -# docker containers alias dcin='docker container inspect' -alias dlo='docker container logs' alias dcls='docker container ls' alias dclsa='docker container ls -a' -alias dpo='docker container port' -alias dr='docker container run' -alias drit='docker container run -it' -alias drm='docker container rm' -alias 'drm!'='docker container rm -f' -alias dst='docker container start' -alias dstp='docker container stop' -alias dxc='docker container exec' -alias dxcit='docker container exec -it' - -# docker images alias dib='docker image build' alias dii='docker image inspect' alias dils='docker image ls' alias dipu='docker image push' alias dirm='docker image rm' alias dit='docker image tag' - -# docker network +alias dlo='docker container logs' alias dnc='docker network create' alias dncn='docker network connect' alias dndcn='docker network disconnect' alias dni='docker network inspect' alias dnls='docker network ls' alias dnrm='docker network rm' - -# docker volume +alias dpo='docker container port' +alias dpu='docker pull' +alias dr='docker container run' +alias drit='docker container run -it' +alias drm='docker container rm' +alias 'drm!'='docker container rm -f' +alias dst='docker container start' +alias drs='docker container restart' +alias dsta='docker stop $(docker ps -q)' +alias dstp='docker container stop' +alias dtop='docker top' alias dvi='docker volume inspect' alias dvls='docker volume ls' alias dvprune='docker volume prune' +alias dxc='docker container exec' +alias dxcit='docker container exec -it' diff --git a/plugins/doctl/doctl.plugin.zsh b/plugins/doctl/doctl.plugin.zsh index d23ed085c..7b3a384a9 100644 --- a/plugins/doctl/doctl.plugin.zsh +++ b/plugins/doctl/doctl.plugin.zsh @@ -4,6 +4,14 @@ # # Author: https://github.com/HalisCz -if [ $commands[doctl] ]; then - source <(doctl completion zsh) +if (( ! $+commands[doctl] )); then + return fi + +if [[ ! -f "$ZSH_CACHE_DIR/completions/_doctl" ]]; then + typeset -g -A _comps + autoload -Uz _doctl + _comps[doctl]=_doctl +fi + +doctl completion zsh >| "$ZSH_CACHE_DIR/completions/_doctl" &| diff --git a/plugins/emacs/README.md b/plugins/emacs/README.md index c8e33b5ab..8ed4a1473 100644 --- a/plugins/emacs/README.md +++ b/plugins/emacs/README.md @@ -25,6 +25,6 @@ The plugin uses a custom launcher (which we'll call here `$EMACS_LAUNCHER`) that | e | `emacs` | Same as emacs alias | | te | `$EMACS_LAUNCHER -nw` | Open terminal emacsclient | | eeval | `$EMACS_LAUNCHER --eval` | Same as `M-x eval` but from outside Emacs | -| eframe | `emacsclient --alternate-editor "" --create-frame` | Create new X frame | +| eframe | `emacsclient --alternate-editor="" --create-frame` | Create new X frame | | efile | - | Print the path to the file open in the current buffer | | ecd | - | Print the directory of the file open in the the current buffer | diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index fede5b0c4..4747f035b 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -32,7 +32,7 @@ alias te="$EMACS_PLUGIN_LAUNCHER -nw" # same than M-x eval but from outside Emacs. alias eeval="$EMACS_PLUGIN_LAUNCHER --eval" # create a new X frame -alias eframe='emacsclient --alternate-editor "" --create-frame' +alias eframe='emacsclient --alternate-editor="" --create-frame' # Emacs ANSI Term tracking if [[ -n "$INSIDE_EMACS" ]]; then diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh index 96893c932..172c0ae96 100755 --- a/plugins/emacs/emacsclient.sh +++ b/plugins/emacs/emacsclient.sh @@ -15,11 +15,11 @@ emacsfun() { # Only create another X frame if there isn't one present if [ -z "$frames" -o "$frames" = nil ]; then - emacsclient --alternate-editor "" --create-frame "$@" + emacsclient --alternate-editor="" --create-frame "$@" return $? fi - emacsclient --alternate-editor "" "$@" + emacsclient --alternate-editor="" "$@" } # Adapted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh diff --git a/plugins/encode64/README.md b/plugins/encode64/README.md index 86320cffb..7cdf8c3f3 100644 --- a/plugins/encode64/README.md +++ b/plugins/encode64/README.md @@ -10,10 +10,11 @@ plugins=(... encode64) ## Functions and Aliases -| Function | Alias | Description | -| ---------- | ----- | ------------------------------ | -| `encode64` | `e64` | Encodes given data to base64 | -| `decode64` | `d64` | Decodes given data from base64 | +| Function | Alias | Description | +| -------------- | ------ | -------------------------------------- | +| `encode64` | `e64` | Encodes given data to base64 | +| `encodefile64` | `ef64` | Encodes given file's content to base64 | +| `decode64` | `d64` | Decodes given data from base64 | ## Usage and examples @@ -37,6 +38,20 @@ plugins=(... encode64) b2gtbXktenNo== ``` +### Encoding a file + +Encode a file's contents to base64 and save output to text file. +**NOTE:** Takes provided file and saves encoded content as new file with `.txt` extension + +- From parameter + + ```console + $ encodefile64 ohmyzsh.icn + ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt + $ ef64 "oh-my-zsh" + ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt + ``` + ### Decoding - From parameter diff --git a/plugins/encode64/encode64.plugin.zsh b/plugins/encode64/encode64.plugin.zsh index 979e06742..6927f5216 100644 --- a/plugins/encode64/encode64.plugin.zsh +++ b/plugins/encode64/encode64.plugin.zsh @@ -6,6 +6,15 @@ encode64() { fi } +encodefile64() { + if [[ $# -eq 0 ]]; then + echo "You must provide a filename" + else + base64 -i $1 -o $1.txt + echo "${1}'s content encoded in base64 and saved as ${1}.txt" + fi +} + decode64() { if [[ $# -eq 0 ]]; then cat | base64 --decode @@ -14,4 +23,5 @@ decode64() { fi } alias e64=encode64 +alias ef64=encodefile64 alias d64=decode64 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 1112dd52f..563d88c72 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -30,12 +30,15 @@ EOF local extract_dir="${1:t:r}" local file="$1" full_path="${1:A}" case "${file:l}" in - (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$file" | tar xv } || tar zxvf "$file" ;; - (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$file" ;; + (*.tar.gz|*.tgz) + (( $+commands[pigz] )) && { tar -I pigz -xvf "$file" } || tar zxvf "$file" ;; + (*.tar.bz2|*.tbz|*.tbz2) + (( $+commands[pbzip2] )) && { tar -I pbzip2 -xvf "$file" } || tar xvjf "$file" ;; (*.tar.xz|*.txz) + (( $+commands[pixz] )) && { tar -I pixz -xvf "$file" } || { tar --xz --help &> /dev/null \ && tar --xz -xvf "$file" \ - || xzcat "$file" | tar xvf - ;; + || xzcat "$file" | tar xvf - } ;; (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ && tar --lzma -xvf "$file" \ diff --git a/plugins/fluxcd/README.md b/plugins/fluxcd/README.md new file mode 100644 index 000000000..9723fcc6b --- /dev/null +++ b/plugins/fluxcd/README.md @@ -0,0 +1,9 @@ +# FluxCD plugin + +This plugin adds completion for [FluxCD](https://fluxcd.io), an open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit. + +To use it, add `fluxcd` to the plugins array in your zshrc file: + +```zsh +plugins=(... fluxcd) +``` diff --git a/plugins/fluxcd/fluxcd.plugin.zsh b/plugins/fluxcd/fluxcd.plugin.zsh new file mode 100644 index 000000000..d30866a06 --- /dev/null +++ b/plugins/fluxcd/fluxcd.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for the FluxCD CLI (flux). +if (( ! $+commands[flux] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `flux`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_flux" ]]; then + typeset -g -A _comps + autoload -Uz _flux + _comps[flux]=_flux +fi + +flux completion zsh >| "$ZSH_CACHE_DIR/completions/_flux" &| diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 60ae0c765..9c8dd8648 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -9,6 +9,7 @@ function fzf_setup_using_base_dir() { "${HOME}/.nix-profile/share/fzf" "${XDG_DATA_HOME:-$HOME/.local/share}/fzf" "/usr/local/opt/fzf" + "/opt/homebrew/bin/fzf" "/usr/share/fzf" "/usr/local/share/examples/fzf" ) diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh index b86d7c5b6..6b96e12af 100644 --- a/plugins/git-extras/git-extras.plugin.zsh +++ b/plugins/git-extras/git-extras.plugin.zsh @@ -51,7 +51,7 @@ __gitex_remote_names() { local expl declare -a remote_names remote_names=(${(f)"$(_call_program remotes git remote 2>/dev/null)"}) - __git_command_successful || return + __gitex_command_successful || return _wanted remote-names expl remote-name compadd $* - $remote_names } @@ -59,7 +59,7 @@ __gitex_tag_names() { local expl declare -a tag_names tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) - __git_command_successful || return + __gitex_command_successful || return _wanted tag-names expl tag-name compadd $* - $tag_names } @@ -68,7 +68,7 @@ __gitex_branch_names() { local expl declare -a branch_names branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) - __git_command_successful || return + __gitex_command_successful || return _wanted branch-names expl branch-name compadd $* - $branch_names } @@ -76,7 +76,7 @@ __gitex_specific_branch_names() { local expl declare -a branch_names branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/}) - __git_command_successful || return + __gitex_command_successful || return _wanted branch-names expl branch-name compadd - $branch_names } @@ -100,7 +100,7 @@ __gitex_submodule_names() { local expl declare -a submodule_names submodule_names=(${(f)"$(_call_program branchrefs git submodule status | awk '{print $2}')"}) # ' - __git_command_successful || return + __gitex_command_successful || return _wanted submodule-names expl submodule-name compadd $* - $submodule_names } @@ -109,7 +109,7 @@ __gitex_author_names() { local expl declare -a author_names author_names=(${(f)"$(_call_program branchrefs git log --format='%aN' | sort -u)"}) - __git_command_successful || return + __gitex_command_successful || return _wanted author-names expl author-name compadd $* - $author_names } diff --git a/plugins/git-prompt/README.md b/plugins/git-prompt/README.md index 8775af893..05208d72f 100644 --- a/plugins/git-prompt/README.md +++ b/plugins/git-prompt/README.md @@ -45,6 +45,7 @@ The symbols are as follows: | ●n | there are `n` staged files | | ✖n | there are `n` unmerged files | | ✚n | there are `n` unstaged files | +| -n | there are `n` deleted files | | ⚑n | there are `n` stashed changes | | … | there are some untracked files | @@ -59,6 +60,7 @@ The symbols are as follows: ## Customisation - Set the variable `ZSH_THEME_GIT_PROMPT_CACHE` to any value in order to enable caching. +- Set the variable `ZSH_THEME_GIT_SHOW_UPSTREAM` to any value to display the upstream branch. - You may also change a number of variables (whose name start with `ZSH_THEME_GIT_PROMPT_`) to change the appearance of the prompt. Take a look at the bottom of the [plugin file](git-prompt.plugin.zsh)` to see what variables are available. diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 0485e317c..487332028 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -47,12 +47,19 @@ function update_current_git_vars() { GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] GIT_STASHED=$__CURRENT_GIT_STATUS[8] GIT_CLEAN=$__CURRENT_GIT_STATUS[9] + GIT_DELETED=$__CURRENT_GIT_STATUS[10] + + if [ -z ${ZSH_THEME_GIT_SHOW_UPSTREAM+x} ]; then + GIT_UPSTREAM= + else + GIT_UPSTREAM=$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" 2>/dev/null) && GIT_UPSTREAM="${ZSH_THEME_GIT_PROMPT_UPSTREAM_SEPARATOR}${GIT_UPSTREAM}" + fi } git_super_status() { precmd_update_git_vars if [ -n "$__CURRENT_GIT_STATUS" ]; then - STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" + STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH$GIT_UPSTREAM%{${reset_color}%}" if [ "$GIT_BEHIND" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" fi @@ -69,6 +76,9 @@ git_super_status() { if [ "$GIT_CHANGED" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" fi + if [ "$GIT_DELETED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_DELETED$GIT_DELETED%{${reset_color}%}" + fi if [ "$GIT_UNTRACKED" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED$GIT_UNTRACKED%{${reset_color}%}" fi @@ -91,11 +101,13 @@ ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}" ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{●%G%}" ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}" ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}" +ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[blue]%}%{-%G%}" ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}" ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}%{…%G%}" ZSH_THEME_GIT_PROMPT_STASHED="%{$fg_bold[blue]%}%{⚑%G%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}" +ZSH_THEME_GIT_PROMPT_UPSTREAM_SEPARATOR="->" # Set the prompt. RPROMPT='$(git_super_status)' diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index b5c3c9a0c..94774d828 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -44,7 +44,7 @@ if po.returncode != 0: sys.exit(0) # Not a git repository # collect git status information -untracked, staged, changed, conflicts = [], [], [], [] +untracked, staged, changed, deleted, conflicts = [], [], [], [], [] ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: @@ -75,13 +75,15 @@ for st in status: else: if st[1] == 'M': changed.append(st) + if st[1] == 'D': + deleted.append(st) if st[0] == 'U': conflicts.append(st) elif st[0] != ' ': staged.append(st) stashed = get_stash() -if not changed and not staged and not conflicts and not untracked: +if not changed and not deleted and not staged and not conflicts and not untracked: clean = 1 else: clean = 0 @@ -95,6 +97,7 @@ out = ' '.join([ str(len(changed)), str(len(untracked)), str(stashed), - str(clean) + str(clean), + str(len(deleted)) ]) print(out, end='') diff --git a/plugins/git/README.md b/plugins/git/README.md index 050c13d81..d455e0eff 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -10,188 +10,194 @@ plugins=(... git) ## Aliases -| Alias | Command | -|:---------------------|:---------------------------------------------------------------------------------------------------------------------------------| -| g | git | -| ga | git add | -| gaa | git add --all | -| gapa | git add --patch | -| gau | git add --update | -| gav | git add --verbose | -| gap | git apply | -| gapt | git apply --3way | -| gb | git branch | -| gba | git branch -a | -| gbd | git branch -d | -| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*(<span>$</span>(git_main_branch)\|<span>$</span>(git_develop_branch))\s*<span>$</span>)" \| xargs git branch -d 2>/dev/null | -| gbD | git branch -D | -| gbl | git blame -b -w | -| gbnm | git branch --no-merged | -| gbr | git branch --remote | -| gbs | git bisect | -| gbsb | git bisect bad | -| gbsg | git bisect good | -| gbsr | git bisect reset | -| gbss | git bisect start | -| gc | git commit -v | -| gc! | git commit -v --amend | -| gcn! | git commit -v --no-edit --amend | -| gca | git commit -v -a | -| gca! | git commit -v -a --amend | -| gcan! | git commit -v -a --no-edit --amend | -| gcans! | git commit -v -a -s --no-edit --amend | -| gcam | git commit -a -m | -| gcas | git commit -a -s | -| gcasm | git commit -a -s -m | -| gcsm | git commit -s -m | -| gcb | git checkout -b | -| gcf | git config --list | -| gcl | git clone --recurse-submodules | -| gccd | git clone --recurse-submodules "<span>$</span>@" && cd "<span>$</span>(basename <span>$</span>_ .git)" | -| gclean | git clean -id | -| gpristine | git reset --hard && git clean -dffx | -| gcm | git checkout $(git_main_branch) | -| gcd | git checkout $(git_develop_branch) | -| gcmsg | git commit -m | -| gco | git checkout | -| gcor | git checkout --recurse-submodules | -| gcount | git shortlog -sn | -| gcp | git cherry-pick | -| gcpa | git cherry-pick --abort | -| gcpc | git cherry-pick --continue | -| gcs | git commit -S | -| gd | git diff | -| gdca | git diff --cached | -| gdcw | git diff --cached --word-diff | -| gdct | git describe --tags $(git rev-list --tags --max-count=1) | -| gds | git diff --staged | -| gdt | git diff-tree --no-commit-id --name-only -r | -| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock" | -| gdup | git diff @{upstream} | -| gdv | git diff -w $@ \| view - | -| gdw | git diff --word-diff | -| gf | git fetch | -| gfa | git fetch --all --prune | -| gfg | git ls-files \| grep | -| gfo | git fetch origin | -| gg | git gui citool | -| gga | git gui citool --amend | -| ggf | git push --force origin $(current_branch) | -| ggfl | git push --force-with-lease origin $(current_branch) | -| ggl | git pull origin $(current_branch) | -| ggp | git push origin $(current_branch) | -| ggpnp | ggl && ggp | -| ggpull | git pull origin "$(git_current_branch)" | -| ggpur | ggu | -| ggpush | git push origin "$(git_current_branch)" | -| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | -| ggu | git pull --rebase origin $(current_branch) | -| gpsup | git push --set-upstream origin $(git_current_branch) | -| ghh | git help | -| gignore | git update-index --assume-unchanged | -| gignored | git ls-files -v \| grep "^[[:lower:]]" | -| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | -| gk | gitk --all --branches &! | -| gke | gitk --all $(git log -g --pretty=%h) &! | -| gl | git pull | -| glg | git log --stat | -| glgp | git log --stat -p | -| glgg | git log --graph | -| glgga | git log --graph --decorate --all | -| glgm | git log --graph --max-count=10 | -| glo | git log --oneline --decorate | -| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' | -| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat | -| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | -| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | -| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all | -| glog | git log --oneline --decorate --graph | -| gloga | git log --oneline --decorate --graph --all | -| glp | git log --pretty=\<format\> | -| gm | git merge | -| gmom | git merge origin/$(git_main_branch) | -| gmtl | git mergetool --no-prompt | -| gmtlvim | git mergetool --no-prompt --tool=vimdiff | -| gmum | git merge upstream/$(git_main_branch) | -| gma | git merge --abort | -| gp | git push | -| gpd | git push --dry-run | -| gpf | git push --force-with-lease | -| gpf! | git push --force | -| gpoat | git push origin --all && git push origin --tags | -| gpr | git pull --rebase | -| gpu | git push upstream | -| gpv | git push -v | -| gr | git remote | -| gra | git remote add | -| grb | git rebase | -| grba | git rebase --abort | -| grbc | git rebase --continue | -| grbd | git rebase $(git_develop_branch) | -| grbi | git rebase -i | -| grbm | git rebase $(git_main_branch) | -| grbom | git rebase origin/$(git_main_branch) | -| grbo | git rebase --onto | -| grbs | git rebase --skip | -| grev | git revert | -| grh | git reset | -| grhh | git reset --hard | -| groh | git reset origin/$(git_current_branch) --hard | -| grm | git rm | -| grmc | git rm --cached | -| grmv | git remote rename | -| grrm | git remote remove | -| grs | git restore | -| grset | git remote set-url | -| grss | git restore --source | -| grst | git restore --staged | -| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | -| gru | git reset -- | -| grup | git remote update | -| grv | git remote -v | -| gsb | git status -sb | -| gsd | git svn dcommit | -| gsh | git show | -| gsi | git submodule init | -| gsps | git show --pretty=short --show-signature | -| gsr | git svn rebase | -| gss | git status -s | -| gst | git status | -| gsta | git stash push | -| gsta | git stash save | -| gstaa | git stash apply | -| gstc | git stash clear | -| gstd | git stash drop | -| gstl | git stash list | -| gstp | git stash pop | -| gsts | git stash show --text | -| gstu | git stash --include-untracked | -| gstall | git stash --all | -| gsu | git submodule update | -| gsw | git switch | -| gswc | git switch -c | -| gswm | git switch $(git_main_branch) | -| gswd | git switch $(git_develop_branch) | -| gts | git tag -s | -| gtv | git tag \| sort -V | -| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | -| gunignore | git update-index --no-assume-unchanged | -| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | -| gup | git pull --rebase | -| gupv | git pull --rebase -v | -| gupa | git pull --rebase --autostash | -| gupav | git pull --rebase --autostash -v | -| gupom | git pull --rebase origin $(git_main_branch) | -| gupomi | git pull --rebase=interactive origin $(git_main_branch) | -| glum | git pull upstream $(git_main_branch) | -| gluc | git pull upstream $(git_current_branch) | -| gwch | git whatchanged -p --abbrev-commit --pretty=medium | -| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | -| gam | git am | -| gamc | git am --continue | -| gams | git am --skip | -| gama | git am --abort | -| gamscp | git am --show-current-patch | +| Alias | Command | +| :------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| g | git | +| ga | git add | +| gaa | git add --all | +| gapa | git add --patch | +| gau | git add --update | +| gav | git add --verbose | +| gap | git apply | +| gapt | git apply --3way | +| gb | git branch | +| gba | git branch --all | +| gbd | git branch --delete | +| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*(<span>$</span>(git_main_branch)\|<span>$</span>(git_develop_branch))\s*<span>$</span>)" \| xargs git branch --delete 2>/dev/null | +| gbD | git branch --delete --force | +| gbl | git blame -b -w | +| gbnm | git branch --no-merged | +| gbr | git branch --remote | +| gbs | git bisect | +| gbsb | git bisect bad | +| gbsg | git bisect good | +| gbsr | git bisect reset | +| gbss | git bisect start | +| gc | git commit --verbose | +| gc! | git commit --verbose --amend | +| gcn! | git commit --verbose --no-edit --amend | +| gca | git commit --verbose --all | +| gca! | git commit --verbose --all --amend | +| gcan! | git commit --verbose --all --no-edit --amend | +| gcans! | git commit --verbose --all --signoff --no-edit --amend | +| gcam | git commit --all --message | +| gcas | git commit --all --signoff | +| gcasm | git commit --all --signoff --message | +| gcsm | git commit --signoff --message | +| gcb | git checkout -b | +| gcf | git config --list | +| gcl | git clone --recurse-submodules | +| gccd | git clone --recurse-submodules "<span>$</span>@" && cd "<span>$</span>(basename <span>$</span>\_ .git)" | +| gclean | git clean --interactive -d | +| gpristine | git reset --hard && git clean -dffx | +| gcm | git checkout $(git_main_branch) | +| gcd | git checkout $(git_develop_branch) | +| gcmsg | git commit --message | +| gco | git checkout | +| gcor | git checkout --recurse-submodules | +| gcount | git shortlog --summary -n | +| gcp | git cherry-pick | +| gcpa | git cherry-pick --abort | +| gcpc | git cherry-pick --continue | +| gcs | git commit -S | +| gcss | git commit -S -s | +| gcssm | git commit -S -s -m | +| gd | git diff | +| gdca | git diff --cached | +| gdcw | git diff --cached --word-diff | +| gdct | git describe --tags $(git rev-list --tags --max-count=1) | +| gds | git diff --staged | +| gdt | git diff-tree --no-commit-id --name-only -r | +| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock" | +| gdup | git diff @{upstream} | +| gdv | git diff -w $@ \| view - | +| gdw | git diff --word-diff | +| gf | git fetch | +| gfa | git fetch --all --prune | +| gfg | git ls-files \| grep | +| gfo | git fetch origin | +| gg | git gui citool | +| gga | git gui citool --amend | +| ggf | git push --force origin $(current_branch) | +| ggfl | git push --force-with-lease origin $(current_branch) | +| ggl | git pull origin $(current_branch) | +| ggp | git push origin $(current_branch) | +| ggpnp | ggl && ggp | +| ggpull | git pull origin "$(git_current_branch)" | +| ggpur | ggu | +| ggpush | git push origin "$(git_current_branch)" | +| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | +| ggu | git pull --rebase origin $(current_branch) | +| gpsup | git push --set-upstream origin $(git_current_branch) | +| ghh | git help | +| gignore | git update-index --assume-unchanged | +| gignored | git ls-files -v \| grep "^[[:lower:]]" | +| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | +| gk | gitk --all --branches &! | +| gke | gitk --all $(git log --walk-reflogs --pretty=%h) &! | +| gl | git pull | +| glg | git log --stat | +| glgp | git log --stat --patch | +| glgg | git log --graph | +| glgga | git log --graph --decorate --all | +| glgm | git log --graph --max-count=10 | +| glo | git log --oneline --decorate | +| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' | +| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat | +| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | +| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | +| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all | +| glog | git log --oneline --decorate --graph | +| gloga | git log --oneline --decorate --graph --all | +| glp | git log --pretty=\<format\> | +| gm | git merge | +| gmom | git merge origin/$(git_main_branch) | +| gmtl | git mergetool --no-prompt | +| gmtlvim | git mergetool --no-prompt --tool=vimdiff | +| gmum | git merge upstream/$(git_main_branch) | +| gma | git merge --abort | +| gp | git push | +| gpd | git push --dry-run | +| gpf | git push --force-with-lease | +| gpf! | git push --force | +| gpoat | git push origin --all && git push origin --tags | +| gpr | git pull --rebase | +| gpu | git push upstream | +| gpv | git push --verbose | +| gr | git remote | +| gra | git remote add | +| grb | git rebase | +| grba | git rebase --abort | +| grbc | git rebase --continue | +| grbd | git rebase $(git_develop_branch) | +| grbi | git rebase --interactive | +| grbm | git rebase $(git_main_branch) | +| grbom | git rebase origin/$(git_main_branch) | +| grbo | git rebase --onto | +| grbs | git rebase --skip | +| grev | git revert | +| grh | git reset | +| grhh | git reset --hard | +| groh | git reset origin/$(git_current_branch) --hard | +| grm | git rm | +| grmc | git rm --cached | +| grmv | git remote rename | +| grrm | git remote remove | +| grs | git restore | +| grset | git remote set-url | +| grss | git restore --source | +| grst | git restore --staged | +| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | +| gru | git reset -- | +| grup | git remote update | +| grv | git remote --verbose | +| gsb | git status --short -b | +| gsd | git svn dcommit | +| gsh | git show | +| gsi | git submodule init | +| gsps | git show --pretty=short --show-signature | +| gsr | git svn rebase | +| gss | git status --short | +| gst | git status | +| gsta | git stash push (git version >= 2.13) | +| gsta | git stash save (git version < 2.13) | +| gstaa | git stash apply | +| gstc | git stash clear | +| gstd | git stash drop | +| gstl | git stash list | +| gstp | git stash pop | +| gsts | git stash show --text | +| gstu | git stash --include-untracked | +| gstall | git stash --all | +| gsu | git submodule update | +| gsw | git switch | +| gswc | git switch -c | +| gswm | git switch $(git_main_branch) | +| gswd | git switch $(git_develop_branch) | +| gts | git tag -s | +| gtv | git tag \| sort -V | +| gtl | gtl(){ git tag --sort=-v:refname -n --list ${1}\* }; noglob gtl | +| gunignore | git update-index --no-assume-unchanged | +| gunwip | git log --max-count=1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | +| gup | git pull --rebase | +| gupv | git pull --rebase --verbose | +| gupa | git pull --rebase --autostash | +| gupav | git pull --rebase --autostash --verbose | +| gupom | git pull --rebase origin $(git_main_branch) | +| gupomi | git pull --rebase=interactive origin $(git_main_branch) | +| glum | git pull upstream $(git_main_branch) | +| gluc | git pull upstream $(git_current_branch) | +| gwch | git whatchanged -p --abbrev-commit --pretty=medium | +| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]" | +| gam | git am | +| gamc | git am --continue | +| gams | git am --skip | +| gama | git am --abort | +| gamscp | git am --show-current-patch | +| gwt | git worktree | +| gwtls | git worktree list | +| gwtmv | git worktree move | +| gwtrm | git worktree remove | ### Main branch preference @@ -223,7 +229,7 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa ### Current | Command | Description | -|:-----------------------|:---------------------------------------------------------------------------------------------------------| +| :--------------------- | :------------------------------------------------------------------------------------------------------- | | `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote | | current_branch | Return the name of the current branch | | git_current_user_name | Returns the `user.name` config value | @@ -236,13 +242,13 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it. | Command | Description | -|:-----------------|:------------------------------------------------| +| :--------------- | :---------------------------------------------- | | work_in_progress | Echoes a warning if the current branch is a wip | | gwip | Commit wip branch | | gunwip | Uncommit wip branch | ### Deprecated functions -| Command | Description | Reason | -|:-----------------------|:----------------------------------------|:----------------------------------------------------------------| -| current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) | +| Command | Description | Reason | +| :----------------- | :-------------------------------------- | :-------------------------------------------------------------- | +| current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 5c0e6db2c..7544ca440 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -31,7 +31,7 @@ function work_in_progress() { function git_main_branch() { command git rev-parse --git-dir &>/dev/null || return local ref - for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk}; do + for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do if command git show-ref -q --verify $ref; then echo ${ref:t} return @@ -69,10 +69,10 @@ alias gap='git apply' alias gapt='git apply --3way' alias gb='git branch' -alias gba='git branch -a' -alias gbd='git branch -d' -alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch -d 2>/dev/null' -alias gbD='git branch -D' +alias gba='git branch --all' +alias gbd='git branch --delete' +alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null' +alias gbD='git branch --delete --force' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' alias gbr='git branch --remote' @@ -82,17 +82,17 @@ alias gbsg='git bisect good' alias gbsr='git bisect reset' alias gbss='git bisect start' -alias gc='git commit -v' -alias gc!='git commit -v --amend' -alias gcn!='git commit -v --no-edit --amend' -alias gca='git commit -v -a' -alias gca!='git commit -v -a --amend' -alias gcan!='git commit -v -a --no-edit --amend' -alias gcans!='git commit -v -a -s --no-edit --amend' -alias gcam='git commit -a -m' -alias gcsm='git commit -s -m' -alias gcas='git commit -a -s' -alias gcasm='git commit -a -s -m' +alias gc='git commit --verbose' +alias gc!='git commit --verbose --amend' +alias gcn!='git commit --verbose --no-edit --amend' +alias gca='git commit --verbose --all' +alias gca!='git commit --verbose --all --amend' +alias gcan!='git commit --verbose --all --no-edit --amend' +alias gcans!='git commit --verbose --all --signoff --no-edit --amend' +alias gcam='git commit --all --message' +alias gcsm='git commit --signoff --message' +alias gcas='git commit --all --signoff' +alias gcasm='git commit --all --signoff --message' alias gcb='git checkout -b' alias gcf='git config --list' @@ -103,20 +103,20 @@ function gccd() { compdef _git gccd=git-clone alias gcl='git clone --recurse-submodules' -alias gclean='git clean -id' -alias gpristine='git reset --hard && git clean -dffx' +alias gclean='git clean --interactive -d' +alias gpristine='git reset --hard && git clean --force -dx' alias gcm='git checkout $(git_main_branch)' alias gcd='git checkout $(git_develop_branch)' -alias gcmsg='git commit -m' +alias gcmsg='git commit --message' alias gco='git checkout' alias gcor='git checkout --recurse-submodules' -alias gcount='git shortlog -sn' +alias gcount='git shortlog --summary --numbered' alias gcp='git cherry-pick' alias gcpa='git cherry-pick --abort' alias gcpc='git cherry-pick --continue' -alias gcs='git commit -S' -alias gcss='git commit -S -s' -alias gcssm='git commit -S -s -m' +alias gcs='git commit --gpg-sign' +alias gcss='git commit --gpg-sign --signoff' +alias gcssm='git commit --gpg-sign --signoff --message' alias gd='git diff' alias gdca='git diff --cached' @@ -207,11 +207,11 @@ alias gignored='git ls-files -v | grep "^[[:lower:]]"' alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' alias gk='\gitk --all --branches &!' -alias gke='\gitk --all $(git log -g --pretty=%h) &!' +alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!' alias gl='git pull' alias glg='git log --stat' -alias glgp='git log --stat -p' +alias glgp='git log --stat --patch' alias glgg='git log --graph' alias glgga='git log --graph --decorate --all' alias glgm='git log --graph --max-count=10' @@ -239,7 +239,7 @@ alias gpf!='git push --force' alias gpoat='git push origin --all && git push origin --tags' alias gpr='git pull --rebase' alias gpu='git push upstream' -alias gpv='git push -v' +alias gpv='git push --verbose' alias gr='git remote' alias gra='git remote add' @@ -247,7 +247,7 @@ alias grb='git rebase' alias grba='git rebase --abort' alias grbc='git rebase --continue' alias grbd='git rebase $(git_develop_branch)' -alias grbi='git rebase -i' +alias grbi='git rebase --interactive' alias grbm='git rebase $(git_main_branch)' alias grbom='git rebase origin/$(git_main_branch)' alias grbo='git rebase --onto' @@ -267,15 +267,15 @@ alias grst='git restore --staged' alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' alias gru='git reset --' alias grup='git remote update' -alias grv='git remote -v' +alias grv='git remote --verbose' -alias gsb='git status -sb' +alias gsb='git status --short --branch' alias gsd='git svn dcommit' alias gsh='git show' alias gsi='git submodule init' alias gsps='git show --pretty=short --show-signature' alias gsr='git svn rebase' -alias gss='git status -s' +alias gss='git status --short' alias gst='git status' # use the default stash push on git 2.13 and newer @@ -293,27 +293,33 @@ alias gstu='gsta --include-untracked' alias gstall='git stash --all' alias gsu='git submodule update' alias gsw='git switch' -alias gswc='git switch -c' +alias gswc='git switch --create' alias gswm='git switch $(git_main_branch)' alias gswd='git switch $(git_develop_branch)' -alias gts='git tag -s' +alias gts='git tag --sign' alias gtv='git tag | sort -V' -alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl' +alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl' alias gunignore='git update-index --no-assume-unchanged' -alias gunwip='git log -n 1 | grep -q -c "--wip--" && git reset HEAD~1' +alias gunwip='git log --max-count=1 | grep -q -c "\--wip--" && git reset HEAD~1' alias gup='git pull --rebase' -alias gupv='git pull --rebase -v' +alias gupv='git pull --rebase --verbose' alias gupa='git pull --rebase --autostash' -alias gupav='git pull --rebase --autostash -v' +alias gupav='git pull --rebase --autostash --verbose' alias gupom='git pull --rebase origin $(git_main_branch)' alias gupomi='git pull --rebase=interactive origin $(git_main_branch)' alias glum='git pull upstream $(git_main_branch)' alias gluc='git pull upstream $(git_current_branch)' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' -alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' +alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' + +alias gwt='git worktree' +alias gwta='git worktree add' +alias gwtls='git worktree list' +alias gwtmv='git worktree move' +alias gwtrm='git worktree remove' alias gam='git am' alias gamc='git am --continue' @@ -335,4 +341,4 @@ function grename() { fi } -unset git_version +unset git_version
\ No newline at end of file diff --git a/plugins/golang/README.md b/plugins/golang/README.md index 3b7d1e19f..128cc7fbb 100644 --- a/plugins/golang/README.md +++ b/plugins/golang/README.md @@ -16,11 +16,12 @@ plugins=(... golang) | gob | `go build` | Build your code | | goc | `go clean` | Removes object files from package source directories | | god | `go doc` | Prints documentation comments | +| goe | `go env` | Prints Go environment information | | gof | `go fmt` | Gofmt formats (aligns and indents) Go programs. | | gofa | `go fmt ./...` | Run go fmt for all packages in current directory, recursively | | gofx | `go fix` | Update packages to use a new API | | gog | `go get` | Downloads packages and then installs them to $GOPATH | -| gog | `go get ./...` | Installs all dependencies in current directory, recursively | +| goga | `go get ./...` | Installs all dependencies in current directory, recursively | | goi | `go install` | Compiles and installs packages to $GOPATH | | gol | `go list` | Lists Go packages | | gom | `go mod` | Access to operations on modules | @@ -35,4 +36,5 @@ plugins=(... golang) | gotod | `go tool dist` | Utility to bootstrap, build and test go runtime | | gotofx | `go tool fix` | Fixes an application to use newer features | | gov | `go vet` | Vet examines Go source code and reports suspicious constructs | +| gove | `go version` | Prints Go version | | gow | `go work` | Work provides access to operations on workspaces | diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 0dbaab069..45ccd3a1c 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -13,6 +13,7 @@ unset p alias gob='go build' alias goc='go clean' alias god='go doc' +alias goe='go env' alias gof='go fmt' alias gofa='go fmt ./...' alias gofx='go fix' @@ -32,4 +33,5 @@ alias gotoc='go tool compile' alias gotod='go tool dist' alias gotofx='go tool fix' alias gov='go vet' +alias gove='go version' alias gow='go work' diff --git a/plugins/hasura/README.md b/plugins/hasura/README.md new file mode 100644 index 000000000..d7db9ed92 --- /dev/null +++ b/plugins/hasura/README.md @@ -0,0 +1,9 @@ +# Hasura plugin + +This plugin adds completion for [the Hasura CLI](https://hasura.io/docs/latest/hasura-cli/index/). + +To use it, add `hasura` to the plugins array in your zshrc file: + +```zsh +plugins=(... hasura) +``` diff --git a/plugins/hasura/hasura.plugin.zsh b/plugins/hasura/hasura.plugin.zsh new file mode 100644 index 000000000..18254c43b --- /dev/null +++ b/plugins/hasura/hasura.plugin.zsh @@ -0,0 +1,13 @@ +if (( ! $+commands[hasura] )); then + return +fi + +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background +if [[ ! -f "$ZSH_CACHE_DIR/completions/_hasura" ]]; then + hasura completion zsh --file "$ZSH_CACHE_DIR/completions/_hasura" >/dev/null + source "$ZSH_CACHE_DIR/completions/_hasura" +else + source "$ZSH_CACHE_DIR/completions/_hasura" + hasura completion zsh --file "$ZSH_CACHE_DIR/completions/_hasura" >/dev/null &| +fi diff --git a/plugins/helm/README.md b/plugins/helm/README.md index 49844c78f..8be024bfb 100644 --- a/plugins/helm/README.md +++ b/plugins/helm/README.md @@ -1,9 +1,18 @@ # Helm plugin -This plugin adds completion for [Helm](https://helm.sh/), the Kubernetes package manager. +This plugin adds completion and aliases for [Helm](https://helm.sh/), the Kubernetes package manager. To use it, add `helm` to the plugins array in your zshrc file: ```zsh plugins=(... helm) ``` + +## Aliases + +| Alias | Full command | +| ----- | ------------ | +| h | helm | +| hin | helm install | +| hse | helm search | +| hup | helm upgrade | diff --git a/plugins/helm/helm.plugin.zsh b/plugins/helm/helm.plugin.zsh index 151c43d88..7fc05be98 100644 --- a/plugins/helm/helm.plugin.zsh +++ b/plugins/helm/helm.plugin.zsh @@ -11,3 +11,8 @@ else source "$ZSH_CACHE_DIR/completions/_helm" helm completion zsh | tee "$ZSH_CACHE_DIR/completions/_helm" >/dev/null &| fi + +alias h='helm' +alias hin='helm install' +alias hse='helm search' +alias hup='helm upgrade' diff --git a/plugins/heroku-alias/README.md b/plugins/heroku-alias/README.md new file mode 100644 index 000000000..4b7b953fd --- /dev/null +++ b/plugins/heroku-alias/README.md @@ -0,0 +1,127 @@ +# heroku-alias +🧬 Full alias for heroku cli + +|🚀 last maj|📡 source| +|---|---| +|02/06/2020|[heroku cli doc](https://devcenter.heroku.com/articles/heroku-cli-commands)| + +# Alias list + +## general +| Alias | Command | +| ------------- | ------------- | +| h | heroku | +| hauto | heroku autocomplete $(echo $SHELL) | +| hl | heroku local | + +## config +| Alias | Command | +| ------------- | ------------- | +| hc | heroku config | +| hca | heroku config -a | +| hcr | heroku config -r | +| hcs | heroku config:set | +| hcu | heroku config:unset | +| hcfile | function hcfile bellow | + +```sh +hcfile() { + echo " Which platform [-r/a name] ? " + read platform + echo " Which file ? " + read file + while read line; + do heroku config:set "$platform" "$line"; + done < "$file" +} +``` + +## apps and favorites +| Alias | Command | +| ------------- | ------------- | +| ha | heroku apps | +| hpop | heroku create | +| hkill | heroku apps:destroy | +| hlog | heroku apps:errors | +| hfav | heroku apps:favorites | +| hfava | heroku apps:favorites:add | +| hfavr | heroku apps:favorites:remove | +| hai | heroku apps:info | +| hair | heroku apps:info -r | +| haia | heroku apps:info -a | + +# auth +| Alias | Command | +| ------------- | ------------- | +| h2fa | heroku auth:2fa | +| h2far | heroku auth:2fa:disable | + +# access +| Alias | Command | +| ------------- | ------------- | +| hac | heroku access | +| hacr | heroku access -r | +| haca | heroku access -a | +| hadd | heroku access:add | +| hdel | heroku access:remove | +| hup | heroku access:update | + +## addons +| Alias | Command | +| ------------- | ------------- | +| hads | heroku addons -A | +| hada | heroku addons -a | +| hadr | heroku addons -r | +| hadat | heroku addons:attach | +| hadc | heroku addons:create | +| hadel | heroku addons:destroy | +| hadde | heroku addons:detach | +| hadoc | heroku addons:docs | + +## login +| Alias | Command | +| ------------- | ------------- | +| hin | heroku login | +| hout | heroku logout | +| hi | heroku login -i | +| hwho | heroku auth:whoami | + +## authorizations +| Alias | Command | +| ------------- | ------------- | +| hth | heroku authorizations | +| hthadd | heroku authorizations:create | +| hthif | heroku authorizations:info | +| hthdel | heroku authorizations:revoke | +| hthrot | heroku authorizations:rotate | +| hthup | heroku authorizations:update | + +## plugins +| Alias | Command | +| ------------- | ------------- | +| hp | heroku plugins | + +# log +| Alias | Command | +| ------------- | ------------- | +|hg | heroku logs| +| hgt | heroku log tail | + +# database +| Alias | Command | +| ------------- | ------------- | +| hpg | heroku pg | +| hpsql | heroku pg:psql | +| hpb | heroku pg:backups | +| hpbc | heroku pg:backups:capture | +| hpbd | heroku pg:backups:download | +| hpbr | heroku pg:backups:restore | + +# certs +| Alias | Command | +| ------------- | ------------- | +| hssl | heroku certs | +| hssli | heroku certs:info | +| hssla | heroku certs:add | +| hsslu | heroku certs:update | +| hsslr | heroku certs:remove | diff --git a/plugins/heroku-alias/heroku.alias.sh b/plugins/heroku-alias/heroku.alias.sh new file mode 100644 index 000000000..7daf715b5 --- /dev/null +++ b/plugins/heroku-alias/heroku.alias.sh @@ -0,0 +1,92 @@ +# general +alias h='heroku' +alias hauto='heroku autocomplete $(echo $SHELL)' +alias hl='heroku local' + +# log +alias hg='heroku logs' +alias hgt='heroku log tail' + +# database +alias hpg='heroku pg' +alias hpsql='heroku pg:psql' +alias hpb='heroku pg:backups' +alias hpbc='heroku pg:backups:capture' +alias hpbd='heroku pg:backups:download' +alias hpbr='heroku pg:backups:restore' + +# config +alias hc='heroku config' +alias hca='heroku config -a' +alias hcr='heroku config -r' +alias hcs='heroku config:set' +alias hcu='heroku config:unset' + +# this function allow to load multi env set in a file +hcfile() { + echo 'Which platform [-r/a name] ?' + read platform + echo 'Which file ?' + read file + while read line; + do heroku config:set "$platform" "$line"; + done < "$file" +} + +# apps and favorites +alias ha='heroku apps' +alias hpop='heroku create' +alias hkill='heroku apps:destroy' +alias hlog='heroku apps:errors' +alias hfav='heroku apps:favorites' +alias hfava='heroku apps:favorites:add' +alias hfavr='heroku apps:favorites:remove' +alias hai='heroku apps:info' +alias hair='heroku apps:info -r' +alias haia='heroku apps:info -a' + +# auth +alias h2fa='heroku auth:2fa' +alias h2far='heroku auth:2fa:disable' + +# access +alias hac='heroku access' +alias hacr='heroku access -r' +alias haca='heroku access -a' +alias hadd='heroku access:add' +alias hdel='heroku access:remove' +alias hup='heroku access:update' + +# addons +alias hads='heroku addons -A' +alias hada='heroku addons -a' +alias hadr='heroku addons -r' +alias hadat='heroku addons:attach' +alias hadc='heroku addons:create' +alias hadel='heroku addons:destroy' +alias hadde='heroku addons:detach' +alias hadoc='heroku addons:docs' + +# login +alias hin='heroku login' +alias hout='heroku logout' +alias hi='heroku login -i' +alias hwho='heroku auth:whoami' + +# authorizations +alias hth='heroku authorizations' +alias hthadd='heroku authorizations:create' +alias hthif='heroku authorizations:info' +alias hthdel='heroku authorizations:revoke' +alias hthrot='heroku authorizations:rotate' +alias hthup='heroku authorizations:update' + +# plugins +alias hp='heroku plugins' + +# cert +alias hssl='heroku certs' +alias hssli='heroku certs:info' +alias hssla='heroku certs:add' +alias hsslu='heroku certs:update' +alias hsslr='heroku certs:remove' diff --git a/plugins/jira/README.md b/plugins/jira/README.md index a5633af77..d78ea15a4 100644 --- a/plugins/jira/README.md +++ b/plugins/jira/README.md @@ -14,22 +14,31 @@ In this document, "JIRA" refers to the JIRA issue tracking server, and `jira` re This plugin supplies one command, `jira`, through which all its features are exposed. Most forms of this command open a JIRA page in your web browser. -``` -jira # performs the default action - -jira new # opens a new issue -jira dashboard # opens your JIRA dashboard -jira tempo # opens your JIRA Tempo -jira reported [username] # queries for issues reported by a user -jira assigned [username] # queries for issues assigned to a user -jira myissues # queries for you own issues -jira branch # opens an existing issue matching the current branch name - # The branch name may have prefixes ending in "/": "feature/MP-1234", - # and also suffixes starting with "_": "MP-1234_fix_dashboard" - # In both these cases, the issue opened will be "MP-1234" -jira ABC-123 # opens an existing issue -jira ABC-123 m # opens an existing issue for adding a comment -``` +## Commands + +| Command | Description | +| :------------ | :-------------------------------------------------------- | +| `jira` | Performs the default action | +| `jira new` | Opens a new Jira issue dialogue | +| `jira ABC-123` | Opens an existing issue | +| `jira ABC-123 m` | Opens an existing issue for adding a comment | +| `jira dashboard [rapid_view]` | # opens your JIRA dashboard | +| `jira mine` | Queries for your own issues | +| `jira tempo` | Opens your JIRA Tempo | +| `jira reported [username]` | Queries for issues reported by a user | +| `jira assigned [username]` | Queries for issues assigned to a user | +| `jira branch` | Opens an existing issue matching the current branch name | + + +### Jira Branch usage notes + +The branch name may have prefixes ending in "/": "feature/MP-1234", and also suffixes +starting with "_": "MP-1234_fix_dashboard". In both these cases, the issue opened will be "MP-1234" + +This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234", +"mp-1234" opens the issue "mp-1234", and "1234" opens the issue "MP-1234". + + #### Debugging usage #### @@ -62,7 +71,9 @@ echo "https://jira.atlassian.com" >> .jira-url * `$JIRA_NAME` - Your JIRA username; used as the default user for `assigned`/`reported` searches * `$JIRA_PREFIX` - Prefix added to issue ID arguments * `$JIRA_RAPID_BOARD` - Set to `true` if you use Rapid Board +* `$JIRA_RAPID_VIEW` - Set the default rapid view; it doesn't work if `$JIRA_RAPID_BOARD` is set to false * `$JIRA_DEFAULT_ACTION` - Action to do when `jira` is called with no arguments; defaults to "new" +* `$JIRA_TEMPO_PATH` - Your JIRA tempo url path; defaults to "/secure/Tempo.jspa" ### Browser ### diff --git a/plugins/jira/_jira b/plugins/jira/_jira index 1ac3eeda3..0e37b7e9d 100644 --- a/plugins/jira/_jira +++ b/plugins/jira/_jira @@ -4,6 +4,7 @@ local -a _1st_arguments _1st_arguments=( 'new:create a new issue' + 'mine:open my issues' 'dashboard:open the dashboard' 'tempo:open the tempo' 'reported:search for issues reported by a user' diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 22807e0ae..e789fce92 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -44,25 +44,31 @@ function jira() { open_command "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then _jira_query ${@:-$action} - elif [[ "$action" == "myissues" ]]; then + elif [[ "$action" == "mine" ]]; then echo "Opening my issues" open_command "${jira_url}/issues/?filter=-1" elif [[ "$action" == "dashboard" ]]; then echo "Opening dashboard" if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - open_command "${jira_url}/secure/RapidBoard.jspa" + _jira_rapid_board ${@} else open_command "${jira_url}/secure/Dashboard.jspa" fi elif [[ "$action" == "tempo" ]]; then echo "Opening tempo" - open_command "${jira_url}/secure/Tempo.jspa" + if [[ -n "$JIRA_TEMPO_PATH" ]]; then + open_command "${jira_url}${JIRA_TEMPO_PATH}" + else + open_command "${jira_url}/secure/Tempo.jspa" + fi elif [[ "$action" == "dumpconfig" ]]; then echo "JIRA_URL=$jira_url" echo "JIRA_PREFIX=$jira_prefix" echo "JIRA_NAME=$JIRA_NAME" + echo "JIRA_RAPID_VIEW=$JIRA_RAPID_VIEW" echo "JIRA_RAPID_BOARD=$JIRA_RAPID_BOARD" echo "JIRA_DEFAULT_ACTION=$JIRA_DEFAULT_ACTION" + echo "JIRA_TEMPO_PATH=$JIRA_TEMPO_PATH" else # Anything that doesn't match a special action is considered an issue name # but `branch` is a special case that will parse the current git branch @@ -75,7 +81,7 @@ function jira() { # Strip suffixes starting with _ issue_arg=(${(s:_:)issue_arg}) issue_arg=${issue_arg[1]} - if [[ "$issue_arg" = ${jira_prefix}* ]]; then + if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then issue="${issue_arg}" else issue="${jira_prefix}${issue_arg}" @@ -107,6 +113,16 @@ Valid options, in order of precedence: EOF } +function _jira_rapid_board() { + rapid_view=${2:=$JIRA_RAPID_VIEW} + + if [[ -z $rapid_view ]]; then + open_command "${jira_url}/secure/RapidBoard.jspa" + else + open_command "${jira_url}/secure/RapidBoard.jspa?rapidView=$rapid_view" + fi +} + function _jira_query() { emulate -L zsh local verb="$1" diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 095d2b328..315d3ce93 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -1,15 +1,17 @@ -if (( $+commands[kubectl] )); then - # If the completion file does not exist, generate it and then source it - # Otherwise, source it and regenerate in the background - if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then - kubectl completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubectl" >/dev/null - source "$ZSH_CACHE_DIR/completions/_kubectl" - else - source "$ZSH_CACHE_DIR/completions/_kubectl" - kubectl completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubectl" >/dev/null &| - fi +if (( ! $+commands[kubectl] )); then + return fi +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `kubectl`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then + typeset -g -A _comps + autoload -Uz _kubectl + _comps[kubectl]=_kubectl +fi + +kubectl completion zsh 2> /dev/null >| "$ZSH_CACHE_DIR/completions/_kubectl" &| + # This command is used a LOT both below and in daily life alias k=kubectl diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index 905a02a70..684972cc1 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -9,7 +9,7 @@ chpwd_last_working_dir() { [[ "$ZSH_SUBSHELL" -eq 0 ]] || return 0 # Add ".$SSH_USER" suffix to cache file if $SSH_USER is set and non-empty local cache_file="$ZSH_CACHE_DIR/last-working-dir${SSH_USER:+.$SSH_USER}" - pwd >| "$cache_file" + builtin pwd >| "$cache_file" } # Changes directory to the last working directory diff --git a/plugins/lol/README.md b/plugins/lol/README.md index ea6b0c3b8..b45513b35 100644 --- a/plugins/lol/README.md +++ b/plugins/lol/README.md @@ -49,7 +49,7 @@ plugins=(... lol) | `violenz` | `git rebase` | | `visible` | `echo` | | `wtf` | `dmesg` | -| `yolo` | `git commit -m "$(curl -s http://whatthecommit.com/index.txt)"` | +| `yolo` | `git commit -m "$(curl -s https://whatthecommit.com/index.txt)"` | ## Usage Examples @@ -66,6 +66,6 @@ nowai u=r,go= some.file # ssh root@catserver.org pwned root@catserver.org -# git commit -m "$(curl -s http://whatthecommit.com/index.txt)" +# git commit -m "$(curl -s https://whatthecommit.com/index.txt)" yolo ``` diff --git a/plugins/lol/lol.plugin.zsh b/plugins/lol/lol.plugin.zsh index 3c30259a1..585f96e4f 100644 --- a/plugins/lol/lol.plugin.zsh +++ b/plugins/lol/lol.plugin.zsh @@ -45,7 +45,7 @@ alias bringz='git pull' alias chicken='git add' alias oanward='git commit -m' alias ooanward='git commit -am' -alias yolo='git commit -m "$(curl -s http://whatthecommit.com/index.txt)"' +alias yolo='git commit -m "$(curl -s https://whatthecommit.com/index.txt)"' alias letcat='git checkout' alias violenz='git rebase' diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index b540eecb5..e4d759dcf 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -224,8 +224,9 @@ function quick-look() { } function man-preview() { + local location # Don't let Preview.app steal focus if the man page doesn't exist - man -w "$@" &>/dev/null && man -t "$@" | open -f -a Preview || man "$@" + location=$(man -w "$@") && mandoc -Tpdf $location | open -f -a Preview } compdef _man man-preview diff --git a/plugins/mongo-atlas/README.md b/plugins/mongo-atlas/README.md new file mode 100644 index 000000000..ef1b5e0d2 --- /dev/null +++ b/plugins/mongo-atlas/README.md @@ -0,0 +1,10 @@ +# MongoDB Atlas plugin + +This plugin adds completion for [Atlas](https://www.mongodb.com/docs/atlas/cli/stable/) a command line interface built specifically for +MongoDB Atlas. + +To use it, add `mongo-atlas` to the plugins array in your zshrc file: + +```zsh +plugins=(... mongo-atlas) +``` diff --git a/plugins/mongo-atlas/mongo-atlas.plugin.zsh b/plugins/mongo-atlas/mongo-atlas.plugin.zsh new file mode 100644 index 000000000..6762c909e --- /dev/null +++ b/plugins/mongo-atlas/mongo-atlas.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for the Mongo Atlas CLI (atlas). +if (( ! $+commands[atlas] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `atlas`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_atlas" ]]; then + typeset -g -A _comps + autoload -Uz _atlas + _comps[atlas]=_atlas +fi + +atlas completion zsh >| "$ZSH_CACHE_DIR/completions/atlas" &| diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index 1b9141f21..da51f74df 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -196,7 +196,7 @@ function listMavenCompletions { # spring-boot spring-boot:run spring-boot:repackage # quarkus - quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help + quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:remove-extension quarkus:remove-extensions quarkus:generate-config quarkus:help # exec exec:exec exec:java # versions @@ -283,9 +283,11 @@ function listMavenCompletions { toolchain:toolchain #liberty liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature + # vaadin + vaadin:prepare-frontend vaadin:build-frontend vaadin:clean-frontend vaadin:dance # options - "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile=" + "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile=" "-Dextensions=" # arguments -am --also-make diff --git a/plugins/nsc/README.md b/plugins/nsc/README.md new file mode 100644 index 000000000..ce0d2c15c --- /dev/null +++ b/plugins/nsc/README.md @@ -0,0 +1,11 @@ +# NSC plugin + +This plugin adds completion for the [NSC](https://github.com/nats-io/nsc). + +To use it, add `nsc` to the plugins array in your zshrc file: + +```zsh +plugins=(... nsc) +``` + +This plugin does not add any aliases. diff --git a/plugins/nsc/nsc.plugin.zsh b/plugins/nsc/nsc.plugin.zsh new file mode 100644 index 000000000..daa599e8f --- /dev/null +++ b/plugins/nsc/nsc.plugin.zsh @@ -0,0 +1,13 @@ +if (( ! $+commands[nsc] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `nsc`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_nsc" ]]; then + typeset -g -A _comps + autoload -Uz _nsc + _comps[nsc]=_nsc +fi + +nsc completion zsh >| "$ZSH_CACHE_DIR/completions/_nsc" &| diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index 1acf12050..d3fd980be 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -1,7 +1,7 @@ # nvm plugin -This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager. -It also automatically sources nvm, so you don't need to do it manually in your `.zshrc`. +This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager. It also +automatically sources nvm, so you don't need to do it manually in your `.zshrc`. To use it, add `nvm` to the plugins array of your zshrc file: @@ -21,14 +21,40 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced: [Homebrew is installed in `/opt/homebrew`](https://docs.brew.sh/Installation). To get the directory where nvm has been installed, regardless of chip architecture, use `NVM_HOMEBREW=$(brew --prefix nvm)`. -- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session, - set `NVM_LAZY` to `1`. This will source nvm script only when using it, and will create a function for `node`, - `npm`, `pnpm`, `yarn`, and the command(s) specified by `NVM_LAZY_CMD`, so when you call either of them, - nvm will be loaded and run with default version. +## Customization -- **`NVM_LAZY_CMD`**: if you want additional command(s) to trigger lazy loading of nvm, set `NVM_LAZY_CMD` to - the command or an array of the commands. +#### Lazy startup -- **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when - if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating - which node version to load. +This option will help you to defer nvm's load until you use it to speed-up your zsh startup. This will source +nvm script only when using it, and will create a function for `node`, `npm`, `pnpm`, `yarn`, and the +command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run with +default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced: + +```zsh +zstyle ':omz:plugins:nvm' lazy yes +``` + +Then, to define extra commands that will also trigger nvm load, you can use a similar syntax, adding as many +as you want: + +```zsh +zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ... +``` + +#### `.nvmrc` autoload + +If set, the plugin will automatically load a node version when if finds a +[`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node +version to load. This can be done, similar as previous options, adding: + +```zsh +zstyle ':omz:plugins:nvm' autoload yes +``` + +To remove the output generated by NVM when autoloading, you can set the following option: + +```zsh +zstyle ':omz:plugins:nvm' silent-autoload yes +``` + +Note: _this will not remove regular `nvm` output_ diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 1fb4d238b..20697d67d 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -16,14 +16,41 @@ fi # Note: nvm is a function so we need to use `which` which nvm &>/dev/null && return -if (( $+NVM_LAZY )); then - # Call nvm when first using nvm, node, npm, pnpm, yarn or $NVM_LAZY_CMD - function nvm node npm pnpm yarn $NVM_LAZY_CMD { - unfunction nvm node npm pnpm yarn $NVM_LAZY_CMD - # Load nvm if it exists in $NVM_DIR - [[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" - "$0" "$@" - } +# TODO: 2022-11-11: Remove soft-deprecate options +if (( ${+NVM_LAZY} + ${+NVM_LAZY_CMD} + ${+NVM_AUTOLOAD} )); then + # Get list of NVM_* variable settings defined + local -a used_vars + used_vars=(${(o)parameters[(I)NVM_(AUTOLOAD|LAZY|LAZY_CMD)]}) + # Nicely print the list in the style `var1, var2 and var3` + echo "${fg[yellow]}[nvm plugin] Variable-style settings are deprecated. Instead of ${(j:, :)used_vars[1,-2]}${used_vars[-2]+ and }${used_vars[-1]}, use:\n" + if (( $+NVM_AUTOLOAD )); then + echo " zstyle ':omz:plugins:nvm' autoload yes" + zstyle ':omz:plugins:nvm' autoload yes + fi + if (( $+NVM_LAZY )); then + echo " zstyle ':omz:plugins:nvm' lazy yes" + zstyle ':omz:plugins:nvm' lazy yes + fi + if (( $+NVM_LAZY_CMD )); then + echo " zstyle ':omz:plugins:nvm' lazy-cmd $NVM_LAZY_CMD" + zstyle ':omz:plugins:nvm' lazy-cmd $NVM_LAZY_CMD + fi + echo "$reset_color" + unset used_vars NVM_AUTOLOAD NVM_LAZY NVM_LAZY_CMD +fi + +if zstyle -t ':omz:plugins:nvm' lazy; then + # Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd + zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd + eval " + function nvm node npm pnpm yarn $nvm_lazy_cmd { + unfunction nvm node npm pnpm yarn $nvm_lazy_cmd + # Load nvm if it exists in \$NVM_DIR + [[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\" + \"\$0\" \"\$@\" + } + " + unset nvm_lazy_cmd elif [[ -f "$NVM_DIR/nvm.sh" ]]; then # Load nvm if it exists in $NVM_DIR source "$NVM_DIR/nvm.sh" @@ -33,22 +60,27 @@ fi # Autoload nvm when finding a .nvmrc file in the current directory # Adapted from: https://github.com/nvm-sh/nvm#zsh -if (( $+NVM_AUTOLOAD )); then - load-nvmrc() { +if zstyle -t ':omz:plugins:nvm' autoload; then + function load-nvmrc { local node_version="$(nvm version)" local nvmrc_path="$(nvm_find_nvmrc)" + local nvm_silent="" + zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent" if [[ -n "$nvmrc_path" ]]; then - local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") + local nvmrc_node_version=$(nvm version $(cat "$nvmrc_path" | tr -dc '[:print:]')) if [[ "$nvmrc_node_version" = "N/A" ]]; then nvm install elif [[ "$nvmrc_node_version" != "$node_version" ]]; then - nvm use + nvm use $nvm_silent fi elif [[ "$node_version" != "$(nvm version default)" ]]; then - echo "Reverting to nvm default version" - nvm use default + if [[ -z $nvm_silent ]]; then + echo "Reverting to nvm default version" + fi + + nvm use default $nvm_silent fi } @@ -70,4 +102,4 @@ for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_complet fi done -unset NVM_HOMEBREW NVM_LAZY NVM_AUTOLOAD nvm_completion +unset NVM_HOMEBREW nvm_completion diff --git a/plugins/perms/README.md b/plugins/perms/README.md index ae7a36b9d..ae10fa659 100644 --- a/plugins/perms/README.md +++ b/plugins/perms/README.md @@ -10,6 +10,16 @@ plugins=(... perms) ## Usage -* `set755` recursively sets all given directories (default to .) to octal 755. -* `set644` recursively sets all given files (default to .) to octal 644. -* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases. +> **CAUTION:** these functions are harmful if you don't know what they do. + +- `set755`: sets the permission to octal 755 for all given directories and their child directories (by default, starting from the current directory). + +- `set644`: sets the permission to octal 644 for all files of the given directory (by default, the current directory), recursively. It will only affect regular files (no symlinks). + +- `resetperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. + It will set the permissions to 755 for directories, and 644 for files. + +## Reference + +- octal 644: _read and write_ for the owner, _read_ for the group and others users. +- octal 755: _read, write and execute_ permissions for the owner, and _read and execute_ for the group and others users. diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh index 1a7472c1c..353b58411 100644 --- a/plugins/perms/perms.plugin.zsh +++ b/plugins/perms/perms.plugin.zsh @@ -6,25 +6,25 @@ ### Aliases # Set all files' permissions to 644 recursively in a directory -set644() { +function set644 { find "${@:-.}" -type f ! -perm 644 -print0 | xargs -0 chmod 644 } # Set all directories' permissions to 755 recursively in a directory -set755() { +function set755 { find "${@:-.}" -type d ! -perm 755 -print0 | xargs -0 chmod 755 } ### Functions -# fixperms - fix permissions on files and directories, with confirmation +# resetperms - fix permissions on files and directories, with confirmation # Returns 0 on success, nonzero if any errors occurred -fixperms () { +function resetperms { local opts confirm target exit_status chmod_opts use_slow_mode zparseopts -E -D -a opts -help -slow v+=chmod_opts if [[ $# > 1 || -n "${opts[(r)--help]}" ]]; then cat <<EOF -Usage: fixperms [-v] [--help] [--slow] [target] +Usage: resetperms [-v] [--help] [--slow] [target] target is the file or directory to change permissions on. If omitted, the current directory is taken to be the target. @@ -40,7 +40,7 @@ EOF return $exit_status fi - if [[ $# == 0 ]]; then + if [[ $# -eq 0 ]]; then target="." else target="$1" @@ -49,7 +49,7 @@ EOF # Because this requires confirmation, bail in noninteractive shells if [[ ! -o interactive ]]; then - echo "fixperms: cannot run in noninteractive shell" + echo "resetperms: cannot run in noninteractive shell" return 1 fi @@ -68,15 +68,20 @@ EOF if [[ $use_slow == true ]]; then # Process directories first so non-traversable ones are fixed as we go find "$target" -type d ! -perm 755 -exec chmod $chmod_opts 755 {} \; - if [[ $? != 0 ]]; then exit_status=$?; fi + if [[ $? -ne 0 ]]; then exit_status=$?; fi find "$target" -type f ! -perm 644 -exec chmod $chmod_opts 644 {} \; - if [[ $? != 0 ]]; then exit_status=$?; fi + if [[ $? -ne 0 ]]; then exit_status=$?; fi else find "$target" -type d ! -perm 755 -print0 | xargs -0 chmod $chmod_opts 755 - if [[ $? != 0 ]]; then exit_status=$?; fi + if [[ $? -ne 0 ]]; then exit_status=$?; fi find "$target" -type f ! -perm 644 -print0 | xargs -0 chmod $chmod_opts 644 - if [[ $? != 0 ]]; then exit_status=$?; fi + if [[ $? -ne 0 ]]; then exit_status=$?; fi fi echo "Complete" return $exit_status } + +function fixperms { + print -ru2 "fixperms has been deprecated. Use resetperms instead" + return 1 +} diff --git a/plugins/pip/README.md b/plugins/pip/README.md index 88d88227e..70d40c79f 100644 --- a/plugins/pip/README.md +++ b/plugins/pip/README.md @@ -22,6 +22,14 @@ the next time you autocomplete `pip install`. | Alias | Description | | :------- | :-------------------------------------------- | +| pipi | Install packages | +| pipig | Install package from GitHub repository | +| pipigb | Install package from GitHub branch | +| pipigp | Install package from GitHub pull request | +| pipu | Upgrade packages | +| pipun | Uninstall packages | +| pipgi | Grep through installed packages | +| piplo | List outdated packages | | pipreq | Create requirements file | | pipir | Install packages from `requirements.txt` file | | pipupall | Update all installed packages | diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index 90e39e118..bf1aafd4a 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -88,6 +88,12 @@ else alias pip="noglob pip" fi +alias pipi="pip install" +alias pipu="pip install --upgrade" +alias pipun="pip uninstall" +alias pipgi="pip freeze | grep" +alias piplo="pip list -o" + # Create requirements file alias pipreq="pip freeze > requirements.txt" @@ -102,10 +108,28 @@ function pipupall { pip list --outdated | awk 'NR > 2 { print $1 }' | ${=xargs} pip install --upgrade } -# Uninstalled all installed packages +# Uninstall all installed packages function pipunall { # non-GNU xargs does not support nor need `--no-run-if-empty` local xargs="xargs --no-run-if-empty" xargs --version 2>/dev/null | grep -q GNU || xargs="xargs" pip list --format freeze | cut -d= -f1 | ${=xargs} pip uninstall } + +# Install from GitHub repository +function pipig { + pip install "git+https://github.com/$1.git" +} +compdef _pip pipig + +# Install from GitHub branch +function pipigb { + pip install "git+https://github.com/$1.git@$2" +} +compdef _pip pipigb + +# Install from GitHub pull request +function pipigp { + pip install "git+https://github.com/$1.git@refs/pull/$2/head" +} +compdef _pip pipigp diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh index 4be61a920..244bd6b7c 100644 --- a/plugins/pipenv/pipenv.plugin.zsh +++ b/plugins/pipenv/pipenv.plugin.zsh @@ -1,8 +1,16 @@ -# Pipenv completion -_pipenv() { - eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv) -} -compdef _pipenv pipenv +if (( ! $+commands[pipenv] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `pipenv`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_pipenv" ]]; then + typeset -g -A _comps + autoload -Uz _pipenv + _comps[pipenv]=_pipenv +fi + +_PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &| # Automatic pipenv shell activation/deactivation _togglePipenvShell() { diff --git a/plugins/pre-commit/README.md b/plugins/pre-commit/README.md new file mode 100644 index 000000000..e6d80d369 --- /dev/null +++ b/plugins/pre-commit/README.md @@ -0,0 +1,19 @@ +# Pre-commit plugin + +This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/). + +To use this plugin, add it to the plugins array in your zshrc file: + +```zsh +plugins=(... pre-commit) +``` + +## Aliases + +| Alias | Command | Description | +| ------- | -------------------------------------- | ------------------------------------------------------ | +| prc | `pre-commit` | The `pre-commit` command | +| prcau | `pre-commit autoupdate` | Update hooks automatically | +| prcr | `pre-commit run` | The `pre-commit run` command | +| prcra | `pre-commit run --all-files` | Run pre-commit hooks on all files | +| prcrf | `pre-commit run --files` | Run pre-commit hooks on a given list of files | diff --git a/plugins/pre-commit/pre-commit.plugin.zsh b/plugins/pre-commit/pre-commit.plugin.zsh new file mode 100644 index 000000000..c3d0c6290 --- /dev/null +++ b/plugins/pre-commit/pre-commit.plugin.zsh @@ -0,0 +1,8 @@ +# Aliases for pre-commit +alias prc='pre-commit' + +alias prcau='pre-commit autoupdate' + +alias prcr='pre-commit run' +alias prcra='pre-commit run --all-files' +alias prcrf='pre-commit run --files' diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 7fbd1589e..48c8ffaf5 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -78,7 +78,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then eval "$(pyenv init - --no-rehash zsh)" # If pyenv-virtualenv exists, load it - if [[ "$(pyenv commands)" =~ "virtualenv-init" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then + if [[ "$ZSH_PYENV_VIRTUALENV" != false && "$(pyenv commands)" =~ "virtualenv-init" ]]; then eval "$(pyenv virtualenv-init - zsh)" fi diff --git a/plugins/qrcode/README.md b/plugins/qrcode/README.md new file mode 100644 index 000000000..442838947 --- /dev/null +++ b/plugins/qrcode/README.md @@ -0,0 +1,8 @@ +# QRCode plugin + +Generate a QR Code from the command line. Uses [QRcode.show](https://qrcode.show) via curl. + +alias | command +--------------- | -------- +`qrcode [text]` | `curl -d "text" qrcode.show` +`qrsvg [text]` | `curl -d "text" qrcode.show -H "Accept: image/svg+xml"` diff --git a/plugins/qrcode/qrcode.plugin.zsh b/plugins/qrcode/qrcode.plugin.zsh new file mode 100644 index 000000000..d757e135e --- /dev/null +++ b/plugins/qrcode/qrcode.plugin.zsh @@ -0,0 +1,17 @@ +# Imported and improved from https://qrcode.show/, section SHELL FUNCTIONS + +_qrcode_show_message() { + echo "Type or paste your text, add a new blank line, and press ^d" +} + +qrcode () { + local input="$*" + [ -z "$input" ] && _qrcode_show_message && local input="@/dev/stdin" + curl -d "$input" https://qrcode.show +} + +qrsvg () { + local input="$*" + [ -z "$input" ] && _qrcode_show_message && local input="@/dev/stdin" + curl -d "$input" https://qrcode.show -H "Accept: image/svg+xml" +} diff --git a/plugins/sigstore/README.md b/plugins/sigstore/README.md new file mode 100644 index 000000000..00e83c8c2 --- /dev/null +++ b/plugins/sigstore/README.md @@ -0,0 +1,13 @@ +# Sigstore plugin + +This plugin sets up completion for the following [Sigstore](https://sigstore.dev/) CLI tools. + +- [Cosign](https://docs.sigstore.dev/cosign/overview) +- [Sget](https://docs.sigstore.dev/cosign/installation#alpine-linux) +- [Rekor](https://docs.sigstore.dev/rekor/overview) + +To use it, add `sigstore` to the plugins array in your zshrc file: + +```zsh +plugins=(... sigstore) +``` diff --git a/plugins/sigstore/sigstore.plugin.zsh b/plugins/sigstore/sigstore.plugin.zsh new file mode 100644 index 000000000..1f9d77c11 --- /dev/null +++ b/plugins/sigstore/sigstore.plugin.zsh @@ -0,0 +1,22 @@ +function install_autocompletion { + if (( ! $+commands[$1] )); then + return + fi + + # If the completion file doesn't exist yet, we need to autoload it and + # bind it to `$1` (cosign, sget, rekor-cli). Otherwise, compinit will + # have already done that + if [[ ! -f "$ZSH_CACHE_DIR/completions/_$1" ]]; then + autoload -Uz _$1 + typeset -g -A _comps + _comps[$1]=_$1 + fi + + $1 completion zsh >| "$ZSH_CACHE_DIR/completions/_$1" &| +} + +install_autocompletion cosign +install_autocompletion sget +install_autocompletion rekor-cli + +unfunction install_autocompletion diff --git a/plugins/skaffold/README.md b/plugins/skaffold/README.md new file mode 100644 index 000000000..4ee12c666 --- /dev/null +++ b/plugins/skaffold/README.md @@ -0,0 +1,9 @@ +# Skaffold plugin (Autocompletion) + +This plugin adds completion for [Skaffold](https://skaffold.dev) + +To use it, add `skaffold` to the plugins array in your zshrc file: + +```zsh +plugins=(... skaffold) +``` diff --git a/plugins/skaffold/skaffold.plugin.zsh b/plugins/skaffold/skaffold.plugin.zsh new file mode 100644 index 000000000..8296c450c --- /dev/null +++ b/plugins/skaffold/skaffold.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for skaffold +if (( ! $+commands[skaffold] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `skaffold`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_skaffold" ]]; then + typeset -g -A _comps + autoload -Uz _skaffold + _comps[skaffold]=_skaffold +fi + +skaffold completion zsh >| "$ZSH_CACHE_DIR/completions/_skaffold" &| diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 8e5e0af71..9b5159ff1 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -33,6 +33,14 @@ alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head # top10 of the history alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' +function ip() { + if [ -t 1 ]; then + command ip -color "$@" + else + command ip "$@" + fi +} + # directory LS function dls() { print -l *(/) diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh index 7afd2be58..1270bea0e 100644 --- a/plugins/systemd/systemd.plugin.zsh +++ b/plugins/systemd/systemd.plugin.zsh @@ -107,6 +107,8 @@ function systemd_prompt_info { if systemctl is-active "$unit" &>/dev/null; then echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE" + elif systemctl --user is-active "$unit" &>/dev/null; then + echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE" else echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE" fi diff --git a/plugins/term_tab/README b/plugins/term_tab/README deleted file mode 100644 index 316062e73..000000000 --- a/plugins/term_tab/README +++ /dev/null @@ -1,16 +0,0 @@ - -term_tab - 'cwd' for all open zsh sessions -****************************************** - -What it does: -************* -This plugin allows to complete the 'cwd' of other Zsh sessions. Sounds -complicated but is rather simple. E.g. if you have three zsh sessions open, in -each session you are in a different folder, you can hit Ctrl+v in one session -to show you the current working directory of the other open zsh sessions. - -How it works: -************* -* It uses 'pidof zsh' to determine all zsh PIDs -* It reads procfs to get the current working directory of this session -* Everything is fed into zsh's completion magic diff --git a/plugins/term_tab/README.md b/plugins/term_tab/README.md new file mode 100644 index 000000000..59462a825 --- /dev/null +++ b/plugins/term_tab/README.md @@ -0,0 +1,18 @@ +# term_tab plugin + +This plugin only works for Solaris and linux. + +term_tab - `cwd` for all open zsh sessions + +## What it does: + +This plugin allows to complete the `cwd` of other Zsh sessions. Sounds +complicated but is rather simple. E.g. if you have three zsh sessions open, in +each session you are in a different folder, you can hit `Ctrl+V` in one session +to show you the current working directory of the other open zsh sessions. + +## How it works: + +* It uses `pidof zsh` to determine all zsh PIDs +* It reads procfs to get the current working directory of this session +* Everything is fed into zsh's completion magic diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform deleted file mode 100644 index 625834563..000000000 --- a/plugins/terraform/_terraform +++ /dev/null @@ -1,411 +0,0 @@ -#compdef terraform - -local -a _terraform_cmds opt_args -_terraform_cmds=( - 'apply:Builds or changes infrastructure' - 'console:Interactive console for Terraform interpolations' - 'destroy:Destroy Terraform-managed infrastructure' - 'fmt:Rewrites config files to canonical format' - 'force-unlock:Manually unlock the terraform state' - 'get:Download and install modules for the configuration' - 'graph:Create a visual graph of Terraform resources' - 'import:Import existing infrastructure into Terraform' - 'init:Initialize a Terraform working directory' - 'login:Obtain and save credentials for a remote host' - 'logout:Remove locally-stored credentials for a remote host' - 'output:Read an output from a state file' - 'plan:Generate and show an execution plan' - 'providers:Prints a tree of the providers used in the configuration' - 'refresh:Update local state file against real resources' - 'show:Inspect Terraform state or plan' - 'state:Advanced state management' - 'taint:Manually mark a resource for recreation' - 'untaint:Manually unmark a resource as tainted' - 'validate:Validates the Terraform files' - 'version:Prints the Terraform version' - 'workspace:Workspace management' - '0.12upgrade:Rewrites pre-0.12 module source code for v0.12' - '0.13upgrade:Rewrites pre-0.13 module source code for v0.13' -) - -__012upgrade() { - _arguments \ - '-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' \ - '-force[ Override the heuristic that attempts to detect if a configuration is already written for v0.12 or later. Some of the transformations made by this command are not idempotent, so re-running against the same module may change the meanings expressions in the module.]' -} - -__013upgrade() { - _arguments \ - '-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' -} - -__apply() { - _arguments \ - '-auto-approve[Skip interactive approval of plan before applying.]' \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-no-color[If specified, output will be colorless.]' \ - '-parallelism=[(10) Limit the number of parallel resource operations.]' \ - '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \ - '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \ - '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__console() { - _arguments \ - '-state=[(terraform.tfstate) Path to read state.]' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__destroy() { - _arguments \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-auto-approve[Skip interactive approval before destroying.]' \ - '-force[Deprecated: same as auto-approve.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[If specified, output will contain no color.]' \ - '-parallelism=[(10) Limit the number of concurrent operations.]' \ - '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \ - '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \ - '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__fmt() { - _arguments \ - '-list=[(true) List files whose formatting differs (always false if using STDIN)]' \ - '-write=[(true) Write result to source file instead of STDOUT (always false if using STDIN or -check)]' \ - '-diff=[(false) Display diffs of formatting changes]' \ - '-check=[(false) Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' \ - '-recursive=[(false) Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]' -} - -__force_unlock() { - _arguments \ - "-force[Don't ask for input for unlock confirmation.]" -} - -__get() { - _arguments \ - '-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \ - '-no-color[Disable text coloring in the output.]' -} - -__graph() { - _arguments \ - '-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \ - '-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]' -} - -__import() { - _arguments \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \ - '-allow-missing-config[Allow import when no resource configuration block exists.]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[If specified, output will contain no color.]' \ - '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__init() { - _arguments \ - '-backend=[(true) Configure the backend for this configuration.]' \ - '-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \ - '-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \ - '-from-module=[(SOURCE) Copy the contents of the given module into the target directory before initialization.]' \ - '-get=[(true) Download any modules for this configuration.]' \ - '-get-plugins=[(true) Download any missing plugins for this configuration.]' \ - '-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[If specified, output will contain no color.]' \ - '-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -/' \ - '-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \ - '-upgrade=[(false) If installing modules (-get) or plugins (-get-plugins), ignore previously-downloaded objects and install the latest version allowed within configured constraints.]' \ - '-verify-plugins=[(true) Verify the authenticity and integrity of automatically downloaded plugins.]' -} - -__login() { - _arguments \ - -} - -__logout() { - _arguments \ - -} - -__output() { - _arguments \ - '-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \ - '-no-color[If specified, output will contain no color.]' \ - '-json[If specified, machine readable output will be printed in JSON format]' -} - -__plan() { - _arguments \ - '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \ - '-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \ - '-detailed-exitcode[() Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[() If specified, output will contain no color.]' \ - '-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \ - '-parallelism=[(10) Limit the number of concurrent operations.]' \ - '-refresh=[(true) Update state prior to checking for differences.]' \ - '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \ - '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__providers() { - local -a __providers_cmds - __providers_cmds=( - 'mirror:Mirrors the provider plugins needed for the current configuration' - 'schema:Prints the schemas of the providers used in the configuration' - ) - _describe -t providers "providers commands" __providers_cmds - -} - -__providers_mirror() { - _arguments \ - '-platform=[(os_arch) Choose which target platform to build a mirror for.]' \ - "*:target_dir:_files -/" -} - -__providers_schema() { - _arguments \ - '-json[]' \ - '::' -} - -__refresh() { - _arguments \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -g "*.backup"' \ - '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-no-color[If specified, output will not contain any color.]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \ - '*-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \ - '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"' -} - -__show() { - _arguments \ - '-json[If specified, output the Terraform plan or state in a machine-readable form.]' \ - '-no-color[If specified, output will not contain any color.]' -} - -__state() { - local -a __state_cmds - __state_cmds=( - 'list:List resources in the state' - 'mv:Move an item in the state' - 'pull:Pull current state and output to stdout' - 'push:Update remote state from a local state file' - 'replace-provider:Replace provider for resources in the Terraform state' - 'rm:Remove instances from the state' - 'show:Show a resource in the state' - ) - _describe -t state "state commands" __state_cmds -} - -__state_list() { - _arguments \ - '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]' \ - '-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \ - "*:address:__statelist" -} - -__state_mv() { - _arguments \ - "-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \ - '-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -g "*.backup"' \ - '-backup-out=[(PATH) Path where Terraform should write the backup for the destination state. This can"t be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:backupfile:_files -g "*.backup"' \ - "-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \ - "-lock-timeout=[(0s) Duration to retry a state lock.]" \ - '-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to the destination state file to write to. If this isn"t specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \ - "::" \ - ":source:__statelist" \ - ":destination: " -} - -__state_push() { - _arguments \ - "-force[Write the state even if lineages don't match or the remote serial is higher.]" \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - "-lock-timeout=[(0s) Duration to retry a state lock.]" \ - "::" \ - ":destination:_files" -} - -__state_replace_provider() { - _arguments \ - '-auto-approve[Skip interactive approval.]' \ - '-backup=[(PATH) Path where Terraform should write the backup for the state file. This can"t be disabled. If not set, Terraform will write it to the same path as the state file with a ".backup" extension.]:backupfile:_files -g "*.backup"' \ - "-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \ - "-lock-timeout=[(0s) Duration to retry a state lock.]" \ - '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \ - ":from_provider_fqn:" \ - ":to_provider_fqn:" -} - -__state_rm() { - _arguments \ - "-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \ - '-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -g "*.backup"' \ - "-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)" \ - "-lock-timeout=[(0s) Duration to retry a state lock.]" \ - '-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -g "*.tfstate"' \ - "*:address:__statelist" -} - - -__state_show() { - _arguments \ - '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \ - "*:address:__statelist" -} - -__statelist() { - compadd $(terraform state list $opt_args[-state]) -} - -__taint() { - _arguments \ - '-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' \ - "*:address:__statelist" -} - -__untaint() { - _arguments \ - '-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \ - '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \ - '-lock-timeout=[(0s) Duration to retry a state lock.]' \ - '-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \ - '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' -} - -__validate() { - _arguments \ - '-no-color[If specified, output will not contain any color.]' \ - '-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \ - ':dir:_files -/' -} - -__version() { - _arguments \ - '-json[Output the version information as a JSON object.]' -} - -__workspace() { - local -a __workspace_cmds - __workspace_cmds=( - 'delete:Delete a workspace' - 'list:List Workspaces' - 'new:Create a new workspace' - 'select:Select a workspace' - 'show:Show the name of the current workspace' - ) - _describe -t workspace "workspace commands" __workspace_cmds -} - -_arguments '*:: :->command' - -if (( CURRENT == 1 )); then - _describe -t commands "terraform command" _terraform_cmds - return -fi - -local -a _command_args -case "$words[1]" in - 0.12upgrade) - __012upgrade ;; - 0.13upgrade) - __013upgrade ;; - apply) - __apply ;; - console) - __console;; - destroy) - __destroy ;; - fmt) - __fmt;; - force-unlock) - __force_unlock;; - get) - __get ;; - graph) - __graph ;; - import) - __import;; - init) - __init ;; - login) - __login ;; - logout) - __logout ;; - output) - __output ;; - plan) - __plan ;; - providers) - test $CURRENT -lt 3 && __providers - [[ $words[2] = "mirror" ]] && __providers_mirror - [[ $words[2] = "schema" ]] && __providers_schema - ;; - refresh) - __refresh ;; - show) - __show ;; - state) - test $CURRENT -lt 3 && __state - [[ $words[2] = "list" ]] && __state_list - [[ $words[2] = "mv" ]] && __state_mv - [[ $words[2] = "push" ]] && __state_push - [[ $words[2] = "replace-provider" ]] && __state_replace_provider - [[ $words[2] = "rm" ]] && __state_rm - [[ $words[2] = "show" ]] && __state_show - ;; - taint) - __taint ;; - untaint) - __untaint ;; - validate) - __validate ;; - version) - __version ;; - workspace) - test $CURRENT -lt 3 && __workspace ;; -esac diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh index d9e39e6ac..eaa1e2e81 100644 --- a/plugins/terraform/terraform.plugin.zsh +++ b/plugins/terraform/terraform.plugin.zsh @@ -16,3 +16,8 @@ alias tfi='terraform init' alias tfo='terraform output' alias tfp='terraform plan' alias tfv='terraform validate' + +if (( $+commands[terraform] )); then + autoload -U +X bashcompinit && bashcompinit + complete -o nospace -C terraform terraform +fi diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index b9bb66d59..311c2e6a9 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -73,7 +73,11 @@ function _zsh_tmux_plugin_run() { [[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u) # Try to connect to an existing session. - [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach + if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach -t $ZSH_TMUX_DEFAULT_SESSION_NAME + else + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach + fi # If failed, just run tmux, fixing the TERM variable if requested. if [[ $? -ne 0 ]]; then @@ -83,9 +87,9 @@ function _zsh_tmux_plugin_run() { tmux_cmd+=(-f "$ZSH_TMUX_CONFIG") fi if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then - $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME + $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME else - $tmux_cmd new-session + $tmux_cmd new-session fi fi diff --git a/plugins/ubuntu/README.md b/plugins/ubuntu/README.md index 20f5c65ee..2401c102b 100644 --- a/plugins/ubuntu/README.md +++ b/plugins/ubuntu/README.md @@ -15,7 +15,7 @@ Commands that use `$APT` will use `apt` if installed or defer to `apt-get` other | Alias | Command | Description | |---------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| | age | `sudo $APT` | Run apt-get with sudo | -| acs | `apt-cache search` | Search the apt-cache with the specified criteria | +| acse | `apt-cache search` | Search the apt-cache with the specified criteria | | acsp | `apt-cache showpkg` | Shows information about the listed packages | | acp | `apt-cache policy` | Display the package source priorities | | afs | `apt-file search --regexp` | Perform a regular expression apt-file search | diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 7b765a406..4d35da2ac 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -1,6 +1,6 @@ (( $+commands[apt] )) && APT=apt || APT=apt-get -alias acs='apt-cache search' +alias acse='apt-cache search' alias afs='apt-file search --regexp' diff --git a/plugins/watson/README.md b/plugins/watson/README.md new file mode 100644 index 000000000..ef734ec63 --- /dev/null +++ b/plugins/watson/README.md @@ -0,0 +1,9 @@ +# Watson + +This plugin provides completion for [Watson](https://tailordev.github.io/Watson/). + +To use it add `watson` to the plugins array in your zshrc file. + +```zsh +plugins=(... watson) +``` diff --git a/plugins/watson/_watson b/plugins/watson/_watson new file mode 100644 index 000000000..0f599bd66 --- /dev/null +++ b/plugins/watson/_watson @@ -0,0 +1,34 @@ +#compdef watson + +_watson_completion() { + local -a completions + local -a completions_with_descriptions + local -a response + (( ! $+commands[watson] )) && return 1 + + response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _WATSON_COMPLETE=zsh_complete watson)}") + + for type key descr in ${response}; do + if [[ "$type" == "plain" ]]; then + if [[ "$descr" == "_" ]]; then + completions+=("$key") + else + completions_with_descriptions+=("$key":"$descr") + fi + elif [[ "$type" == "dir" ]]; then + _path_files -/ + elif [[ "$type" == "file" ]]; then + _path_files -f + fi + done + + if [ -n "$completions_with_descriptions" ]; then + _describe -V unsorted completions_with_descriptions -U + fi + + if [ -n "$completions" ]; then + compadd -U -V unsorted -a completions + fi +} + +compdef _watson_completion watson; diff --git a/plugins/wd/README.md b/plugins/wd/README.md index 8791f9f0e..1d1980632 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -1,12 +1,12 @@ # wd -[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd) +[![Build Status](https://github.com/mfaerevaag/wd/actions/workflows/test.yml/badge.svg)](https://github.com/mfaerevaag/wd/actions) `wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems inefficient when the folder is frequently visited or has a long path. -![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif) +![Demo](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif) ## Setup @@ -36,6 +36,10 @@ In your `.zshrc`: antibody bundle mfaerevaag/wd ``` +### [Fig](https://fig.io) + +Install `wd` here: [![Fig plugin store](https://fig.io/badges/install-with-fig.svg)](https://fig.io/plugins/other/wd_mfaerevaag) + ### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/)) 1. Install from the AUR diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh index 9085c5b7b..e51cf906a 100644 --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -163,6 +163,7 @@ wd_add() { local point=$1 local force=$2 + cmdnames=(add rm show list ls path clean help) if [[ $point == "" ]] then @@ -178,6 +179,9 @@ wd_add() elif [[ $point =~ : ]] || [[ $point =~ / ]] then wd_exit_fail "Warp point contains illegal character (:/)" + elif (($cmdnames[(Ie)$point])) + then + wd_exit_fail "Warp point name cannot be a wd command (see wd -h for a full list)" elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ] then wd_remove "$point" > /dev/null @@ -185,7 +189,7 @@ wd_add() if (whence sort >/dev/null); then local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX") # use 'cat' below to ensure we respect $WD_CONFIG as a symlink - command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" > "$WD_CONFIG" && command rm "${config_tmp}" + command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" >| "$WD_CONFIG" && command rm "${config_tmp}" fi wd_export_static_named_directories @@ -214,7 +218,7 @@ wd_remove() then local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX") # Copy and delete in two steps in order to preserve symlinks - if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" > "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp" + if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" >| "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp" then wd_print_msg "$WD_GREEN" "Warp point removed" else @@ -251,7 +255,7 @@ wd_list_all() then arr=(${(s,:,)line}) key=${arr[1]} - val=${arr[2]} + val=${line#"${arr[1]}:"} if [[ -z $wd_quiet_mode ]] then @@ -389,6 +393,11 @@ else wd_export_static_named_directories fi +# disable extendedglob for the complete wd execution time +setopt | grep -q extendedglob +wd_extglob_is_set=$? +[[ $wd_extglob_is_set ]] && setopt noextendedglob + # load warp points typeset -A points while read -r line @@ -475,6 +484,9 @@ fi # if not, next time warp will pick up variables from this run # remember, there's no sub shell +[[ $wd_extglob_is_set ]] && setopt extendedglob + +unset wd_extglob_is_set unset wd_warp unset wd_add unset wd_remove diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md index 9c16ff2c3..5c7c7f323 100644 --- a/plugins/yarn/README.md +++ b/plugins/yarn/README.md @@ -15,7 +15,7 @@ It also adds `yarn` global scripts dir (commonly `~/.yarn/bin`) to the `$PATH`. To disable this feature, set the following style in your `.zshrc`: ```zsh -zstyle ':omz:plugins:yarn' global-path false +zstyle ':omz:plugins:yarn' global-path no ``` ## Aliases @@ -29,6 +29,7 @@ zstyle ':omz:plugins:yarn' global-path false | yb | `yarn build` | Run the build script defined in `package.json` | | ycc | `yarn cache clean` | Clean yarn's global cache of packages | | yd | `yarn dev` | Run the dev script defined in `package.json` | +| yf | `yarn format` | Run the dev script defined in `package.json` | | yga | `yarn global add` | Install packages globally on your operating system | | ygls | `yarn global list` | Lists global installed packages | | ygrm | `yarn global remove` | Remove global installed packages from your OS | @@ -54,3 +55,4 @@ zstyle ':omz:plugins:yarn' global-path false | yv | `yarn version` | Update the version of your package | | yw | `yarn workspace` | Run a command within a single workspace. | | yws | `yarn workspaces` | Run a command within all defined workspaces. | +| yy | `yarn why` | Show why a package has been installed, detailing which other packages depend on it | diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh index bcb8661cf..157044d71 100644 --- a/plugins/yarn/yarn.plugin.zsh +++ b/plugins/yarn/yarn.plugin.zsh @@ -17,6 +17,7 @@ alias yap="yarn add --peer" alias yb="yarn build" alias ycc="yarn cache clean" alias yd="yarn dev" +alias yf="yarn format" alias yga="yarn global add" alias ygls="yarn global list" alias ygrm="yarn global remove" @@ -42,3 +43,4 @@ alias yup="yarn upgrade" alias yv="yarn version" alias yw="yarn workspace" alias yws="yarn workspaces" +alias yy="yarn why" diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 96190993a..3abd9f799 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -116,6 +116,17 @@ prompt_git() { prompt_segment green $CURRENT_FG fi + local ahead behind + ahead=$(git log --oneline @{upstream}.. 2>/dev/null) + behind=$(git log --oneline ..@{upstream} 2>/dev/null) + if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then + PL_BRANCH_CHAR=$'\u21c5' + elif [[ -n "$ahead" ]]; then + PL_BRANCH_CHAR=$'\u21b1' + elif [[ -n "$behind" ]]; then + PL_BRANCH_CHAR=$'\u21b0' + fi + if [[ -e "${repo_path}/BISECT_LOG" ]]; then mode=" <B>" elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index f90ba331b..1279ea919 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -82,4 +82,4 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}" # LS colors, made with https://geoff.greer.fm/lscolors/ export LSCOLORS="exfxcxdxbxegedabagacad" export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:' -export GREP_COLOR='1;33' +export GREP_COLORS='mt=1;33' diff --git a/tools/changelog.sh b/tools/changelog.sh index 6489a3cb2..a5cc468f2 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -209,7 +209,7 @@ function display-release { case "$output" in raw) printf '%s' "$hash" ;; text) printf '\e[33m%s\e[0m' "$hash" ;; # red - md) printf '[`%s`](https://github.com/ohmyzsh/ohmyzsh/commit/%s)' "$hash" ;; + md) printf '[`%s`](https://github.com/ohmyzsh/ohmyzsh/commit/%s)' "$hash" "$hash" ;; esac } diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index cc527e72d..3a6bb6555 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -24,7 +24,7 @@ zstyle -s ':omz:update' mode update_mode || { # - git is unavailable on the system. if [[ "$update_mode" = disabled ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ - || ! command -v git &>/dev/null; then + || ! command git --version 2>&1 >/dev/null; then unset update_mode return fi |