mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
Merge branch 'ohmyzsh:master' into master
This commit is contained in:
commit
bd72dd8bea
15 changed files with 111 additions and 67 deletions
|
@ -20,6 +20,12 @@ if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom functi
|
|||
}
|
||||
fi
|
||||
|
||||
currentAppId () {
|
||||
if (( $+commands[osascript] )); then
|
||||
osascript -e 'tell application (path to frontmost application as text) to id' 2>/dev/null
|
||||
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"
|
||||
|
@ -32,11 +38,20 @@ currentWindowId () {
|
|||
|
||||
bgnotify () { ## args: (title, subtitle)
|
||||
if hash terminal-notifier 2>/dev/null; then #osx
|
||||
[[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2';
|
||||
[[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal';
|
||||
local term_id="$bgnotify_appid"
|
||||
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!)
|
||||
[ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null ||
|
||||
terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/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
|
||||
fi
|
||||
elif hash growlnotify 2>/dev/null; then #osx growl
|
||||
growlnotify -m "$1" "$2"
|
||||
elif hash notify-send 2>/dev/null; then #ubuntu gnome!
|
||||
|
@ -54,6 +69,7 @@ bgnotify () { ## args: (title, subtitle)
|
|||
bgnotify_begin() {
|
||||
bgnotify_timestamp=$EPOCHSECONDS
|
||||
bgnotify_lastcmd="${1:-$2}"
|
||||
bgnotify_appid="$(currentAppId)"
|
||||
bgnotify_windowid=$(currentWindowId)
|
||||
}
|
||||
|
||||
|
@ -62,7 +78,7 @@ bgnotify_end() {
|
|||
elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
|
||||
past_threshold=$(( elapsed >= bgnotify_threshold ))
|
||||
if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
|
||||
if [ $(currentWindowId) != "$bgnotify_windowid" ]; then
|
||||
if [[ $(currentAppId) != "$bgnotify_appid" || $(currentWindowId) != "$bgnotify_windowid" ]]; then
|
||||
print -n "\a"
|
||||
bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
|
||||
fi
|
||||
|
|
|
@ -40,7 +40,7 @@ bundle_install() {
|
|||
else
|
||||
local cores_num="$(nproc)"
|
||||
fi
|
||||
bundle install --jobs="$cores_num" "$@"
|
||||
BUNDLE_JOBS="$cores_num" bundle install "$@"
|
||||
}
|
||||
|
||||
## Gem wrapper
|
||||
|
@ -81,14 +81,12 @@ bundled_commands=(
|
|||
)
|
||||
|
||||
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
|
||||
for cmd in $UNBUNDLED_COMMANDS; do
|
||||
bundled_commands=(${bundled_commands#$cmd});
|
||||
done
|
||||
bundled_commands=(${bundled_commands:|UNBUNDLED_COMMANDS})
|
||||
unset UNBUNDLED_COMMANDS
|
||||
|
||||
# Add $BUNDLED_COMMANDS to the bundled_commands list
|
||||
for cmd in $BUNDLED_COMMANDS; do
|
||||
bundled_commands+=($cmd);
|
||||
done
|
||||
bundled_commands+=($BUNDLED_COMMANDS)
|
||||
unset BUNDLED_COMMANDS
|
||||
|
||||
# Check if in the root or a subdirectory of a bundled project
|
||||
_within-bundled-project() {
|
||||
|
@ -126,5 +124,4 @@ for cmd in $bundled_commands; do
|
|||
compdef "_$cmd" "bundled_$cmd"="$cmd"
|
||||
fi
|
||||
done
|
||||
|
||||
unset cmd bundled_commands
|
||||
|
|
|
@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30
|
|||
# Returns the element if the array was not empty,
|
||||
# otherwise returns empty string.
|
||||
function pop_past() {
|
||||
eval "$1=${(q)dirhistory_past[$#dirhistory_past]}"
|
||||
print -v $1 "${dirhistory_past[$#dirhistory_past]}"
|
||||
if [[ $#dirhistory_past -gt 0 ]]; then
|
||||
dirhistory_past[$#dirhistory_past]=()
|
||||
fi
|
||||
}
|
||||
|
||||
function pop_future() {
|
||||
eval "$1=${(q)dirhistory_future[$#dirhistory_future]}"
|
||||
print -v $1 "${dirhistory_future[$#dirhistory_future]}"
|
||||
if [[ $#dirhistory_future -gt 0 ]]; then
|
||||
dirhistory_future[$#dirhistory_future]=()
|
||||
fi
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
# support Compose v2 as docker CLI plugin
|
||||
DOCKER_CONTEXT=default command docker compose &>/dev/null \
|
||||
&& dccmd='docker compose' \
|
||||
|| dccmd='docker-compose'
|
||||
(( ${+commands[docker-compose]} )) && dccmd='docker-compose' || dccmd='docker compose'
|
||||
|
||||
alias dco="$dccmd"
|
||||
alias dcb="$dccmd build"
|
||||
|
|
17
plugins/kn/README.md
Normal file
17
plugins/kn/README.md
Normal 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
8
plugins/kn/kn.plugin.zsh
Normal 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
|
|
@ -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
|
||||
alias ofd='open_command $PWD'
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
macos.plugin.zsh
|
|
@ -1 +0,0 @@
|
|||
macos
|
3
plugins/osx/README.md
Normal file
3
plugins/osx/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# osx plugin
|
||||
|
||||
**Deprecated: use the [`macos`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/macos) plugin instead.**
|
5
plugins/osx/osx.plugin.zsh
Normal file
5
plugins/osx/osx.plugin.zsh
Normal 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"
|
|
@ -13,28 +13,24 @@ plugins=(... ssh-agent)
|
|||
|
||||
**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:
|
||||
|
||||
```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
|
||||
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`._
|
||||
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 lazy yes
|
||||
zstyle :omz:plugins:ssh-agent helper ksshaskpass
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
----
|
||||
### `identities`
|
||||
|
||||
To **load multiple identities** use the `identities` style (**this has no effect
|
||||
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}
|
||||
```
|
||||
|
||||
----
|
||||
### `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.
|
||||
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
|
||||
```
|
||||
|
||||
----
|
||||
### `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,
|
||||
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`.
|
||||
|
||||
----
|
||||
|
||||
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
|
||||
|
||||
Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
|
||||
|
|
|
@ -18,7 +18,7 @@ function _start_agent() {
|
|||
zstyle -s :omz:plugins:ssh-agent lifetime lifetime
|
||||
|
||||
# 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"
|
||||
chmod 600 "$ssh_env_cache"
|
||||
. "$ssh_env_cache" > /dev/null
|
||||
|
@ -78,7 +78,7 @@ function _add_identities() {
|
|||
|
||||
if [[ -n "$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
|
||||
SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null
|
||||
return $?
|
||||
|
@ -88,11 +88,9 @@ function _add_identities() {
|
|||
ssh-add "${args[@]}" ${^not_loaded}
|
||||
}
|
||||
|
||||
# test if agent-forwarding is enabled
|
||||
zstyle -b :omz:plugins:ssh-agent agent-forwarding agent_forwarding
|
||||
|
||||
# Add a nifty symlink for screen/tmux if agent forwarding
|
||||
if [[ $agent_forwarding = "yes" && -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
|
||||
# Add a nifty symlink for screen/tmux if agent forwarding is enabled
|
||||
if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
|
||||
&& [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
|
||||
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
|
||||
else
|
||||
_start_agent
|
||||
|
|
|
@ -339,11 +339,11 @@ EOF
|
|||
|
||||
# shellcheck disable=SC2183 # printf string has more %s than arguments ($RAINBOW expands to multiple arguments)
|
||||
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 '\n'
|
||||
printf '\n'
|
||||
|
|
|
@ -182,12 +182,12 @@ if git pull --rebase --stat $remote $branch; then
|
|||
printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
|
||||
fi
|
||||
|
||||
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 "${BLUE}%s${RESET}\n\n" "$message"
|
||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "$(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
|
||||
|
|
Loading…
Reference in a new issue