Merge branch 'ohmyzsh:master' into feat/docker-stats-alias

This commit is contained in:
Chriss 2025-03-24 16:10:03 +01:00 committed by GitHub
commit 167e8ffed7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 270 additions and 17 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -60,3 +60,46 @@ to `/usr` again.
After that, <kbd>Alt</kbd> + <kbd>Down</kbd> will probably go to `/usr/bin` if `bin` is the first directory in alphabetical
order (depends on your `/usr` folder structure). <kbd>Alt</kbd> + <kbd>Up</kbd> 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
# <Alt + Left>
# <Alt + Left>
```
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 <kbd>Alt</kbd> + <kbd>Right</kbd>, 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 <kbd>Alt</kbd> + <kbd>Right</kbd>:
```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 )
```

View File

@ -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

View File

@ -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 |

View File

@ -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'

View File

@ -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

89
plugins/jj/README.md Normal file
View File

@ -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

53
plugins/jj/jj.plugin.zsh Normal file
View File

@ -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'

View File

@ -13,6 +13,7 @@ plugins=(... macos)
- [iTerm2](https://iterm2.com/)
- [Hyper](https://hyper.is/)
- [Tabby](https://tabby.sh/)
- [Ghostty](https://ghostty.org)
## Commands

View File

@ -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 <<EOF
tell application "System Events"
tell process "Ghostty" to keystroke "t" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&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 <<EOF
tell application "System Events"
tell process "Ghostty" to keystroke "D" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&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 <<EOF
tell application "System Events"
tell process "Ghostty" to keystroke "d" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&2

View File

@ -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
;;

View File

@ -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"')"

View File

@ -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`) |

View File

@ -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

View File

@ -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'

12
themes/nicoulaj.zsh-theme Normal file → Executable file
View File

@ -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

View File

@ -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