diff --git a/lib/async_prompt.zsh b/lib/async_prompt.zsh index db48446e7..151e24b8c 100644 --- a/lib/async_prompt.zsh +++ b/lib/async_prompt.zsh @@ -26,7 +26,7 @@ autoload -Uz is-at-least # This API is subject to change and optimization. Rely on it at your own risk. function _omz_register_handler { - setopt localoptions noksharrays + setopt localoptions noksharrays unset typeset -ga _omz_async_functions # we want to do nothing if there's no $1 function or we already set it up if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \ @@ -44,6 +44,7 @@ function _omz_register_handler { # Set up async handlers and callbacks function _omz_async_request { + setopt localoptions noksharrays unset local -i ret=$? typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 087bae9bb..d2fbf42cd 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -47,7 +47,7 @@ fi # Runs before showing the prompt function omz_termsupport_precmd { - [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return + [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return 0 title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE" } @@ -145,6 +145,7 @@ esac # Identifies the directory using a file: URI scheme, including # the host name to disambiguate local vs. remote paths. function omz_termsupport_cwd { + setopt localoptions unset # Percent-encode the host and path names. local URL_HOST URL_PATH URL_HOST="$(omz_urlencode -P $HOST)" || return 1 diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index f6ffb6ed5..dca8250be 100644 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -62,7 +62,7 @@ function bgnotify_formatted { function bgnotify_appid { if (( ${+commands[osascript]} )); then osascript -e "tell application id \"$(bgnotify_programid)\" to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null - elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )); then # wayland+sway + elif [[ -n $WAYLAND_DISPLAY ]] && ([[ -n $SWAYSOCK ]] || [[ -n $I3SOCK ]]) && (( ${+commands[swaymsg]} )); then # wayland+sway local app_id=$(bgnotify_find_sway_appid) [[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then diff --git a/plugins/conda/conda.plugin.zsh b/plugins/conda/conda.plugin.zsh index a93ceeb95..7a130ba7b 100644 --- a/plugins/conda/conda.plugin.zsh +++ b/plugins/conda/conda.plugin.zsh @@ -14,8 +14,8 @@ alias cnl='conda list' alias cnle='conda list --export' alias cnles='conda list --explicit > spec-file.txt' alias cnr='conda remove' -alias cnrn='conda remove -y -all -n' -alias cnrp='conda remove -y -all -p' +alias cnrn='conda remove -y --all -n' +alias cnrp='conda remove -y --all -p' alias cnry='conda remove -y' alias cnsr='conda search' alias cnu='conda update' diff --git a/plugins/dirhistory/README.md b/plugins/dirhistory/README.md index ede9b5410..66e3e0469 100644 --- a/plugins/dirhistory/README.md +++ b/plugins/dirhistory/README.md @@ -60,3 +60,46 @@ to `/usr` again. After that, Alt + Down will probably go to `/usr/bin` if `bin` is the first directory in alphabetical order (depends on your `/usr` folder structure). Alt + Up will return to `/usr`, and once more will get you to the root folder (`/`). + +### cde + +This plugin also provides a `cde` alias that allows you to change to a directory without clearing the next directory stack. +This changes the default behavior of `dirhistory`, which is to clear the next directory stack when changing directories. + +For example, if the shell was started, and the following commands were entered: + +```shell +cd ~ +cd /usr +cd share +cd doc + +# +# +``` + +The directory stack would look like this: + +```sh +➜ /usr typeset -pm dirhistory_\* +typeset -ax dirhistory_past=( /home/user /usr ) +typeset -ax dirhistory_future=( /usr/share/doc /usr/share ) +``` + +This means that pressing Alt + Right, you'd go to `/usr/share` and `/usr/share/doc` (the "future" directories). + +If you run `cd /usr/bin`, the "future" directories will be removed, and you won't be able to access them with Alt + Right: + +```sh +➜ /u/bin typeset -pm dirhistory_\* +typeset -ax dirhistory_past=( /home/user /usr ) +typeset -ax dirhistory_future=( /usr/bin ) +``` + +If you instead run `cde /usr/bin`, the "future" directories will be preserved: + +```sh +➜ /u/bin typeset -pm dirhistory_\* +typeset -ax dirhistory_past=( /home/user /usr /usr/bin ) +typeset -ax dirhistory_future=( /usr/share/doc /usr/share ) +``` diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 8d67c6188..706bb6fb2 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -11,9 +11,10 @@ dirhistory_past=($PWD) dirhistory_future=() export dirhistory_past export dirhistory_future - export DIRHISTORY_SIZE=30 +alias cde='dirhistory_cd' + # Pop the last element of dirhistory_past. # Pass the name of the variable to return the result in. # Returns the element if the array was not empty, @@ -136,7 +137,11 @@ for keymap in emacs vicmd viins; do case "$TERM_PROGRAM" in Apple_Terminal) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app - iTerm.app) bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back ;; # iTerm2 + ghostty) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # ghostty + iTerm.app) + bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back + bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back + ;; esac if (( ${+terminfo[kcub1]} )); then @@ -151,7 +156,11 @@ for keymap in emacs vicmd viins; do case "$TERM_PROGRAM" in Apple_Terminal) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app - iTerm.app) bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future ;; # iTerm2 + ghostty) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # ghostty + iTerm.app) + bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future + bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future + ;; esac if (( ${+terminfo[kcuf1]} )); then @@ -200,6 +209,7 @@ for keymap in emacs vicmd viins; do case "$TERM_PROGRAM" in Apple_Terminal) bindkey -M $keymap "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app iTerm.app) bindkey -M $keymap "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2 + ghostty) bindkey -M $keymap "^[[1;3A" dirhistory_zle_dirhistory_up ;; # ghostty esac if (( ${+terminfo[kcuu1]} )); then @@ -215,6 +225,7 @@ for keymap in emacs vicmd viins; do case "$TERM_PROGRAM" in Apple_Terminal) bindkey -M $keymap "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app iTerm.app) bindkey -M $keymap "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2 + ghostty) bindkey -M $keymap "^[[1;3B" dirhistory_zle_dirhistory_down ;; # ghostty esac if (( ${+terminfo[kcud1]} )); then diff --git a/plugins/jira/README.md b/plugins/jira/README.md index 19266e7f0..f6e2e26f4 100644 --- a/plugins/jira/README.md +++ b/plugins/jira/README.md @@ -26,6 +26,7 @@ This plugin supplies one command, `jira`, through which all its features are exp | `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 project ABC` | Opens JIRA project summary | | `jira dashboard [rapid_view]` | Opens your JIRA dashboard | | `jira mine` | Queries for your own issues | | `jira tempo` | Opens your JIRA Tempo | diff --git a/plugins/jira/_jira b/plugins/jira/_jira index 5f7dcd09d..617a3e501 100644 --- a/plugins/jira/_jira +++ b/plugins/jira/_jira @@ -5,6 +5,7 @@ local -a _1st_arguments _1st_arguments=( 'new:create a new issue' 'mine:open my issues' + 'project:open the project' '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 22e0c82c7..0c90544d5 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -8,6 +8,7 @@ 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 project ABC Opens JIRA project summary jira dashboard [rapid_view] Opens your JIRA dashboard jira mine Queries for your own issues jira tempo Opens your JIRA Tempo @@ -88,6 +89,9 @@ function jira() { elif [[ "$action" == "mine" ]]; then echo "Opening my issues" open_command "${jira_url}/issues/?filter=-1" + elif [[ "$action" == "project" ]]; then + echo "Opening project" + open_command "${jira_url}/jira/software/c/projects/${2}/summary" elif [[ "$action" == "dashboard" ]]; then echo "Opening dashboard" if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then diff --git a/plugins/jj/README.md b/plugins/jj/README.md new file mode 100644 index 000000000..cd43ed11b --- /dev/null +++ b/plugins/jj/README.md @@ -0,0 +1,89 @@ +# jj - Jujutsu CLI + +This plugin provides autocompletion for [jj](https://martinvonz.github.io/jj). + +To use it, add `jj` to the plugins array of your zshrc file: + +```zsh +plugins=(... jj) +``` + +## Aliases + +| Alias | Command | +| ------ | ----------------------------- | +| jjc | `jj commit` | +| jjcmsg | `jj commit --message` | +| jjd | `jj diff` | +| jjdmsg | `jj desc --message` | +| jjds | `jj desc` | +| jje | `jj edit` | +| jjgcl | `jj git clone` | +| jjgf | `jj git fetch` | +| jjgp | `jj git push` | +| jjl | `jj log` | +| jjla | `jj log -r "all()"` | +| jjn | `jj new` | +| jjrb | `jj rebase` | +| jjrs | `jj restore` | +| jjrt | `cd "$(jj root \|\| echo .)"` | +| jjsp | `jj split` | +| jjsq | `jj squash` | + +## Prompt usage + +Because `jj` has a very powerful [template syntax](https://martinvonz.github.io/jj/latest/templates/), this +plugin only exposes a convenience function `jj_prompt_template` to read information from the current change. +It is basically the same as `jj log --no-graph -r @ -T $1`: + +```sh +_my_theme_jj_info() { + jj_prompt_template 'self.change_id().shortest(3)' +} + +PROMPT='$(_my_theme_jj_info) $' +``` + +`jj_prompt_template` escapes `%` signs in the output. Use `jj_prompt_template_raw` if you don't want that +(e.g. to colorize the output). + +However, because `jj` can be used inside a Git repository, some themes might clash with it. Generally, you can +fix it with a wrapper function that tries `jj` first and then falls back to `git` if it didn't work: + +```sh +_my_theme_vcs_info() { + jj_prompt_template 'self.change_id().shortest(3)' \ + || git_prompt_info +} + +PROMPT='$(_my_theme_vcs_info) $' +``` + +You can find an example +[here](https://github.com/nasso/omzsh/blob/e439e494f22f4fd4ef1b6cb64626255f4b341c1b/themes/sunakayu.zsh-theme). + +### Performance + +Sometimes `jj` can be slower than `git`. + +If you feel slowdowns, consider using the following: + +``` +zstyle :omz:plugins:jj ignore-working-copy yes +``` + +This will add `--ignore-working-copy` to all `jj` commands executed by your prompt. The downside here is that +your prompt might be out-of-sync until the next time `jj` gets a chance to _not_ ignore the working copy (i.e. +you manually run a `jj` command). + +If you prefer to keep your prompt always up-to-date but still don't want to _feel_ the slowdown, you can make +your prompt asynchronous. This plugin doesn't do this automatically so you'd have to hack your theme a bit for +that. + +## See Also + +- [martinvonz/jj](https://github.com/martinvonz/jj) + +## Contributors + +- [nasso](https://github.com/nasso) - Plugin Author diff --git a/plugins/jj/jj.plugin.zsh b/plugins/jj/jj.plugin.zsh new file mode 100644 index 000000000..06c04958b --- /dev/null +++ b/plugins/jj/jj.plugin.zsh @@ -0,0 +1,53 @@ +# if jj is not found, don't do the rest of the script +if (( ! $+commands[jj] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `jj`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_jj" ]]; then + typeset -g -A _comps + autoload -Uz _jj + _comps[jj]=_jj +fi + +COMPLETE=zsh jj >| "$ZSH_CACHE_DIR/completions/_jj" &| + +function __jj_prompt_jj() { + local -a flags + flags=("--no-pager") + if zstyle -t ':omz:plugins:jj' ignore-working-copy; then + flags+=("--ignore-working-copy") + fi + command jj $flags "$@" +} + +# convenience functions for themes +function jj_prompt_template_raw() { + __jj_prompt_jj log --no-graph -r @ -T "$@" 2> /dev/null +} + +function jj_prompt_template() { + local out + out=$(jj_prompt_template_raw "$@") || return 1 + echo "${out:gs/%/%%}" +} + +# Aliases (sorted alphabetically) +alias jjc='jj commit' +alias jjcmsg='jj commit --message' +alias jjd='jj diff' +alias jjdmsg='jj desc --message' +alias jjds='jj desc' +alias jje='jj edit' +alias jjgcl='jj git clone' +alias jjgf='jj git fetch' +alias jjgp='jj git push' +alias jjl='jj log' +alias jjla='jj log -r "all()"' +alias jjn='jj new' +alias jjrb='jj rebase' +alias jjrs='jj restore' +alias jjrt='cd "$(jj root || echo .)"' +alias jjsp='jj split' +alias jjsq='jj squash' diff --git a/plugins/macos/README.md b/plugins/macos/README.md index 8245e211f..ccc4331e5 100644 --- a/plugins/macos/README.md +++ b/plugins/macos/README.md @@ -13,6 +13,7 @@ plugins=(... macos) - [iTerm2](https://iterm2.com/) - [Hyper](https://hyper.is/) - [Tabby](https://tabby.sh/) +- [Ghostty](https://ghostty.org) ## Commands diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index b951a289f..6ddf31ecf 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -85,6 +85,12 @@ EOF tell application "System Events" tell process "Tabby" to keystroke "t" using command down end tell +EOF + elif [[ "$the_app" == 'ghostty' ]]; then + osascript >/dev/null <&2 @@ -139,6 +145,12 @@ EOF tell application "System Events" tell process "Tabby" to keystroke "D" using command down end tell +EOF + elif [[ "$the_app" == 'ghostty' ]]; then + osascript >/dev/null <&2 @@ -194,6 +206,12 @@ EOF tell application "System Events" tell process "Tabby" to keystroke "d" using command down end tell +EOF + elif [[ "$the_app" == 'ghostty' ]]; then + osascript >/dev/null <&2 diff --git a/plugins/mix/_mix b/plugins/mix/_mix index 656c7fe19..346fc8c4f 100644 --- a/plugins/mix/_mix +++ b/plugins/mix/_mix @@ -146,6 +146,16 @@ case $state in (help) _arguments ':feature:__task_list' ;; + (format) + _arguments -C \ + '--check-formatted' \ + '--dot-formatter' \ + '--dry-run' \ + '--force' \ + '--migrate' \ + '--no-exit' \ + '*::file:_files' + ;; (test) _files ;; diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh index 23c21dc8f..1eda54caa 100644 --- a/plugins/rand-quote/rand-quote.plugin.zsh +++ b/plugins/rand-quote/rand-quote.plugin.zsh @@ -8,7 +8,7 @@ function quote { # Get random quote data local data - data="$(command curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php" \ + data="$(command curl -s --connect-timeout 2 "https://www.quotationspage.com/random.php" \ | iconv -c -f ISO-8859-1 -t UTF-8 \ | command grep -a -m 1 'dt class="quote"')" diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 28ad3558a..53607b8ad 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -31,6 +31,7 @@ The plugin also supports the following: | Variable | Description | | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | +| `ZSH_TMUX_AUTOREFRESH` | Automatically refresh global environments (default: `true`) | | `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) | | `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) | | `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) | diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 51cc7d6a5..f6de9166f 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -15,6 +15,8 @@ fi : ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART} # Automatically name the new session based on the basename of PWD : ${ZSH_TMUX_AUTONAME_SESSION:=false} +# Automatically pick up tmux environments +: ${ZSH_TMUX_AUTOREFRESH:=true} # Set term to screen or screen-256color based on current terminal support : ${ZSH_TMUX_DETACHED:=false} # Set detached mode @@ -158,6 +160,15 @@ function _zsh_tmux_plugin_run() { fi } +# Refresh tmux environment variables. +function _zsh_tmux_plugin_preexec() +{ + local -a tmux_cmd + tmux_cmd=(command tmux) + + eval $($tmux_cmd show-environment -s) +} + # Use the completions for tmux for our function compdef _tmux _zsh_tmux_plugin_run # Alias tmux to our wrapper function. @@ -184,3 +195,9 @@ if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z _zsh_tmux_plugin_run fi fi + +# Automatically refresh tmux environments if tmux is running. +if [[ -n "$TMUX" && "$ZSH_TMUX_AUTOREFRESH" == "true" ]] && tmux ls >/dev/null 2>/dev/null; then + autoload -U add-zsh-hook + add-zsh-hook preexec _zsh_tmux_plugin_preexec +fi diff --git a/plugins/uv/uv.plugin.zsh b/plugins/uv/uv.plugin.zsh index f1ad37e15..abcbc117e 100644 --- a/plugins/uv/uv.plugin.zsh +++ b/plugins/uv/uv.plugin.zsh @@ -3,6 +3,8 @@ if (( ! ${+commands[uv]} )); then return fi +alias uv="noglob uv" + alias uva='uv add' alias uvexp='uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet' alias uvl='uv lock' diff --git a/themes/nicoulaj.zsh-theme b/themes/nicoulaj.zsh-theme old mode 100644 new mode 100755 index 685cd1ade..6435c3833 --- a/themes/nicoulaj.zsh-theme +++ b/themes/nicoulaj.zsh-theme @@ -12,12 +12,12 @@ # ------------------------------------------------------------------------------ # Customizable parameters. -PROMPT_PATH_MAX_LENGTH=30 -PROMPT_DEFAULT_END=❯ -PROMPT_ROOT_END=❯❯❯ -PROMPT_SUCCESS_COLOR=$FG[071] -PROMPT_FAILURE_COLOR=$FG[124] -PROMPT_VCS_INFO_COLOR=$FG[242] +PROMPT_PATH_MAX_LENGTH=${PROMPT_PATH_MAX_LENGTH:-30} +PROMPT_DEFAULT_END=${PROMPT_DEFAULT_END:-❯} +PROMPT_ROOT_END=${PROMPT_ROOT_END:-❯❯❯} +PROMPT_SUCCESS_COLOR=${PROMPT_SUCCESS_COLOR:-$FG[071]} +PROMPT_FAILURE_COLOR=${PROMPT_FAILURE_COLOR:-$FG[124]} +PROMPT_VCS_INFO_COLOR=${PROMPT_VCS_INFO_COLOR:-$FG[242]} # Set required options. setopt promptsubst diff --git a/tools/install.sh b/tools/install.sh index e5f126915..5c9b2c18d 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -399,8 +399,8 @@ EOF "$FMT_YELLOW" "$FMT_RESET" read -r opt case $opt in - y*|Y*|"") ;; - n*|N*) echo "Shell change skipped."; return ;; + [Yy]*|"") ;; + [Nn]*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac