Merge branch 'ohmyzsh:master' into master

This commit is contained in:
Vigneshwar Ravichandar 2021-11-19 13:40:12 +05:30 committed by GitHub
commit bd72dd8bea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 111 additions and 67 deletions

View file

@ -20,6 +20,12 @@ if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom functi
} }
fi fi
currentAppId () {
if (( $+commands[osascript] )); then
osascript -e 'tell application (path to frontmost application as text) to id' 2>/dev/null
fi
}
currentWindowId () { currentWindowId () {
if hash osascript 2>/dev/null; then #osx 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" osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
@ -32,11 +38,20 @@ currentWindowId () {
bgnotify () { ## args: (title, subtitle) bgnotify () { ## args: (title, subtitle)
if hash terminal-notifier 2>/dev/null; then #osx if hash terminal-notifier 2>/dev/null; then #osx
[[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2'; local term_id="$bgnotify_appid"
[[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal'; 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
## now call terminal-notifier, (hopefully with $term_id!) ## now call terminal-notifier, (hopefully with $term_id!)
[ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null || 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 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 hash growlnotify 2>/dev/null; then #osx growl
growlnotify -m "$1" "$2" growlnotify -m "$1" "$2"
elif hash notify-send 2>/dev/null; then #ubuntu gnome! elif hash notify-send 2>/dev/null; then #ubuntu gnome!
@ -54,6 +69,7 @@ bgnotify () { ## args: (title, subtitle)
bgnotify_begin() { bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS bgnotify_timestamp=$EPOCHSECONDS
bgnotify_lastcmd="${1:-$2}" bgnotify_lastcmd="${1:-$2}"
bgnotify_appid="$(currentAppId)"
bgnotify_windowid=$(currentWindowId) bgnotify_windowid=$(currentWindowId)
} }
@ -62,7 +78,7 @@ bgnotify_end() {
elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
past_threshold=$(( elapsed >= bgnotify_threshold )) past_threshold=$(( elapsed >= bgnotify_threshold ))
if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
if [ $(currentWindowId) != "$bgnotify_windowid" ]; then if [[ $(currentAppId) != "$bgnotify_appid" || $(currentWindowId) != "$bgnotify_windowid" ]]; then
print -n "\a" print -n "\a"
bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
fi fi

View file

@ -40,7 +40,7 @@ bundle_install() {
else else
local cores_num="$(nproc)" local cores_num="$(nproc)"
fi fi
bundle install --jobs="$cores_num" "$@" BUNDLE_JOBS="$cores_num" bundle install "$@"
} }
## Gem wrapper ## Gem wrapper
@ -81,14 +81,12 @@ bundled_commands=(
) )
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list # Remove $UNBUNDLED_COMMANDS from the bundled_commands list
for cmd in $UNBUNDLED_COMMANDS; do bundled_commands=(${bundled_commands:|UNBUNDLED_COMMANDS})
bundled_commands=(${bundled_commands#$cmd}); unset UNBUNDLED_COMMANDS
done
# Add $BUNDLED_COMMANDS to the bundled_commands list # Add $BUNDLED_COMMANDS to the bundled_commands list
for cmd in $BUNDLED_COMMANDS; do bundled_commands+=($BUNDLED_COMMANDS)
bundled_commands+=($cmd); unset BUNDLED_COMMANDS
done
# Check if in the root or a subdirectory of a bundled project # Check if in the root or a subdirectory of a bundled project
_within-bundled-project() { _within-bundled-project() {
@ -126,5 +124,4 @@ for cmd in $bundled_commands; do
compdef "_$cmd" "bundled_$cmd"="$cmd" compdef "_$cmd" "bundled_$cmd"="$cmd"
fi fi
done done
unset cmd bundled_commands unset cmd bundled_commands

View file

@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30
# Returns the element if the array was not empty, # Returns the element if the array was not empty,
# otherwise returns empty string. # otherwise returns empty string.
function pop_past() { function pop_past() {
eval "$1=${(q)dirhistory_past[$#dirhistory_past]}" print -v $1 "${dirhistory_past[$#dirhistory_past]}"
if [[ $#dirhistory_past -gt 0 ]]; then if [[ $#dirhistory_past -gt 0 ]]; then
dirhistory_past[$#dirhistory_past]=() dirhistory_past[$#dirhistory_past]=()
fi fi
} }
function pop_future() { function pop_future() {
eval "$1=${(q)dirhistory_future[$#dirhistory_future]}" print -v $1 "${dirhistory_future[$#dirhistory_future]}"
if [[ $#dirhistory_future -gt 0 ]]; then if [[ $#dirhistory_future -gt 0 ]]; then
dirhistory_future[$#dirhistory_future]=() dirhistory_future[$#dirhistory_future]=()
fi fi

View file

@ -1,7 +1,5 @@
# support Compose v2 as docker CLI plugin # support Compose v2 as docker CLI plugin
DOCKER_CONTEXT=default command docker compose &>/dev/null \ (( ${+commands[docker-compose]} )) && dccmd='docker-compose' || dccmd='docker compose'
&& dccmd='docker compose' \
|| dccmd='docker-compose'
alias dco="$dccmd" alias dco="$dccmd"
alias dcb="$dccmd build" alias dcb="$dccmd build"

17
plugins/kn/README.md Normal file
View file

@ -0,0 +1,17 @@
# kn - Knative CLI
This plugin provides autocompletion for [kn](https://knative.dev/docs/install/client/install-kn/) operations.
To use it, add `kn` to the plugins array of your zshrc file:
```zsh
plugins=(... kn)
```
## See Also
+ [kn/client](https://github.com/knative/client)
## Contributors
+ [btannous](https://github.com/btannous) - Plugin Author

8
plugins/kn/kn.plugin.zsh Normal file
View file

@ -0,0 +1,8 @@
# Autocompletion for kn, the command line interface for knative
#
# Author: https://github.com/btannous
if [ $commands[kn] ]; then
source <(kn completion zsh)
compdef _kn kn
fi

View file

@ -1,9 +1,3 @@
# Check if 'osx' is still in the plugins list and prompt to change to 'macos'
if [[ -n "${plugins[(r)osx]}" ]]; then
print ${(%):-"%F{yellow}The \`osx\` plugin is deprecated and has been renamed to \`macos\`."}
print ${(%):-"Please update your .zshrc to use the \`%Bmacos%b\` plugin instead.%f"}
fi
# Open the current directory in a Finder window # Open the current directory in a Finder window
alias ofd='open_command $PWD' alias ofd='open_command $PWD'

View file

@ -1 +0,0 @@
macos.plugin.zsh

View file

@ -1 +0,0 @@
macos

3
plugins/osx/README.md Normal file
View file

@ -0,0 +1,3 @@
# osx plugin
**Deprecated: use the [`macos`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/macos) plugin instead.**

View file

@ -0,0 +1,5 @@
print ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'}
print ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'}
(( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath)
source "$ZSH/plugins/macos/macos.plugin.zsh"

View file

@ -13,28 +13,24 @@ plugins=(... ssh-agent)
**IMPORTANT: put these settings _before_ the line that sources oh-my-zsh** **IMPORTANT: put these settings _before_ the line that sources oh-my-zsh**
### `agent-forwarding`
To enable **agent forwarding support** add the following to your zshrc file: To enable **agent forwarding support** add the following to your zshrc file:
```zsh ```zsh
zstyle :omz:plugins:ssh-agent agent-forwarding on zstyle :omz:plugins:ssh-agent agent-forwarding yes
``` ```
---- ### `helper`
To **NOT load any identities on start** use the `lazy` setting. This is particularly To set an **external helper** to ask for the passwords and possibly store
useful when combined with the `AddKeysToAgent` setting (available since OpenSSH 7.2), them in the system keychain use the `helper` style. For example:
since it allows to enter the password only on first use. _NOTE: you can know your
OpenSSH version with `ssh -V`._
```zsh ```zsh
zstyle :omz:plugins:ssh-agent lazy yes zstyle :omz:plugins:ssh-agent helper ksshaskpass
``` ```
You can enable `AddKeysToAgent` by passing `-o AddKeysToAgent=yes` to the `ssh` command, ### `identities`
or by adding `AddKeysToAgent yes` to your `~/.ssh/config` file [1].
See the [OpenSSH 7.2 Release Notes](http://www.openssh.com/txt/release-7.2).
----
To **load multiple identities** use the `identities` style (**this has no effect To **load multiple identities** use the `identities` style (**this has no effect
if the `lazy` setting is enabled**). For example: if the `lazy` setting is enabled**). For example:
@ -52,7 +48,22 @@ zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_r
zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github} zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github}
``` ```
---- ### `lazy`
To **NOT load any identities on start** use the `lazy` setting. This is particularly
useful when combined with the `AddKeysToAgent` setting (available since OpenSSH 7.2),
since it allows to enter the password only on first use. _NOTE: you can know your
OpenSSH version with `ssh -V`._
```zsh
zstyle :omz:plugins:ssh-agent lazy yes
```
You can enable `AddKeysToAgent` by passing `-o AddKeysToAgent=yes` to the `ssh` command,
or by adding `AddKeysToAgent yes` to your `~/.ssh/config` file [1].
See the [OpenSSH 7.2 Release Notes](http://www.openssh.com/txt/release-7.2).
### `lifetime`
To **set the maximum lifetime of the identities**, use the `lifetime` style. To **set the maximum lifetime of the identities**, use the `lifetime` style.
The lifetime may be specified in seconds or as described in sshd_config(5) The lifetime may be specified in seconds or as described in sshd_config(5)
@ -62,7 +73,15 @@ The lifetime may be specified in seconds or as described in sshd_config(5)
zstyle :omz:plugins:ssh-agent lifetime 4h zstyle :omz:plugins:ssh-agent lifetime 4h
``` ```
---- ### `quiet`
To silence the plugin, use the following setting:
```zsh
zstyle :omz:plugins:ssh-agent quiet yes
```
### `ssh-add-args`
To **pass arguments to the `ssh-add` command** that adds the identities on startup, To **pass arguments to the `ssh-add` command** that adds the identities on startup,
use the `ssh-add-args` setting. You can pass multiple arguments separated by spaces: use the `ssh-add-args` setting. You can pass multiple arguments separated by spaces:
@ -80,15 +99,6 @@ ssh-add -K -c -a /run/user/1000/ssh-auth <identities>
For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`. For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`.
----
To set an **external helper** to ask for the passwords and possibly store
them in the system keychain use the `helper` style. For example:
```zsh
zstyle :omz:plugins:ssh-agent helper ksshaskpass
```
## Credits ## Credits
Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html

View file

@ -18,7 +18,7 @@ function _start_agent() {
zstyle -s :omz:plugins:ssh-agent lifetime lifetime zstyle -s :omz:plugins:ssh-agent lifetime lifetime
# start ssh-agent and setup environment # start ssh-agent and setup environment
echo Starting ssh-agent... zstyle -t :omz:plugins:ssh-agent quiet || echo >&2 "Starting ssh-agent ..."
ssh-agent -s ${lifetime:+-t} ${lifetime} | sed '/^echo/d' >! "$ssh_env_cache" ssh-agent -s ${lifetime:+-t} ${lifetime} | sed '/^echo/d' >! "$ssh_env_cache"
chmod 600 "$ssh_env_cache" chmod 600 "$ssh_env_cache"
. "$ssh_env_cache" > /dev/null . "$ssh_env_cache" > /dev/null
@ -78,7 +78,7 @@ function _add_identities() {
if [[ -n "$helper" ]]; then if [[ -n "$helper" ]]; then
if [[ -z "${commands[$helper]}" ]]; then if [[ -z "${commands[$helper]}" ]]; then
echo "ssh-agent: the helper '$helper' has not been found." echo >&2 "ssh-agent: the helper '$helper' has not been found."
else else
SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null
return $? return $?
@ -88,11 +88,9 @@ function _add_identities() {
ssh-add "${args[@]}" ${^not_loaded} ssh-add "${args[@]}" ${^not_loaded}
} }
# test if agent-forwarding is enabled # Add a nifty symlink for screen/tmux if agent forwarding is enabled
zstyle -b :omz:plugins:ssh-agent agent-forwarding agent_forwarding if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
&& [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
# Add a nifty symlink for screen/tmux if agent forwarding
if [[ $agent_forwarding = "yes" && -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
else else
_start_agent _start_agent

View file

@ -341,9 +341,9 @@ EOF
print_success() { print_success() {
printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
printf '%s / __ \%s/ __ \ %s / __ `__ \%s/ / / / %s /_ / %s/ ___/%s __ \ %s\n' $RAINBOW $RESET printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET
printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
printf '%s %s %s %s /____/ %s %s %s %s....is now installed!%s\n' $RAINBOW $GREEN $RESET printf '%s %s %s %s /____/ %s %s %s %s....is now installed!%s\n' $RAINBOW $GREEN $RESET
printf '\n' printf '\n'
printf '\n' printf '\n'

View file

@ -184,9 +184,9 @@ if git pull --rebase --stat $remote $branch; then
printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
printf '%s / __ \%s/ __ \ %s / __ `__ \%s/ / / / %s /_ / %s/ ___/%s __ \ %s\n' $RAINBOW $RESET printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET
printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET
printf '\n' printf '\n'
printf "${BLUE}%s${RESET}\n\n" "$message" printf "${BLUE}%s${RESET}\n\n" "$message"