diff options
| author | Tuowen Zhao <ztuowen@gmail.com> | 2023-12-09 13:20:13 -0800 |
|---|---|---|
| committer | Tuowen Zhao <ztuowen@gmail.com> | 2023-12-09 13:20:13 -0800 |
| commit | 7e951c254e779ff0620537cf43ca69dd878387b4 (patch) | |
| tree | cb042e695bb3e11ed0483fad1af8a5b4f1bfc8d8 | |
| parent | 4d908094fdc2a0c0e9a0a072eba213fab7adef43 (diff) | |
| parent | 48ccc7b36de8efb2bd7beb9bd6e0a6f6fe03b95d (diff) | |
| download | zsh-7e951c254e779ff0620537cf43ca69dd878387b4.tar.gz zsh-7e951c254e779ff0620537cf43ca69dd878387b4.tar.bz2 zsh-7e951c254e779ff0620537cf43ca69dd878387b4.zip | |
Merge remote-tracking branch 'github/master'
| -rw-r--r-- | .github/workflows/installer.yml | 4 | ||||
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | lib/functions.zsh | 5 | ||||
| -rw-r--r-- | lib/misc.zsh | 9 | ||||
| -rw-r--r-- | plugins/bgnotify/README.md | 29 | ||||
| -rw-r--r-- | plugins/bgnotify/bgnotify.plugin.zsh | 88 | ||||
| -rw-r--r-- | plugins/direnv/direnv.plugin.zsh | 6 | ||||
| -rw-r--r-- | plugins/docker-compose/README.md | 41 | ||||
| -rw-r--r-- | plugins/docker-compose/docker-compose.plugin.zsh | 1 | ||||
| -rw-r--r-- | plugins/dotnet/dotnet.plugin.zsh | 22 | ||||
| -rw-r--r-- | plugins/frontend-search/README.md | 12 | ||||
| -rw-r--r-- | plugins/frontend-search/frontend-search.plugin.zsh | 20 | ||||
| -rw-r--r-- | plugins/git/git.plugin.zsh | 2 | ||||
| -rw-r--r-- | plugins/grc/grc.plugin.zsh | 1 | ||||
| -rw-r--r-- | plugins/juju/juju.plugin.zsh | 2 | ||||
| -rw-r--r-- | plugins/per-directory-history/README.md | 2 | ||||
| -rw-r--r-- | plugins/per-directory-history/per-directory-history.zsh | 11 | ||||
| -rw-r--r-- | plugins/python/README.md | 2 | ||||
| -rw-r--r-- | plugins/python/python.plugin.zsh | 4 | ||||
| -rw-r--r-- | plugins/vi-mode/README.md | 2 | ||||
| -rw-r--r-- | plugins/vi-mode/vi-mode.plugin.zsh | 20 | ||||
| -rw-r--r-- | themes/robbyrussell.zsh-theme | 4 | ||||
| -rwxr-xr-x | tools/install.sh | 4 |
23 files changed, 201 insertions, 102 deletions
diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index a70c483d1..cad5d445b 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -17,6 +17,7 @@ permissions: jobs: test: name: Test installer + if: github.repository == 'ohmyzsh/ohmyzsh' runs-on: ${{ matrix.os }} strategy: matrix: @@ -48,7 +49,8 @@ jobs: env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} run: | cp tools/install.sh .github/workflows/installer/install.sh cd .github/workflows/installer - vc deploy --prod -t ${{ secrets.VERCEL_TOKEN }} + vc deploy --prod -t "$VERCEL_TOKEN" @@ -88,6 +88,14 @@ Oh My Zsh is installed by running one of the following commands in your terminal | **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | +Alternatively, the installer is also mirrored outside GitHub. Using this URL instead may be required if you're in a country like India or China, that blocks `raw.githubusercontent.com`: + +| Method | Command | +| :-------- | :------------------------------------------------------------------------------------------------ | +| **curl** | `sh -c "$(curl -fsSL https://install.ohmyz.sh/)"` | +| **wget** | `sh -c "$(wget -O- https://install.ohmyz.sh/)"` | +| **fetch** | `sh -c "$(fetch -o - https://install.ohmyz.sh/)"` | + _Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move the configuration you want to preserve into the new `.zshrc`._ #### Manual Inspection @@ -101,6 +109,8 @@ wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh sh install.sh ``` +If the above URL times out or otherwise fails, you may have to substitute the URL for `https://install.ohmyz.sh` to be able to get the script. + ## Using Oh My Zsh ### Plugins @@ -220,6 +230,8 @@ the default shell, and it also won't run `zsh` when the installation has finishe sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended ``` +If you're in China, India, or another country that blocks `raw.githubusercontent.com`, you may have to substitute the URL for `https://install.ohmyz.sh` for it to install. + #### Installing From A Forked Repository The install script also accepts these variables to allow installation of a different repository: diff --git a/lib/functions.zsh b/lib/functions.zsh index a252d0a33..f5c671f9c 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -182,6 +182,8 @@ function omz_urlencode() { fi # Use LC_CTYPE=C to process text byte-by-byte + # Note that this doesn't work in Termux, as it only has UTF-8 locale. + # Characters will be processed as UTF-8, which is fine for URLs. local i byte ord LC_ALL=C export LC_ALL local reserved=';/?:@&=+$,' @@ -206,6 +208,9 @@ function omz_urlencode() { else if [[ "$byte" == " " && -n $spaces_as_plus ]]; then url_str+="+" + elif [[ "$PREFIX" = *com.termux* ]]; then + # Termux does not have non-UTF8 locales, so just send the UTF-8 character directly + url_str+="$byte" else ord=$(( [##16] #byte )) url_str+="%$ord" diff --git a/lib/misc.zsh b/lib/misc.zsh index 132f33551..ff2017713 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -19,8 +19,13 @@ setopt multios # enable redirect to multiple streams: echo >file1 > setopt long_list_jobs # show long list format job notifications setopt interactivecomments # recognize comments -env_default 'PAGER' 'less' -env_default 'LESS' '-R' +# define pager dependant on what is available (less or more) +if (( ${+commands[less]} )); then + env_default 'PAGER' 'less' + env_default 'LESS' '-R' +elif (( ${+commands[more]} )); then + env_default 'PAGER' 'more' +fi ## super user alias alias _='sudo ' diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md index 1d8fac54d..33d529f15 100644 --- a/plugins/bgnotify/README.md +++ b/plugins/bgnotify/README.md @@ -1,19 +1,19 @@ # bgnotify zsh plugin -cross-platform background notifications for long running commands! Supports OSX and Ubuntu linux. +cross-platform background notifications for long running commands! Supports OSX and Linux. Standalone homepage: [t413/zsh-background-notify](https://github.com/t413/zsh-background-notify) ----------------------------------- +--- -## How to use! +## How to use Just add bgnotify to your plugins list in your `.zshrc` - On OS X you'll need [terminal-notifier](https://github.com/alloy/terminal-notifier) * `brew install terminal-notifier` (or `gem install terminal-notifier`) -- On ubuntu you're already all set! -- On windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package +- On Linux, make sure you have `notify-send` or `kdialog` installed. If you're using Ubuntu you should already be all set! +- On Windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package ## Screenshots @@ -35,20 +35,29 @@ Just add bgnotify to your plugins list in your `.zshrc` One can configure a few things: +- `bgnotify_bell` enabled or disables the terminal bell (default true) - `bgnotify_threshold` sets the notification threshold time (default 6 seconds) -- `function bgnotify_formatted` lets you change the notification +- `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon. Use these by adding a function definition before the your call to source. Example: -~~~ sh +```sh +bgnotify_bell=false ## disable terminal bell bgnotify_threshold=4 ## set your own notification threshold function bgnotify_formatted { ## $1=exit_status, $2=command, $3=elapsed_time - [ $1 -eq 0 ] && title="Holy Smokes Batman!" || title="Holy Graf Zeppelin!" - bgnotify "$title -- after $3 s" "$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" + + [ $1 -eq 0 ] && title="Holy Smokes Batman" || title="Holy Graf Zeppelin" + [ $1 -eq 0 ] && icon="$HOME/icons/success.png" || icon="$HOME/icons/fail.png" + bgnotify "$title - took ${elapsed}" "$2" "$icon" } plugins=(git bgnotify) ## add to plugins list source $ZSH/oh-my-zsh.sh ## existing source call -~~~ +``` diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index ed2653aa8..3c0766191 100644 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -27,7 +27,7 @@ function bgnotify_end { # check if Terminal app is not active [[ $(bgnotify_appid) != "$bgnotify_termid" ]] || return - printf '\a' # beep sound + [[ $bgnotify_bell = true ]] && printf '\a' # beep sound bgnotify_formatted "$exit_status" "$bgnotify_lastcmd" "$elapsed" } always { bgnotify_timestamp=0 @@ -52,53 +52,93 @@ function bgnotify_formatted { (( $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" + if [[ $exit_status -eq 0 ]]; then + bgnotify "#win (took $elapsed)" "$cmd" else - bgnotify "#fail (took $elapsed)" "$2" + bgnotify "#fail (took $elapsed)" "$cmd" fi } -# for macOS, output is "app ID, window ID" (com.googlecode.iterm2, 116) function bgnotify_appid { if (( ${+commands[osascript]} )); then + # output is "app ID, window ID" (com.googlecode.iterm2, 116) 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 + elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )); then # wayland+sway + local app_id=$(find_sway_appid) + [[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS + elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5 else echo $EPOCHSECONDS fi } -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 + +function find_sway_appid { + # output is "app_id,container_id", for example "Alacritty,1694" + # see example swaymsg output: https://github.com/ohmyzsh/ohmyzsh/files/13463939/output.json + if (( ${+commands[jq]} )); then + swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | {app_id, id} | join(",")' + else + swaymsg -t get_tree | awk ' + BEGIN { Id = ""; Appid = ""; FocusNesting = -1; Nesting = 0 } + { + # Enter a block + if ($0 ~ /.*{$/) Nesting++ + + # Exit a block. If Nesting is now less than FocusNesting, we have the data we are looking for + if ($0 ~ /^[[:blank:]]*}.*/) { Nesting--; if (FocusNesting > 0 && Nesting < FocusNesting) exit 0 } + + # Save the Id, it is potentially what we are looking for + if ($0 ~ /^[[:blank:]]*"id": [0-9]*,?$/) { sub(/^[[:blank:]]*"id": /, ""); sub(/,$/, ""); Id = $0 } + + # Save the Appid, it is potentially what we are looking for + if ($0 ~ /^[[:blank:]]*"app_id": ".*",?$/) { sub(/^[[:blank:]]*"app_id": "/, ""); sub(/",$/, ""); Appid = $0 } + + # Window is focused, this nesting block contains the Id and Appid we want! + if ($0 ~ /^[[:blank:]]*"focused": true,?$/) { FocusNesting = Nesting } + } + END { + if (Appid != "" && Id != "" && FocusNesting != -1) print Appid "," Id + else print "" + }' + fi +} + +function find_term_id { + local term_id="${bgnotify_termid%%,*}" # remove window id + if [[ -z "$term_id" ]]; then + case "$TERM_PROGRAM" in iTerm.app) term_id='com.googlecode.iterm2' ;; Apple_Terminal) term_id='com.apple.terminal' ;; - esac - fi + esac + fi + echo "$term_id" +} - if [[ -z "$term_id" ]]; then - terminal-notifier -message "$2" -title "$1" &>/dev/null - else - terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" &>/dev/null - fi +function bgnotify { + local title="$1" + local message="$2" + local icon="$3" + if (( ${+commands[terminal-notifier]} )); then # macOS + local term_id=$(find_term_id) + terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id" -sender "$term_id"} &>/dev/null elif (( ${+commands[growlnotify]} )); then # macOS growl - growlnotify -m "$1" "$2" - elif (( ${+commands[notify-send]} )); then # GNOME - notify-send "$1" "$2" + growlnotify -m "$title" "$message" + elif (( ${+commands[notify-send]} )); then + notify-send "$title" "$message" ${=icon:+--icon "$icon"} elif (( ${+commands[kdialog]} )); then # KDE - kdialog --title "$1" --passivepopup "$2" 5 + kdialog --title "$title" --passivepopup "$message" 5 elif (( ${+commands[notifu]} )); then # cygwin - notifu /m "$2" /p "$1" + notifu /m "$message" /p "$title" ${=icon:+/i "$icon"} fi } ## Defaults +# enable terminal bell on notify by default +bgnotify_bell=${bgnotify_bell:-true} + # notify if command took longer than 5s by default bgnotify_threshold=${bgnotify_threshold:-5} diff --git a/plugins/direnv/direnv.plugin.zsh b/plugins/direnv/direnv.plugin.zsh index 6f8debb62..0a33194dd 100644 --- a/plugins/direnv/direnv.plugin.zsh +++ b/plugins/direnv/direnv.plugin.zsh @@ -3,14 +3,14 @@ command -v direnv &>/dev/null || return _direnv_hook() { trap -- '' SIGINT; - eval "$(direnv hook zsh)"; + eval "$(direnv export zsh)"; trap - SIGINT; } typeset -ag precmd_functions; -if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then +if [[ -z "${precmd_functions[(r)_direnv_hook]+1}" ]]; then precmd_functions=( _direnv_hook ${precmd_functions[@]} ) fi typeset -ag chpwd_functions; -if [[ -z ${chpwd_functions[(r)_direnv_hook]} ]]; then +if [[ -z "${chpwd_functions[(r)_direnv_hook]+1}" ]]; then chpwd_functions=( _direnv_hook ${chpwd_functions[@]} ) fi diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md index bbcff2e0c..66d4e0521 100644 --- a/plugins/docker-compose/README.md +++ b/plugins/docker-compose/README.md @@ -11,23 +11,24 @@ 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 | -| 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 | +| 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 | +| dclF | `docker-compose logs -f --tail0` | Just follow recent logs | +| 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 7a8bf4a03..d1823f535 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -16,6 +16,7 @@ alias dcupdb="$dccmd up -d --build" alias dcdn="$dccmd down" alias dcl="$dccmd logs" alias dclf="$dccmd logs -f" +alias dclF="$dccmd logs -f --tail 0" alias dcpull="$dccmd pull" alias dcstart="$dccmd start" alias dck="$dccmd kill" diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh index 89d464670..40ee7efae 100644 --- a/plugins/dotnet/dotnet.plugin.zsh +++ b/plugins/dotnet/dotnet.plugin.zsh @@ -1,22 +1,14 @@ # This scripts is copied from (MIT License): -# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh +# https://raw.githubusercontent.com/dotnet/sdk/main/scripts/register-completions.zsh -_dotnet_zsh_complete() -{ - local completions=("$(dotnet complete "$words")") - - # If the completion list is empty, just continue with filename selection - if [ -z "$completions" ] - then - _arguments '*::arguments: _normal' - return - fi - - # This is not a variable assignment, don't remove spaces! - _values = "${(ps:\n:)completions}" +#compdef dotnet +_dotnet_completion() { + local -a completions=("${(@f)$(dotnet complete "${words}")}") + compadd -a completions + _files } -compdef _dotnet_zsh_complete dotnet +compdef _dotnet_completion dotnet # Aliases bellow are here for backwards compatibility # added by Shaun Tabone (https://github.com/xontab) diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md index 050058931..920795060 100644 --- a/plugins/frontend-search/README.md +++ b/plugins/frontend-search/README.md @@ -60,12 +60,22 @@ Available search contexts are: | typescript | `https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=` | | unheap | `http://www.unheap.com/?s=` | | vuejs | `https://www.google.com/search?as_sitesearch=vuejs.org&as_q=` | +| nextjs | `https://www.google.com/search?as_sitesearch=nextjs.org&as_q=` | If you want to have another context, open an Issue and tell us! ## Fallback search behaviour -The plugin will use Google as a fallback if the docs site for a search context does not have a search function. You can set the fallback search engine to DuckDuckGo by setting `FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced. +The plugin will use Google as a fallback if the docs site for a search context does not have a search +function. You can set the fallback search engine to DuckDuckGo by setting +`FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced. + +## DuckDuckGo Lucky Search + +Enable DuckDuckGo's "ducky" (lucky) search feature to automatically access the top search result. This feature +is optimized for DuckDuckGo, as Google redirects to an intermediate page. The FRONTEND_SEARCH_FALLBACK_LUCKY +environment variable triggers the use of DuckDuckGo's lucky search, rendering the FRONTEND_SEARCH_FALLBACK +setting unnecessary in this context. ## Author diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index b9e2fe95d..c96596eb9 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -27,12 +27,19 @@ alias stackoverflow='frontend stackoverflow' alias typescript='frontend typescript' alias unheap='frontend unheap' alias vuejs='frontend vuejs' +alias nextjs='frontend nextjs' function _frontend_fallback() { - case "$FRONTEND_SEARCH_FALLBACK" in - duckduckgo) echo "https://duckduckgo.com/?sites=$1&q=" ;; - *) echo "https://google.com/search?as_sitesearch=$1&as_q=" ;; - esac + if [[ "$FRONTEND_SEARCH_FALLBACK_LUCKY" == "true" ]]; then + case true in + *) echo "https://duckduckgo.com/?q=!ducky+site%3A$1+" ;; + esac + else + case "$FRONTEND_SEARCH_FALLBACK" in + duckduckgo) echo "https://duckduckgo.com/?sites=$1&q=" ;; + *) echo "https://google.com/search?as_sitesearch=$1&as_q=" ;; + esac + fi } function frontend() { @@ -70,6 +77,7 @@ function frontend() { typescript $(_frontend_fallback 'www.typescriptlang.org/docs') unheap 'http://www.unheap.com/?s=' vuejs $(_frontend_fallback 'vuejs.org') + nextjs $(_frontend_fallback 'nextjs.org') ) # show help for command list @@ -81,7 +89,7 @@ function frontend() { print -P "" print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash," - print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" + print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia, nextjs" print -P "" print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." print -P "" @@ -96,7 +104,7 @@ function frontend() { echo "" echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash," - echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" + echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia, nextjs" echo "" return 1 fi diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 6ea1d1177..2a824444b 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -166,6 +166,8 @@ alias gclean='git clean --interactive -d' alias gcl='git clone --recurse-submodules' function gccd() { + setopt localoptions extendedglob + # get repo URI from args based on valid formats: https://git-scm.com/docs/git-clone#URLS local repo="${${@[(r)(ssh://*|git://*|ftp(s)#://*|http(s)#://*|*@*)(.git/#)#]}:-$_}" diff --git a/plugins/grc/grc.plugin.zsh b/plugins/grc/grc.plugin.zsh index e036b8d89..55ffc1a1e 100644 --- a/plugins/grc/grc.plugin.zsh +++ b/plugins/grc/grc.plugin.zsh @@ -5,6 +5,7 @@ files=( /etc/grc.zsh # default /usr/local/etc/grc.zsh # homebrew darwin-x64 /opt/homebrew/etc/grc.zsh # homebrew darwin-arm64 + /usr/share/grc/grc.zsh # Gentoo Linux (app-misc/grc) ) # verify the file is readable and source it diff --git a/plugins/juju/juju.plugin.zsh b/plugins/juju/juju.plugin.zsh index 0c60e35ce..a82ebaf84 100644 --- a/plugins/juju/juju.plugin.zsh +++ b/plugins/juju/juju.plugin.zsh @@ -98,7 +98,7 @@ jaddr() { elif [[ $# -eq 2 ]]; then # Get unit address juju status "$1/$2" --format=json \ - | jq -r ".applications.\"$1\".units.\"$1/$2\".address" + | jq -r ".applications.\"$1\".units.\"$1/$2\" | .address // .\"public-address\"" else echo "Invalid number of arguments." echo "Usage: jaddr <app-name> [<unit-number>]" diff --git a/plugins/per-directory-history/README.md b/plugins/per-directory-history/README.md index 69854aa38..11150b059 100644 --- a/plugins/per-directory-history/README.md +++ b/plugins/per-directory-history/README.md @@ -34,6 +34,8 @@ toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable. and global histories. * `PER_DIRECTORY_HISTORY_TOGGLE` is the key binding used to run the toggle-history function above (default `^G`) +* `PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE` is a variable which toggles whether + the current mode is printed to the screen following a mode change (default `true`) ## History diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh index acbd64757..b33e0b5dd 100644 --- a/plugins/per-directory-history/per-directory-history.zsh +++ b/plugins/per-directory-history/per-directory-history.zsh @@ -59,6 +59,7 @@ [[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" [[ -z $HISTORY_START_WITH_GLOBAL ]] && HISTORY_START_WITH_GLOBAL=false [[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G' +[[ -z $PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE ]] && PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE=true #------------------------------------------------------------------------------- # toggle global/directory history used for searching - ctrl-G by default @@ -68,14 +69,16 @@ function per-directory-history-toggle-history() { if [[ $_per_directory_history_is_global == true ]]; then _per-directory-history-set-directory-history _per_directory_history_is_global=false - print -n "\nusing local history" + if [[ $PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE == true ]]; then + zle -M "using local history" + fi else _per-directory-history-set-global-history _per_directory_history_is_global=true - print -n "\nusing global history" + if [[ $PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE == true ]]; then + zle -M "using global history" + fi fi - zle .push-line - zle .accept-line } autoload per-directory-history-toggle-history diff --git a/plugins/python/README.md b/plugins/python/README.md index 97c1a34ee..7bf1b34ac 100644 --- a/plugins/python/README.md +++ b/plugins/python/README.md @@ -12,7 +12,7 @@ plugins=(... python) | Command | Description | | ---------------- | -------------------------------------------------------------------------------------- | -| `py` | Runs `python3` | +| `py` | Runs `python3`. Only set if `py` is not installed. | | `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv | | `pyfind` | Finds .py files recursively in the current directory | | `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one | diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh index 2fbb59577..3d7ca55c9 100644 --- a/plugins/python/python.plugin.zsh +++ b/plugins/python/python.plugin.zsh @@ -1,5 +1,5 @@ -# python command -alias py='python3' +# set python command if 'py' not installed +builtin which py > /dev/null || alias py='python3' # Find python file alias pyfind='find . -name "*.py"' diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md index 821c12adb..84ba30105 100644 --- a/plugins/vi-mode/README.md +++ b/plugins/vi-mode/README.md @@ -37,6 +37,8 @@ plugins=(... vi-mode) - `INSERT_MODE_INDICATOR`: controls the string displayed when the shell is in insert mode. See [Mode indicators](#mode-indicators) for details. +- `VI_MODE_DISABLE_CLIPBOARD`: If set, disables clipboard integration on yank/paste + ## Mode indicators *Normal mode* is indicated with a red `<<<` mark at the right prompt, when it diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 8fefaf86c..5c104f7bb 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -147,17 +147,19 @@ function wrap_clipboard_widgets() { done } -wrap_clipboard_widgets copy \ - vi-yank vi-yank-eol vi-yank-whole-line \ - vi-change vi-change-eol vi-change-whole-line \ - vi-kill-line vi-kill-eol vi-backward-kill-word \ - vi-delete vi-delete-char vi-backward-delete-char +if [[ -z "${VI_MODE_DISABLE_CLIPBOARD:-}" ]]; then + wrap_clipboard_widgets copy \ + vi-yank vi-yank-eol vi-yank-whole-line \ + vi-change vi-change-eol vi-change-whole-line \ + vi-kill-line vi-kill-eol vi-backward-kill-word \ + vi-delete vi-delete-char vi-backward-delete-char -wrap_clipboard_widgets paste \ - vi-put-{before,after} \ - put-replace-selection + wrap_clipboard_widgets paste \ + vi-put-{before,after} \ + put-replace-selection -unfunction wrap_clipboard_widgets + unfunction wrap_clipboard_widgets +fi # if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default if [[ -z "$MODE_INDICATOR" ]]; then diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme index 173e6d579..cfecfc892 100644 --- a/themes/robbyrussell.zsh-theme +++ b/themes/robbyrussell.zsh-theme @@ -1,7 +1,7 @@ -PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ ) %{$fg[cyan]%}%c%{$reset_color%}" +PROMPT="%(?:%{$fg_bold[green]%}%1{➜%} :%{$fg_bold[red]%}%1{➜%} ) %{$fg[cyan]%}%c%{$reset_color%}" PROMPT+=' $(git_prompt_info)' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}%1{✗%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" diff --git a/tools/install.sh b/tools/install.sh index fcfbcf778..508fc2f77 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -63,7 +63,9 @@ zdot="${ZDOTDIR:-$HOME}" # Default value for $ZSH # a) if $ZDOTDIR is supplied and not $HOME: $ZDOTDIR/ohmyzsh # b) otherwise, $HOME/.oh-my-zsh -[ "$ZDOTDIR" = "$HOME" ] || ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}" +if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then + ZSH="${ZSH:-$ZDOTDIR/ohmyzsh}" +fi ZSH="${ZSH:-$HOME/.oh-my-zsh}" # Default settings |
