summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2021-10-23 18:01:40 -0600
committerTuowen Zhao <ztuowen@gmail.com>2021-10-23 18:01:40 -0600
commitfad92c603be0ff36825cc53bf8c485d4b95c7869 (patch)
tree407fe826be62a3543b6feab4f3552f58575234de
parentc674485e6b4abe313469900997d893d2940ee843 (diff)
parentf1dd97bb2a9df55fae9b1ca26c829b9f8b290667 (diff)
downloadzsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.tar.gz
zsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.tar.bz2
zsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.zip
Merge remote-tracking branch 'origin/master'
-rw-r--r--README.md65
-rw-r--r--lib/cli.zsh47
-rw-r--r--lib/correction.zsh1
-rw-r--r--lib/git.zsh3
-rw-r--r--lib/termsupport.zsh20
-rw-r--r--lib/theme-and-appearance.zsh2
-rw-r--r--oh-my-zsh.sh40
-rw-r--r--plugins/archlinux/README.md46
-rw-r--r--plugins/archlinux/archlinux.plugin.zsh23
-rw-r--r--plugins/battery/README.md19
-rw-r--r--plugins/battery/battery.plugin.zsh96
-rw-r--r--plugins/chucknorris/README.md4
-rw-r--r--plugins/chucknorris/chucknorris.plugin.zsh36
-rw-r--r--plugins/chucknorris/fortunes/chucknorris8
-rw-r--r--plugins/docker-compose/_docker-compose12
-rw-r--r--plugins/docker-compose/docker-compose.plugin.zsh48
-rw-r--r--plugins/emacs/emacs.plugin.zsh102
-rwxr-xr-xplugins/emacs/emacsclient.sh51
-rw-r--r--plugins/git/README.md9
-rw-r--r--plugins/git/git.plugin.zsh15
-rw-r--r--plugins/gpg-agent/README.md2
-rw-r--r--plugins/gpg-agent/gpg-agent.plugin.zsh25
-rw-r--r--plugins/jsontools/jsontools.plugin.zsh4
-rw-r--r--plugins/juju/README.md117
-rw-r--r--plugins/juju/juju.plugin.zsh127
-rw-r--r--plugins/mercurial/README.md3
-rw-r--r--plugins/mercurial/mercurial.plugin.zsh2
-rw-r--r--plugins/mvn/mvn.plugin.zsh577
-rw-r--r--plugins/osx/README.md43
-rw-r--r--plugins/osx/osx.plugin.zsh26
-rw-r--r--plugins/per-directory-history/per-directory-history.zsh64
-rw-r--r--plugins/pyenv/pyenv.plugin.zsh2
-rw-r--r--plugins/python/README.md1
-rw-r--r--plugins/ruby/README.md27
-rw-r--r--plugins/ruby/ruby.plugin.zsh20
-rw-r--r--plugins/ssh-agent/README.md18
-rw-r--r--plugins/ssh-agent/ssh-agent.plugin.zsh13
-rw-r--r--plugins/sublime/sublime.plugin.zsh2
-rw-r--r--plugins/yarn/README.md1
-rw-r--r--plugins/yarn/_yarn176
-rw-r--r--plugins/yarn/yarn.plugin.zsh8
-rw-r--r--plugins/z/z.sh16
-rw-r--r--plugins/zsh_reload/README.md22
-rw-r--r--plugins/zsh_reload/zsh_reload.plugin.zsh25
-rw-r--r--templates/zshrc.zsh-template11
-rw-r--r--themes/half-life.zsh-theme99
-rw-r--r--themes/obraun.zsh-theme3
-rw-r--r--tools/check_for_upgrade.sh71
-rwxr-xr-xtools/upgrade.sh101
49 files changed, 1459 insertions, 794 deletions
diff --git a/README.md b/README.md
index 3ebea91e0..907248beb 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ It's a good idea to inspect the install script from projects you don't yet know.
that by downloading the install script first, looking through it so everything looks normal,
then running it:
-```shell
+```sh
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh
```
@@ -57,13 +57,13 @@ Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load.
-```shell
+```sh
vi ~/.zshrc
```
For example, this might begin to look like this:
-```shell
+```sh
plugins=(
git
bundler
@@ -91,13 +91,13 @@ _Robby's theme is the default one. It's not the fanciest one. It's not the simpl
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
-```shell
+```sh
ZSH_THEME="robbyrussell"
```
To use a different theme, simply change the value to match the name of your desired theme. For example:
-```shell
+```sh
ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
```
@@ -112,13 +112,13 @@ In case you did not find a suitable theme for your needs, please have a look at
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
-```shell
+```sh
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
```
And if you want to pick random theme from a list of your favorite themes:
-```shell
+```sh
ZSH_THEME_RANDOM_CANDIDATES=(
"robbyrussell"
"agnoster"
@@ -127,7 +127,7 @@ ZSH_THEME_RANDOM_CANDIDATES=(
If you only know which themes you don't like, you can add them similarly to an ignored list:
-```shell
+```sh
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
```
@@ -152,7 +152,7 @@ If you'd like to change the install directory with the `ZSH` environment variabl
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
like this:
-```shell
+```sh
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
```
@@ -162,7 +162,7 @@ If you're running the Oh My Zsh install script as part of an automated install,
flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change
the default shell, and also won't run `zsh` when the installation has finished.
-```shell
+```sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
```
@@ -185,7 +185,7 @@ The install script also accepts these variables to allow installation of a diffe
For example:
-```shell
+```sh
REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
```
@@ -193,13 +193,13 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
##### 1. Clone the repository
-```shell
+```sh
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
```
##### 2. *Optionally*, backup your existing `~/.zshrc` file
-```shell
+```sh
cp ~/.zshrc ~/.zshrc.orig
```
@@ -207,13 +207,13 @@ cp ~/.zshrc ~/.zshrc.orig
You can create a new zsh config file by copying the template that we have included for you.
-```shell
+```sh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
```
##### 4. Change your default shell
-```shell
+```sh
chsh -s $(which zsh)
```
@@ -242,23 +242,40 @@ If you would like to override the functionality of a plugin distributed with Oh
## Getting Updates
-By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`:
+By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
-```shell
-DISABLE_UPDATE_PROMPT=true
-```
+1. Automatic update without confirmation prompt:
+
+ ```sh
+ zstyle ':omz:update' mode auto
+ ```
+
+2. Just offer a reminder every few days, if there are updates available:
+
+ ```sh
+ zstyle ':omz:update' mode reminder
+ ```
+
+3. To disable automatic updates entirely:
+
+ ```sh
+ zstyle ':omz:update' mode disabled
+ ```
-To disable automatic upgrades, set the following in your `~/.zshrc`:
+NOTE: you can control how often Oh My Zsh checks for updates with the following setting:
-```shell
-DISABLE_AUTO_UPDATE=true
+```sh
+# This will check for updates every 7 days
+zstyle ':omz:update' frequency 7
+# This will check for updates every time you open the terminal (not recommended)
+zstyle ':omz:update' frequency 0
```
### Manual Updates
-If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
+If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
-```shell
+```sh
omz update
```
diff --git a/lib/cli.zsh b/lib/cli.zsh
index 2189e24ca..4b14360c1 100644
--- a/lib/cli.zsh
+++ b/lib/cli.zsh
@@ -26,6 +26,7 @@ function _omz {
'help:Usage information'
'plugin:Manage plugins'
'pr:Manage Oh My Zsh Pull Requests'
+ 'reload:Reload the current zsh session'
'theme:Manage themes'
'update:Update Oh My Zsh'
)
@@ -35,7 +36,7 @@ function _omz {
elif (( CURRENT == 3 )); then
case "$words[2]" in
changelog) local -a refs
- refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
+ refs=("${(@f)$(command git -C "$ZSH" for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
_describe 'command' refs ;;
plugin) subcmds=(
'disable:Disable plugin(s)'
@@ -90,7 +91,8 @@ function _omz {
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
# has a space after them. This is to avoid removing plugins partially passed, which makes
# the completion not add a space after the completed plugin.
- local -a args=(${words[4,$(( CURRENT - 1))]})
+ local -a args
+ args=(${words[4,$(( CURRENT - 1))]})
valid_plugins=(${valid_plugins:|args})
_describe 'plugin' valid_plugins ;;
@@ -159,6 +161,7 @@ Available commands:
changelog Print the changelog
plugin <command> Manage plugins
pr <command> Manage Oh My Zsh Pull Requests
+ reload Reload the current zsh session
theme <command> Manage themes
update Update Oh My Zsh
@@ -212,7 +215,7 @@ function _omz::plugin::disable {
fi
# Check that plugin is in $plugins
- local -a dis_plugins=()
+ local -a dis_plugins
for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
_omz::log warn "plugin '$plugin' is not enabled."
@@ -301,7 +304,7 @@ function _omz::plugin::enable {
fi
# Check that plugin is not in $plugins
- local -a add_plugins=()
+ local -a add_plugins
for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
_omz::log warn "plugin '$plugin' is already enabled."
@@ -422,10 +425,8 @@ function _omz::plugin::load {
return 1
fi
- local plugins=("$@")
local plugin base has_completion=0
-
- for plugin in $plugins; do
+ for plugin in "$@"; do
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
base="$ZSH_CUSTOM/plugins/$plugin"
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
@@ -598,6 +599,16 @@ function _omz::pr::test {
)
}
+function _omz::reload {
+ # Delete current completion cache
+ command rm -f $_comp_dumpfile $ZSH_COMPDUMP
+
+ # Old zsh versions don't have ZSH_ARGZERO
+ local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
+ # Check whether to run a login shell
+ [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
+}
+
function _omz::theme {
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
cat >&2 <<EOF
@@ -630,17 +641,23 @@ function _omz::theme::list {
return
fi
+ # Print theme in use
+ if [[ -n "$ZSH_THEME" ]]; then
+ print -Pn "%U%BCurrent theme%b%u: "
+ [[ $ZSH_THEME = random ]] && echo "$RANDOM_THEME (via random)" || echo "$ZSH_THEME"
+ echo
+ fi
+
+ # Print custom themes if there are any
if (( ${#custom_themes} )); then
print -P "%U%BCustom themes%b%u:"
print -l ${(q-)custom_themes} | column -x
+ echo
fi
- if (( ${#builtin_themes} )); then
- (( ${#custom_themes} )) && echo # add a line of separation
-
- print -P "%U%BBuilt-in themes%b%u:"
- print -l ${(q-)builtin_themes} | column -x
- fi
+ # Print built-in themes
+ print -P "%U%BBuilt-in themes%b%u:"
+ print -l ${(q-)builtin_themes} | column -x
}
function _omz::theme::set {
@@ -727,6 +744,10 @@ function _omz::theme::use {
_omz::log error "%B$1%b theme not found"
return 1
fi
+
+ # Update theme settings
+ ZSH_THEME="$1"
+ [[ $1 = random ]] || unset RANDOM_THEME
}
function _omz::update {
diff --git a/lib/correction.zsh b/lib/correction.zsh
index c635236b5..4259d3418 100644
--- a/lib/correction.zsh
+++ b/lib/correction.zsh
@@ -9,6 +9,7 @@ if [[ "$ENABLE_CORRECTION" == "true" ]]; then
alias mv='nocorrect mv'
alias mysql='nocorrect mysql'
alias sudo='nocorrect sudo'
+ alias su='nocorrect su'
setopt correct_all
fi
diff --git a/lib/git.zsh b/lib/git.zsh
index c9363274c..9a615e77b 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -206,7 +206,8 @@ function git_prompt_status() {
STASHED UNMERGED AHEAD BEHIND DIVERGED
)
- local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
+ local status_text
+ status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
# Don't continue on a catastrophic failure
if [[ $? -eq 128 ]]; then
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index 33451ef1f..ef0d78895 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -10,7 +10,8 @@ function title {
emulate -L zsh
setopt prompt_subst
- [[ "$INSIDE_EMACS" == *term* ]] && return
+ # Don't set the title if inside emacs, unless using vterm
+ [[ -n "$INSIDE_EMACS" && "$INSIDE_EMACS" != vterm ]] && return
# if $2 is unset use $1 as default
# if it is set and empty, leave it as is
@@ -29,12 +30,9 @@ function title {
print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name
else
- # Try to use terminfo to set the title
- # If the feature is available set title
- if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
- echoti tsl
- print -Pn "$1"
- echoti fsl
+ # Try to use terminfo to set the title if the feature is available
+ if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
+ print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}"
fi
fi
;;
@@ -105,10 +103,12 @@ function omz_termsupport_preexec {
title '$CMD' '%100>...>$LINE%<<'
}
-autoload -U add-zsh-hook
-add-zsh-hook precmd omz_termsupport_precmd
-add-zsh-hook preexec omz_termsupport_preexec
+autoload -Uz add-zsh-hook
+if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then
+ add-zsh-hook precmd omz_termsupport_precmd
+ add-zsh-hook preexec omz_termsupport_preexec
+fi
# Keep Apple Terminal.app's current working directory updated
# Based on this answer: https://superuser.com/a/315029
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index 0b71de372..00947f72d 100644
--- a/lib/theme-and-appearance.zsh
+++ b/lib/theme-and-appearance.zsh
@@ -40,7 +40,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
fi
# enable diff color if possible.
-if command diff --color . . &>/dev/null; then
+if command diff --color /dev/null /dev/null &>/dev/null; then
alias diff='diff --color'
fi
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 545d980f0..b388b341d 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -1,3 +1,43 @@
+# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
+[ -n "$ZSH_VERSION" ] || {
+ # ANSI formatting function (\033[<code>m)
+ # 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
+ omz_f() {
+ [ $# -gt 0 ] || return
+ IFS=";" printf "\033[%sm" $*
+ }
+ # If stdout is not a terminal ignore all formatting
+ [ -t 1 ] || omz_f() { :; }
+
+ omz_ptree() {
+ # Get process tree of the current process
+ pid=$$; pids="$pid"
+ while [ ${pid-0} -ne 1 ] && ppid=$(ps -e -o pid,ppid | awk "\$1 == $pid { print \$2 }"); do
+ pids="$pids $pid"; pid=$ppid
+ done
+
+ # Show process tree
+ case "$(uname)" in
+ Linux) ps -o ppid,pid,command -f -p $pids 2>/dev/null ;;
+ Darwin|*) ps -o ppid,pid,command -p $pids 2>/dev/null ;;
+ esac
+
+ # If ps command failed, try Busybox ps
+ [ $? -eq 0 ] || ps -o ppid,pid,comm | awk "NR == 1 || index(\"$pids\", \$2) != 0"
+ }
+
+ {
+ shell=$(ps -o pid,comm | awk "\$1 == $$ { print \$2 }")
+ printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded from: $(omz_f 1)${shell}$(omz_f 22). "
+ printf "You need to run $(omz_f 1)zsh$(omz_f 22) instead.$(omz_f 0)\n"
+ printf "$(omz_f 33)Here's the process tree:$(omz_f 22)\n\n"
+ omz_ptree
+ printf "$(omz_f 0)\n"
+ } >&2
+
+ return 1
+}
+
# If ZSH is not defined, use the current script's directory.
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md
index d6b41ee40..c8ec1de1e 100644
--- a/plugins/archlinux/README.md
+++ b/plugins/archlinux/README.md
@@ -32,7 +32,7 @@ plugins=(... archlinux)
| pacfiles | `pacman -F` | Search package file names for matching strings |
| pacls | `pacman -Ql` | List files in a package |
| pacown | `pacman -Qo` | Show which package owns a file |
-| upgrade[²](#f2) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
+| upgrade[¹](#f1) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| Function | Description |
|----------------|-----------------------------------------------------------|
@@ -73,7 +73,7 @@ upgrades were available. Use `pacman -Que` instead.
| auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases |
| auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) |
| ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation |
-| upgrade[²](#f2) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
+| upgrade[¹](#f1) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| Function | Description |
|-----------------|---------------------------------------------------------------------|
@@ -99,7 +99,7 @@ upgrades were available. Use `pacman -Que` instead.
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
-| upgrade[²](#f2) | `pacaur -Syu` | Sync with repositories before upgrading packages |
+| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
#### Trizen
@@ -121,31 +121,9 @@ upgrades were available. Use `pacman -Que` instead.
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
-| upgrade[²](#f2) | `trizen -Syu` | Sync with repositories before upgrading packages |
+| upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
-#### Yaourt[¹](#f1)
-
-| Alias | Command | Description |
-|---------|-----------------------------------|---------------------------------------------------------------------|
-| yaconf | `yaourt -C` | Fix all configuration files with vimdiff |
-| yain | `yaourt -S` | Install packages from the repositories |
-| yains | `yaourt -U` | Install a package from a local file |
-| yainsd | `yaourt -S --asdeps` | Install packages as dependencies of another package |
-| yaloc | `yaourt -Qi` | Display information about a package in the local database |
-| yalocs | `yaourt -Qs` | Search for packages in the local database |
-| yalst | `yaourt -Qe` | List installed packages including from AUR (tagged as "local") |
-| yamir | `yaourt -Syy` | Force refresh of all package lists after updating mirrorlist |
-| yaorph | `yaourt -Qtd` | Remove orphans using yaourt |
-| yare | `yaourt -R` | Remove packages, keeping its settings and dependencies |
-| yarem | `yaourt -Rns` | Remove packages, including its settings and unneeded dependencies |
-| yarep | `yaourt -Si` | Display information about a package in the repositories |
-| yareps | `yaourt -Ss` | Search for packages in the repositories |
-| yaupd | `yaourt -Sy` | Update and refresh local package, ABS and AUR databases |
-| yaupg | `yaourt -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
-| yasu | `yaourt -Syua --no-confirm` | Same as `yaupg`, but without confirmation |
-| upgrade[²](#f2) | `yaourt -Syu` | Sync with repositories before upgrading packages |
-
-#### Yay[¹](#f1)
+#### Yay
| Alias | Command | Description |
|---------|--------------------------------|-------------------------------------------------------------------|
@@ -165,23 +143,19 @@ upgrades were available. Use `pacman -Que` instead.
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
-| upgrade[²](#f2) | `yay -Syu` | Sync with repositories before upgrading packages |
+| upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
---
<span id="f1">¹</span>
-Yay and Yaourt aliases overlap. If both are installed, yay will take precedence.
-
-<span id="f2">²</span>
The `upgrade` alias is set for all package managers. Its value will depend on
whether the package manager is installed, checked in the following order:
1. `yay`
-2. `yaourt`
-3. `trizen`
-4. `pacaur`
-5. `aura`
-6. `pacman`
+2. `trizen`
+3. `pacaur`
+4. `aura`
+5. `pacman`
## Contributors
diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh
index c94fb8f6c..0c5782d98 100644
--- a/plugins/archlinux/archlinux.plugin.zsh
+++ b/plugins/archlinux/archlinux.plugin.zsh
@@ -104,7 +104,7 @@ if (( $+commands[aura] )); then
alias auras='aura -As --both'
alias auupd="sudo aura -Sy"
alias auupg='sudo sh -c "aura -Syu && aura -Au"'
- alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
+ alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
alias upgrade='sudo aura -Syu'
# extra bonus specially for aura
@@ -153,26 +153,6 @@ if (( $+commands[trizen] )); then
alias upgrade='trizen -Syu'
fi
-if (( $+commands[yaourt] )); then
- alias yaconf='yaourt -C'
- alias yaupg='yaourt -Syua'
- alias yasu='yaourt -Syua --noconfirm'
- alias yain='yaourt -S'
- alias yains='yaourt -U'
- alias yare='yaourt -R'
- alias yarem='yaourt -Rns'
- alias yarep='yaourt -Si'
- alias yareps='yaourt -Ss'
- alias yaloc='yaourt -Qi'
- alias yalocs='yaourt -Qs'
- alias yalst='yaourt -Qe'
- alias yaorph='yaourt -Qtd'
- alias yainsd='yaourt -S --asdeps'
- alias yamir='yaourt -Syy'
- alias yaupd="yaourt -Sy"
- alias upgrade='yaourt -Syu'
-fi
-
if (( $+commands[yay] )); then
alias yaconf='yay -Pg'
alias yaupg='yay -Syu'
@@ -192,4 +172,3 @@ if (( $+commands[yay] )); then
alias yaupd="yay -Sy"
alias upgrade='yay -Syu'
fi
-
diff --git a/plugins/battery/README.md b/plugins/battery/README.md
index c2554a36d..18e5bd882 100644
--- a/plugins/battery/README.md
+++ b/plugins/battery/README.md
@@ -8,15 +8,22 @@ To use, add `battery` to the list of plugins in your `.zshrc` file:
Then, add the `battery_pct_prompt` function to your custom theme. For example:
-```
+```zsh
RPROMPT='$(battery_pct_prompt) ...'
```
## Requirements
-On Linux, you must have the `acpi` tool installed on your operating system.
+- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
+ On Debian/Ubuntu, you can do that with `sudo apt install acpi` or `sudo apt install acpitool`.
-Here's an example of how to install with apt:
-```
-sudo apt-get install acpi
-```
+- On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
+
+ 1. The `Termux:API` addon app installed:
+ [Google Play](https://play.google.com/store/apps/details?id=com.termux.api) | [F-Droid](https://f-droid.org/packages/com.termux.api/)
+
+ 2. The `termux-api` package installed within termux:
+
+ ```sh
+ pkg install termux-api
+ ```
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
index a525fd7da..db5eeb93a 100644
--- a/plugins/battery/battery.plugin.zsh
+++ b/plugins/battery/battery.plugin.zsh
@@ -10,17 +10,17 @@
# Author: J (927589452) #
# Modified to add support for FreeBSD #
###########################################
+# Author: Avneet Singh (kalsi-avneet) #
+# Modified to add support for Android #
+###########################################
if [[ "$OSTYPE" = darwin* ]]; then
-
function battery_is_charging() {
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
}
-
function battery_pct() {
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
}
-
function battery_pct_remaining() {
if battery_is_charging; then
echo "External Power"
@@ -28,7 +28,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
battery_pct
fi
}
-
function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
@@ -42,7 +41,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
echo "∞"
fi
}
-
function battery_pct_prompt () {
local battery_pct color
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
@@ -61,17 +59,14 @@ if [[ "$OSTYPE" = darwin* ]]; then
}
elif [[ "$OSTYPE" = freebsd* ]]; then
-
function battery_is_charging() {
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
}
-
function battery_pct() {
if (( $+commands[sysctl] )); then
sysctl -n hw.acpi.battery.life
fi
}
-
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
@@ -79,7 +74,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "External Power"
fi
}
-
function battery_time_remaining() {
local remaining_time
remaining_time=$(sysctl -n hw.acpi.battery.time)
@@ -89,7 +83,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
printf %02d:%02d $hour $minute
fi
}
-
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
@@ -106,19 +99,83 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
-
+elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
+ function battery_is_charging() {
+ termux-battery-status 2>/dev/null | command awk '/status/ { exit ($0 ~ /DISCHARGING/) }'
+ }
+ function battery_pct() {
+ # Sample output:
+ # {
+ # "health": "GOOD",
+ # "percentage": 93,
+ # "plugged": "UNPLUGGED",
+ # "status": "DISCHARGING",
+ # "temperature": 29.0,
+ # "current": 361816
+ # }
+ termux-battery-status 2>/dev/null | command awk '/percentage/ { gsub(/[,]/,""); print $2}'
+ }
+ function battery_pct_remaining() {
+ if ! battery_is_charging; then
+ battery_pct
+ else
+ echo "External Power"
+ fi
+ }
+ function battery_time_remaining() { } # Not available on android
+ function battery_pct_prompt() {
+ local battery_pct color
+ battery_pct=$(battery_pct_remaining)
+ if battery_is_charging; then
+ echo "∞"
+ else
+ if [[ $battery_pct -gt 50 ]]; then
+ color='green'
+ elif [[ $battery_pct -gt 20 ]]; then
+ color='yellow'
+ else
+ color='red'
+ fi
+ echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
+ fi
+ }
elif [[ "$OSTYPE" = linux* ]]; then
-
function battery_is_charging() {
- ! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
+ if (( $+commands[acpitool] )); then
+ ! acpitool 2>/dev/null | command grep -qE '^\s+Battery.*Discharging'
+ elif (( $+commands[acpi] )); then
+ ! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
+ fi
}
-
function battery_pct() {
- if (( $+commands[acpi] )); then
- acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]'
+ if (( $+commands[acpitool] )); then
+ # Sample output:
+ # Battery #1 : Unknown, 99.55%
+ # Battery #2 : Discharging, 49.58%, 01:12:05
+ # All batteries : 62.60%, 02:03:03
+ local -i pct=$(acpitool 2>/dev/null | command awk -F, '
+ /^\s+All batteries/ {
+ gsub(/[^0-9.]/, "", $1)
+ pct=$1
+ exit
+ }
+ !pct && /^\s+Battery/ {
+ gsub(/[^0-9.]/, "", $2)
+ pct=$2
+ }
+ END { print pct }
+ ')
+ echo $pct
+ elif (( $+commands[acpi] )); then
+ # Sample output:
+ # Battery 0: Discharging, 0%, rate information unavailable
+ # Battery 1: Full, 100%
+ acpi 2>/dev/null | command awk -F, '
+ /rate information unavailable/ { next }
+ /^Battery.*: /{ gsub(/[^0-9]/, "", $2); print $2; exit }
+ '
fi
}
-
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
@@ -126,13 +183,11 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "External Power"
fi
}
-
function battery_time_remaining() {
if ! battery_is_charging; then
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
}
-
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
@@ -149,7 +204,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
-
else
# Empty functions so we don't cause errors in prompts
function battery_is_charging { false }
@@ -174,7 +228,7 @@ function battery_level_gauge() {
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
- local battery_remaining_percentage=$(battery_pct)
+ local -i battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
diff --git a/plugins/chucknorris/README.md b/plugins/chucknorris/README.md
index 35f989180..b51875de9 100644
--- a/plugins/chucknorris/README.md
+++ b/plugins/chucknorris/README.md
@@ -1,8 +1,6 @@
# chucknorris
-Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
-
-**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
+Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
To use it add `chucknorris` to the plugins array in you zshrc file.
diff --git a/plugins/chucknorris/chucknorris.plugin.zsh b/plugins/chucknorris/chucknorris.plugin.zsh
index 1dbb04ef0..b90abe320 100644
--- a/plugins/chucknorris/chucknorris.plugin.zsh
+++ b/plugins/chucknorris/chucknorris.plugin.zsh
@@ -1,28 +1,24 @@
-# chucknorris: Chuck Norris fortunes
+() {
+ # %x: name of file containing code being executed
+ local fortunes_dir="${${(%):-%x}:h}/fortunes"
-# Automatically generate or update Chuck's compiled fortune data file
-# $0 must be used outside a local function. This variable name is unlikly to collide.
-CHUCKNORRIS_PLUGIN_DIR=${0:h}
+ # Aliases
+ alias chuck="fortune -a $fortunes_dir"
+ alias chuck_cow="chuck | cowthink"
-() {
-local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes
-if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then
- # For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
- local strfile=strfile
- if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then
- strfile=/usr/sbin/strfile
+ # Automatically generate or update Chuck's compiled fortune data file
+ if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
+ return
fi
- if which $strfile &> /dev/null; then
- $strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null
- else
+
+ # For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
+ local strfile="${commands[strfile]:-/usr/sbin/strfile}"
+ if [[ ! -x "$strfile" ]]; then
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
+ return
fi
-fi
-# Aliases
-alias chuck="fortune -a $DIR"
-alias chuck_cow="chuck | cowthink"
+ # Generate the compiled fortune data file
+ $strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
}
-
-unset CHUCKNORRIS_PLUGIN_DIR
diff --git a/plugins/chucknorris/fortunes/chucknorris b/plugins/chucknorris/fortunes/chucknorris
index 0ddb6c03b..6ba5bb9b5 100644
--- a/plugins/chucknorris/fortunes/chucknorris
+++ b/plugins/chucknorris/fortunes/chucknorris
@@ -558,3 +558,11 @@ You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "God
%
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
%
+Chuck Norris made the first Giraffe by uppercutting a horse.
+%
+Chuck Norris can hear sign language.
+%
+Chuck Norris make onions cry.
+%
+Chuck Norris doesn't shake hands, he makes them tremble.
+%
diff --git a/plugins/docker-compose/_docker-compose b/plugins/docker-compose/_docker-compose
index 808b068a3..c6b733500 100644
--- a/plugins/docker-compose/_docker-compose
+++ b/plugins/docker-compose/_docker-compose
@@ -121,12 +121,6 @@ __docker-compose_subcommand() {
'--parallel[Build images in parallel.]' \
'*:services:__docker-compose_services_from_build' && ret=0
;;
- (bundle)
- _arguments \
- $opts_help \
- '--push-images[Automatically push images for any services which have a `build` option specified.]' \
- '(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0
- ;;
(config)
_arguments \
$opts_help \
@@ -290,7 +284,7 @@ __docker-compose_subcommand() {
(up)
_arguments \
$opts_help \
- '(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.]' \
+ '(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit and --attach-dependencies.]' \
$opts_no_color \
$opts_no_deps \
$opts_force_recreate \
@@ -298,6 +292,7 @@ __docker-compose_subcommand() {
$opts_no_build \
"(--no-build)--build[Build images before starting containers.]" \
"(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \
+ "(-d)--attach-dependencies[Attach to dependent containers. Incompatible with -d.]" \
'(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \
'--scale[SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.]:service scale SERVICE=NUM: ' \
'--exit-code-from=[Return the exit code of the selected service container. Implies --abort-on-container-exit]:service:__docker-compose_services' \
@@ -341,11 +336,13 @@ _docker-compose() {
'(- :)'{-h,--help}'[Get help]' \
'*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
+ '--env-file[Specify an alternate environment file (default: .env)]:env-file:_files' \
"--compatibility[If set, Compose will attempt to convert keys in v3 files to their non-Swarm equivalent]" \
'(- :)'{-v,--version}'[Print version and exit]' \
'--verbose[Show more output]' \
'--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \
'--no-ansi[Do not print ANSI control characters]' \
+ '--ansi=[Control when to print ANSI control characters]:when:(never always auto)' \
'(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \
'--tls[Use TLS; implied by --tlsverify]' \
'--tlscacert=[Trust certs signed only by this CA]:ca path:' \
@@ -359,6 +356,7 @@ _docker-compose() {
local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
relevant_compose_flags=(
+ "--env-file"
"--file" "-f"
"--host" "-H"
"--project-name" "-p"
diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh
index 85e03d343..13985fc82 100644
--- a/plugins/docker-compose/docker-compose.plugin.zsh
+++ b/plugins/docker-compose/docker-compose.plugin.zsh
@@ -1,28 +1,24 @@
-# Authors:
-# https://github.com/tristola
-#
-# Docker-compose related zsh aliases
+# support Compose v2 as docker CLI plugin
+DOCKER_CONTEXT=default command docker compose &>/dev/null \
+ && dccmd='docker compose' \
+ || dccmd='docker-compose'
-# Aliases ###################################################################
+alias dco="$dccmd"
+alias dcb="$dccmd build"
+alias dce="$dccmd exec"
+alias dcps="$dccmd ps"
+alias dcrestart="$dccmd restart"
+alias dcrm="$dccmd rm"
+alias dcr="$dccmd run"
+alias dcstop="$dccmd stop"
+alias dcup="$dccmd up"
+alias dcupb="$dccmd up --build"
+alias dcupd="$dccmd up -d"
+alias dcdn="$dccmd down"
+alias dcl="$dccmd logs"
+alias dclf="$dccmd logs -f"
+alias dcpull="$dccmd pull"
+alias dcstart="$dccmd start"
+alias dck="$dccmd kill"
-# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator'
-# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html
-
-alias dco='docker-compose'
-
-alias dcb='docker-compose build'
-alias dce='docker-compose exec'
-alias dcps='docker-compose ps'
-alias dcrestart='docker-compose restart'
-alias dcrm='docker-compose rm'
-alias dcr='docker-compose run'
-alias dcstop='docker-compose stop'
-alias dcup='docker-compose up'
-alias dcupb='docker-compose up --build'
-alias dcupd='docker-compose up -d'
-alias dcdn='docker-compose down'
-alias dcl='docker-compose logs'
-alias dclf='docker-compose logs -f'
-alias dcpull='docker-compose pull'
-alias dcstart='docker-compose start'
-alias dck='docker-compose kill'
+unset dccmd
diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
index 0b602d12a..027c7550f 100644
--- a/plugins/emacs/emacs.plugin.zsh
+++ b/plugins/emacs/emacs.plugin.zsh
@@ -9,57 +9,55 @@
# - You can share opened buffered across opened frames.
# - Configuration changes made at runtime are applied to all frames.
-
-if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then
- export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh"
-
- # set EDITOR if not already defined.
- export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
-
- alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
- alias e=emacs
- # open terminal emacsclient
- alias te="$EMACS_PLUGIN_LAUNCHER -nw"
-
- # same than M-x eval but from outside Emacs.
- alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
- # create a new X frame
- alias eframe='emacsclient --alternate-editor "" --create-frame'
-
- # Emacs ANSI Term tracking
- if [[ -n "$INSIDE_EMACS" ]]; then
- chpwd_emacs() { print -P "\033AnSiTc %d"; }
- print -P "\033AnSiTc %d" # Track current working directory
- print -P "\033AnSiTu %n" # Track username
-
- # add chpwd hook
- autoload -Uz add-zsh-hook
- add-zsh-hook chpwd chpwd_emacs
- fi
-
- # Write to standard output the path to the file
- # opened in the current buffer.
- function efile {
- local cmd="(buffer-file-name (window-buffer))"
- "$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \"
- }
-
- # Write to standard output the directory of the file
- # opened in the the current buffer
- function ecd {
- local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
- (if buf-name (file-name-directory buf-name)))"
-
- local dir="$($EMACS_PLUGIN_LAUNCHER --eval $cmd | tr -d \")"
- if [ -n "$dir" ] ;then
- echo "$dir"
- else
- echo "can not deduce current buffer filename." >/dev/stderr
- return 1
- fi
- }
+# Require emacs version to be minimum 24
+autoload -Uz is-at-least
+is-at-least 24 "${${(Az)"$(emacsclient --version 2>/dev/null)"}[2]}" || return 0
+
+# Path to custom emacsclient launcher
+export EMACS_PLUGIN_LAUNCHER="${0:A:h}/emacsclient.sh"
+
+# set EDITOR if not already defined.
+export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
+
+alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
+alias e=emacs
+# open terminal emacsclient
+alias te="$EMACS_PLUGIN_LAUNCHER -nw"
+
+# same than M-x eval but from outside Emacs.
+alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
+# create a new X frame
+alias eframe='emacsclient --alternate-editor "" --create-frame'
+
+# Emacs ANSI Term tracking
+if [[ -n "$INSIDE_EMACS" ]]; then
+ chpwd_emacs() { print -P "\033AnSiTc %d"; }
+ print -P "\033AnSiTc %d" # Track current working directory
+ print -P "\033AnSiTu %n" # Track username
+
+ # add chpwd hook
+ autoload -Uz add-zsh-hook
+ add-zsh-hook chpwd chpwd_emacs
fi
-## Local Variables:
-## mode: sh
-## End:
+# Write to standard output the path to the file
+# opened in the current buffer.
+function efile {
+ local cmd="(buffer-file-name (window-buffer))"
+ local file="$("$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \")"
+
+ if [[ -z "$file" ]]; then
+ echo "Can't deduce current buffer filename." >&2
+ return 1
+ fi
+
+ echo "$file"
+}
+
+# Write to standard output the directory of the file
+# opened in the the current buffer
+function ecd {
+ local file
+ file="$(efile)" || return $?
+ echo "${file:h}"
+}
diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
index 04a2c2afd..25efe0d68 100755
--- a/plugins/emacs/emacsclient.sh
+++ b/plugins/emacs/emacsclient.sh
@@ -1,29 +1,38 @@
#!/bin/sh
-_emacsfun()
-{
- # get list of emacs frames.
- frameslist=`emacsclient --alternate-editor '' --eval '(frame-list)' 2>/dev/null | egrep -o '(frame)+'`
+emacsfun() {
+ local cmd frames
- if [ "$(echo "$frameslist" | sed -n '$=')" -ge 2 ] ;then
- # prevent creating another X frame if there is at least one present.
- emacsclient --alternate-editor "" "$@"
- else
- # Create one if there is no X window yet.
- emacsclient --alternate-editor "" --create-frame "$@"
- fi
-}
+ # Build the Emacs Lisp command to check for suitable frames
+ # See https://www.gnu.org/software/emacs/manual/html_node/elisp/Frames.html#index-framep
+ case "$*" in
+ *-t*|*--tty*|*-nw*) cmd="(memq 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are tty frames
+ *) cmd="(delete 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are graphical terminals (x, w32, ns)
+ esac
+
+ # Check if there are suitable frames
+ frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null)"
+ # Only create another X frame if there isn't one present
+ if [ -z "$frames" -o "$frames" = nil ]; then
+ emacsclient --alternate-editor "" --create-frame "$@"
+ return $?
+ fi
-# adopted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
+ emacsclient --alternate-editor "" "$@"
+}
+
+# Adapted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
# If the second argument is - then write stdin to a tempfile and open the
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
-if [ "$#" -ge "2" -a "$2" = "-" ]
-then
- tempfile="$(mktemp --tmpdir emacs-stdin-$USERNAME.XXXXXXX 2>/dev/null \
- || mktemp -t emacs-stdin-$USERNAME)" # support BSD mktemp
- cat - > "$tempfile"
- _emacsfun --no-wait $tempfile
-else
- _emacsfun "$@"
+if [ $# -ge 2 -a "$2" = "-" ]; then
+ # Create a tempfile to hold stdin
+ tempfile="$(mktemp --tmpdir emacs-stdin-$USERNAME.XXXXXXX 2>/dev/null \
+ || mktemp -t emacs-stdin-$USERNAME)" # support BSD mktemp
+ # Redirect stdin to the tempfile
+ cat - > "$tempfile"
+ # Reset $2 to the tempfile so that "$@" works as expected
+ set -- "$1" "$tempfile" "${@:3}"
fi
+
+emacsfun "$@"
diff --git a/plugins/git/README.md b/plugins/git/README.md
index e53d93b0b..113080874 100644
--- a/plugins/git/README.md
+++ b/plugins/git/README.md
@@ -47,6 +47,7 @@ plugins=(... git)
| gcb | git checkout -b |
| gcf | git config --list |
| gcl | git clone --recurse-submodules |
+| gccd | git clone --recurse-submodules "$@" && cd "$(basename $_ .git)" |
| gclean | git clean -id |
| gpristine | git reset --hard && git clean -dffx |
| gcm | git checkout $(git_main_branch) |
@@ -66,7 +67,7 @@ plugins=(... git)
| gds | git diff --staged |
| gdt | git diff-tree --no-commit-id --name-only -r |
| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)&ast;.lock" |
-| gdu | git diff @{u} |
+| gdup | git diff @{upstream} |
| gdv | git diff -w $@ \| view - |
| gdw | git diff --word-diff |
| gf | git fetch |
@@ -90,8 +91,8 @@ plugins=(... git)
| gignore | git update-index --assume-unchanged |
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
-| gk | gitk --all --branches |
-| gke | gitk --all $(git log -g --pretty=%h) |
+| gk | gitk --all --branches &! |
+| gke | gitk --all $(git log -g --pretty=%h) &! |
| gl | git pull |
| glg | git log --stat |
| glgp | git log --stat -p |
@@ -168,6 +169,8 @@ plugins=(... git)
| gsu | git submodule update |
| gsw | git switch |
| gswc | git switch -c |
+| gswm | git switch $(git_main_branch) |
+| gswd | git switch $(git_develop_branch) |
| gts | git tag -s |
| gtv | git tag \| sort -V |
| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl |
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 76e0faed3..5a3c98287 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -97,6 +97,13 @@ alias gcas='git commit -a -s'
alias gcasm='git commit -a -s -m'
alias gcb='git checkout -b'
alias gcf='git config --list'
+
+function gccd() {
+ command git clone --recurse-submodules "$@"
+ [[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}"
+}
+compdef _git gccd=git-clone
+
alias gcl='git clone --recurse-submodules'
alias gclean='git clean -id'
alias gpristine='git reset --hard && git clean -dffx'
@@ -119,7 +126,7 @@ alias gdcw='git diff --cached --word-diff'
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r'
-alias gdu='git diff @{u}'
+alias gdup='git diff @{upstream}'
alias gdw='git diff --word-diff'
function gdnolock() {
@@ -201,8 +208,8 @@ alias gignore='git update-index --assume-unchanged'
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
-alias gk='\gitk --all --branches'
-alias gke='\gitk --all $(git log -g --pretty=%h)'
+alias gk='\gitk --all --branches &!'
+alias gke='\gitk --all $(git log -g --pretty=%h) &!'
alias gl='git pull'
alias glg='git log --stat'
@@ -288,6 +295,8 @@ alias gstall='git stash --all'
alias gsu='git submodule update'
alias gsw='git switch'
alias gswc='git switch -c'
+alias gswm='git switch $(git_main_branch)'
+alias gswd='git switch $(git_develop_branch)'
alias gts='git tag -s'
alias gtv='git tag | sort -V'
diff --git a/plugins/gpg-agent/README.md b/plugins/gpg-agent/README.md
index 9c1e6d2cc..8eeb94f92 100644
--- a/plugins/gpg-agent/README.md
+++ b/plugins/gpg-agent/README.md
@@ -2,7 +2,7 @@
Enables [GPG's gpg-agent](https://www.gnupg.org/documentation/manuals/gnupg/) if it is not running.
-To use it, add gpg-agent to the plugins array of your zshrc file:
+To use it, add `gpg-agent` to the plugins array of your zshrc file:
```zsh
plugins=(... gpg-agent)
diff --git a/plugins/gpg-agent/gpg-agent.plugin.zsh b/plugins/gpg-agent/gpg-agent.plugin.zsh
index 3e24c2527..0adc8de5d 100644
--- a/plugins/gpg-agent/gpg-agent.plugin.zsh
+++ b/plugins/gpg-agent/gpg-agent.plugin.zsh
@@ -1,16 +1,17 @@
-# Enable gpg-agent if it is not running-
-# --use-standard-socket will work from version 2 upwards
-
-AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2)
-
-if [[ ! -S $AGENT_SOCK ]]; then
- gpg-agent --daemon --use-standard-socket &>/dev/null
-fi
export GPG_TTY=$TTY
-# Set SSH to use gpg-agent if it's enabled
-GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf"
-if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then
- export SSH_AUTH_SOCK="$AGENT_SOCK.ssh"
+# Fix for passphrase prompt on the correct tty
+# See https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002denable_002dssh_002dsupport
+function _gpg-agent_update-tty_preexec {
+ gpg-connect-agent updatestartuptty /bye &>/dev/null
+}
+autoload -U add-zsh-hook
+add-zsh-hook preexec _gpg-agent_update-tty_preexec
+
+# If enable-ssh-support is set, fix ssh agent integration
+if [[ $(gpgconf --list-options gpg-agent | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
unset SSH_AGENT_PID
+ if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
+ export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
+ fi
fi
diff --git a/plugins/jsontools/jsontools.plugin.zsh b/plugins/jsontools/jsontools.plugin.zsh
index ed45cfa8e..857ca0ec9 100644
--- a/plugins/jsontools/jsontools.plugin.zsh
+++ b/plugins/jsontools/jsontools.plugin.zsh
@@ -7,7 +7,7 @@ if [[ -n "$JSONTOOLS_METHOD" ]]; then
fi
# If method undefined, find the first one that is installed
-if [[ ! -v JSONTOOLS_METHOD ]]; then
+if [[ -z "$JSONTOOLS_METHOD" ]]; then
for JSONTOOLS_METHOD in node python ruby; do
# If method found, break out of loop
(( $+commands[$JSONTOOLS_METHOD] )) && break
@@ -16,7 +16,7 @@ if [[ ! -v JSONTOOLS_METHOD ]]; then
done
# If no methods were found, exit the plugin
- [[ -v JSONTOOLS_METHOD ]] || return 1
+ [[ -n "$JSONTOOLS_METHOD" ]] || return 1
fi
# Define json tools for each method
diff --git a/plugins/juju/README.md b/plugins/juju/README.md
new file mode 100644
index 000000000..49f8b0d47
--- /dev/null
+++ b/plugins/juju/README.md
@@ -0,0 +1,117 @@
+# juju plugin
+
+This plugin provides useful aliases and functions for [juju](https://juju.is/) (for TAB completion,
+refer to the [official repo](https://github.com/juju/juju/blob/develop/etc/bash_completion.d/juju)).
+
+To use this plugin, add `juju` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... juju)
+```
+
+## Aliases
+
+Naming convention:
+
+- `!` suffix: `--force --no-wait -y`.
+- `ds` suffix: `--destroy-storage`.
+
+### General
+
+| Alias | Command | Description |
+|--------|---------------------------------------------|--------------------------------------------------------|
+| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
+| `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
+| `jh` | `juju help` | Show help on a command or other topic |
+| `jssl` | `juju juju show-status-log` | Output past statuses for the specified entity |
+| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
+| `jst` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
+
+### Bootstrap
+
+| Alias | Command | Description |
+|-------|---------------------------|-------------------------------------------|
+| `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
+| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
+
+### Controller
+
+| Alias | Command | Description |
+|----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------|
+| `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller |
+| `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller |
+| `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage |
+| `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage |
+| `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller |
+| `jsw` | `juju switch` | Select or identify the current controller and model |
+
+### Model
+
+| Alias | Command | Description |
+|----------|-------------------------------------------------------------|-------------------------------------------------------|
+| `jam` | `juju add-model` | Add a hosted model |
+| `jdm` | `juju destroy-model` | Non-recoverable, complete removal of a model |
+| `jdm!` | `juju destroy-model --force --no-wait -y` | Non-recoverable, complete removal of a model |
+| `jdmds` | `juju destroy-model --destroy-storage` | Non-recoverable, complete removal of a model |
+| `jdmds!` | `juju destroy-model --destroy-storage --force --no-wait -y` | Non-recoverable, complete removal of a model |
+| `jmc` | `juju model-config` | Display or set configuration values on a model |
+| `jm` | `juju models` | List models a user can access on a controller |
+| `jshm` | `juju show-model` | Show information about the current or specified model |
+| `jsw` | `juju switch` | Select or identify the current controller and model |
+
+### Application / unit
+
+| Alias | Command | Description |
+|----------|---------------------------------------------------------------|---------------------------------------------------------------------------|
+| `jc` | `juju config` | Get, set, or reset configuration for a deployed application |
+| `jde` | `juju deploy --channel=edge` | Deploy a new application or bundle from the edge channel |
+| `jd` | `juju deploy` | Deploy a new application or bundle |
+| `jra` | `juju run-action` | Queue an action for execution |
+| `jraw` | `juju run-action --wait` | Queue an action for execution and wait for results, with optional timeout |
+| `jrm` | `juju remove-application` | Remove application |
+| `jrm!` | `juju remove-application --force --no-wait` | Remove application forcefully |
+| `jrmds` | `juju remove-application --destroy-storage` | Remove application and destroy attached storage |
+| `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage |
+| `jrp` | `juju refresh --path` | Upgrade charm from local charm file |
+| `jsa` | `juju scale-application` | Set the desired number of application units |
+| `jsh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
+| `jshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
+| `jsu` | `juju show-unit` | Displays information about a unit |
+
+### Storage
+
+| Alias | Command | Description |
+|---------|-------------------------------|-------------------------------------------------|
+| `jrs` | `juju remove-storage` | Remove storage |
+| `jrs!` | `juju remove-storage --force` | Remove storage even if it is currently attached |
+
+### Relation
+
+| Alias | Command | Description |
+|-----------|--------------------------------|-------------------------------------------------------------------|
+| `jrel` | `juju relate` | Relate two applications |
+| `jrmrel` | `juju remove-relation` | Remove an existing relation between two applications. |
+| `jrmrel!` | `juju remove-relation --force` | Remove an existing relation between two applications, forcefully. |
+
+### Cross-model relation (CMR)
+
+| Alias | Command | Description |
+|----------|--------------------|----------------------------------------------------------------|
+| `jex` | `juju expose` | Make an application publicly available over the network |
+| `jof` | `juju offer` | Offer application endpoints for use in other models |
+| `jcon` | `juju consume` | Add a remote offer to the model |
+| `jrmsas` | `juju remove-saas` | Remove consumed applications (SAAS) from the model |
+| `junex` | `juju unexpose` | Remove public availability over the network for an application |
+
+### Bundle
+
+| Alias | Command | Description |
+|-------|----------------------|-------------------------------------------------------------|
+| `jeb` | `juju export-bundle` | Export the current model configuration as a reusable bundle |
+
+## Functions
+
+- `jaddr <app_name> [unit_num]`: display app or unit IP address.
+- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data.
+- `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval
+ (default: 5s); you may pass additional arguments to `watch`.
diff --git a/plugins/juju/juju.plugin.zsh b/plugins/juju/juju.plugin.zsh
new file mode 100644
index 000000000..07f15b392
--- /dev/null
+++ b/plugins/juju/juju.plugin.zsh
@@ -0,0 +1,127 @@
+# ---------------------------------------------------------- #
+# Aliases and functions for juju (https://juju.is) #
+# ---------------------------------------------------------- #
+
+# Load TAB completions
+# You need juju's bash completion script installed. By default bash-completion's
+# location will be used (i.e. pkg-config --variable=completionsdir bash-completion).
+completion_file="$(pkg-config --variable=completionsdir bash-completion 2>/dev/null)/juju" || \
+ completion_file="/usr/share/bash-completion/completions/juju"
+[[ -f "$completion_file" ]] && source "$completion_file"
+unset completion_file
+
+# ---------------------------------------------------------- #
+# Aliases (in alphabetic order) #
+# #
+# Generally, #
+# - `!` means --force --no-wait -y #
+# - `ds` suffix means --destroy-storage #
+# ---------------------------------------------------------- #
+alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\
+ --config update-status-hook-interval=\"60m\""
+alias jb='juju bootstrap'
+alias jbm='juju bootstrap microk8s'
+alias jc='juju config'
+alias jdc='juju destroy-controller --destroy-all-models'
+alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y'
+alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage'
+alias 'jdcds!'='juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y'
+alias jdm='juju destroy-model'
+alias 'jdm!'='juju destroy-model --force --no-wait -y'
+alias jdmds='juju destroy-model --destroy-storage'
+alias 'jdmds!'='juju destroy-model --destroy-storage --force --no-wait -y'
+alias jde='juju deploy --channel=edge'
+alias jd='juju deploy'
+alias jdl='juju debug-log --ms'
+alias jdlr='juju debug-log --ms --replay'
+alias jcon='juju consume'
+alias jeb='juju export-bundle'
+alias jex='juju expose'
+alias jh='juju help'
+alias jkc='juju kill-controller -y -t 0'
+alias jm='juju models'
+alias jmc='juju model-config'
+alias jof='juju offer'
+alias jra='juju run-action'
+alias jraw='juju run-action --wait'
+alias jrel='juju relate'
+alias jrm='juju remove-application'
+alias 'jrm!'='juju remove-application --force --no-wait'
+alias jrmds='juju remove-application --destroy-storage'
+alias 'jrmds!'='juju remove-application --destroy-storage --force --no-wait'
+alias jrmrel='juju remove-relation'
+alias 'jrmrel!'='juju remove-relation --force'
+alias jrmsas='juju remove-saas'
+alias jrp='juju refresh --path'
+alias jrs='juju remove-storage'
+alias 'jrs!'='juju remove-storage --force'
+alias jsa='juju scale-application'
+alias jsh='juju ssh'
+alias jshc='juju ssh --container'
+alias jshm='juju show-model'
+alias jssl='juju show-status-log'
+alias jstj='juju status --format=json'
+alias jst='juju status --relations --storage --color'
+alias jsu='juju show-unit'
+alias jsw='juju switch'
+
+# ---------------------------------------------------------- #
+# Functions (in alphabetic order) #
+# ---------------------------------------------------------- #
+
+# Get app or unit address
+jaddr() {
+ # $1 = app name
+ # $2 = unit number (optional)
+ if (( ! ${+commands[jq]} )); then
+ echo "jq is required but could not be found." >&2
+ return 1
+ fi
+
+ if [[ $# -eq 1 ]]; then
+ # Get app address
+ juju status "$1" --format=json \
+ | jq -r ".applications.\"$1\".address"
+ elif [[ $# -eq 2 ]]; then
+ # Get unit address
+ juju status "$1/$2" --format=json \
+ | jq -r ".applications.\"$1\".units.\"$1/$2\".address"
+ else
+ echo "Invalid number of arguments."
+ echo "Usage: jaddr <app-name> [<unit-number>]"
+ echo "Example: jaddr karma"
+ echo "Example: jaddr karma 0"
+ return 1
+ fi
+}
+
+# Display app and unit relation data
+jreld() {
+ # $1 = relation name
+ # $2 = app name
+ # $3 = unit number
+ if [[ $# -ne 3 ]]; then
+ echo "Invalid number of arguments."
+ echo "Usage: jreld <relation-name> <app-name> <unit-number>"
+ echo "Example: jreld karma-dashboard alertmanager 0"
+ return 1
+ fi
+
+ local relid="$(juju run "relation-ids $1" --unit $2/$3)"
+ if [[ -z "$relid" ]]; then
+ return 1
+ fi
+
+ echo "App data:"
+ juju run "relation-get -r $relid --app - $2" --unit $2/$3
+ echo
+ echo "Unit data:"
+ juju run "relation-get -r $relid - $2" --unit $2/$3
+}
+
+# Watch juju status, with optional interval (default: 5 sec)
+wjst() {
+ local interval="${1:-5}"
+ shift $(( $# > 0 ))
+ watch -n "$interval" --color juju status --relations --storage --color "$@"
+}
diff --git a/plugins/mercurial/README.md b/plugins/mercurial/README.md
index 80ea2de31..756964896 100644
--- a/plugins/mercurial/README.md
+++ b/plugins/mercurial/README.md
@@ -30,7 +30,8 @@ plugins=(... mercurial)
| `hgl` | `hg pull -u` |
| `hglr` | `hg pull --rebase` |
| `hgo` | `hg outgoing` |
-
+| `hglg` | `hg log --stat -v` |
+| `hglgp`| `hg log --stat -p -v` |
## Prompt usage
- Switch to a theme which uses `hg_prompt_info`
diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh
index f4efc2b4a..e098664c0 100644
--- a/plugins/mercurial/mercurial.plugin.zsh
+++ b/plugins/mercurial/mercurial.plugin.zsh
@@ -17,6 +17,8 @@ alias hgi='hg incoming'
alias hgl='hg pull -u'
alias hglr='hg pull --rebase'
alias hgo='hg outgoing'
+alias hglg='hg log --stat -v'
+alias hglgp='hg log --stat -p -v'
function in_hg() {
if $(hg branch > /dev/null 2>&1); then
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index 27d63a6f9..e32729aa6 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -1,39 +1,46 @@
-# Calls ./mvnw if found, otherwise execute the original mvn
+# Calls mvnw if found in the current project, otherwise execute the original mvn
mvn-or-mvnw() {
- if [ -x ./mvnw ]; then
- echo "executing mvnw instead of mvn"
- ./mvnw "$@"
- else
- command mvn "$@"
- fi
+ local dir="$PWD"
+ while [[ ! -x "$dir/mvnw" && "$dir" != / ]]; do
+ dir="${dir:h}"
+ done
+
+ if [[ -x "$dir/mvnw" ]]; then
+ echo "Running \`$dir/mvnw\`..." >&2
+ "$dir/mvnw" "$@"
+ return $?
+ fi
+
+ command mvn "$@"
}
# Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
mvn-color() {
- local BOLD=$(echoti bold)
- local TEXT_RED=$(echoti setaf 1)
- local TEXT_GREEN=$(echoti setaf 2)
- local TEXT_YELLOW=$(echoti setaf 3)
- local TEXT_BLUE=$(echoti setaf 4)
- local TEXT_WHITE=$(echoti setaf 7)
- local RESET_FORMATTING=$(echoti sgr0)
- (
- # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
- unset LANG
- LC_CTYPE=C mvn "$@" | sed \
- -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
- -e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_WHITE}${BOLD}\1${RESET_FORMATTING}\2/g" \
- -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
- -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
- -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
- -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
-
- # Make sure formatting is reset
- echo -ne "${RESET_FORMATTING}"
- )
+ local BOLD=$(echoti bold)
+ local TEXT_RED=$(echoti setaf 1)
+ local TEXT_GREEN=$(echoti setaf 2)
+ local TEXT_YELLOW=$(echoti setaf 3)
+ local TEXT_BLUE=$(echoti setaf 4)
+ local TEXT_WHITE=$(echoti setaf 7)
+ local RESET_FORMATTING=$(echoti sgr0)
+
+ (
+ # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
+ unset LANG
+ LC_CTYPE=C mvn "$@" | sed \
+ -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
+ -e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_WHITE}${BOLD}\1${RESET_FORMATTING}\2/g" \
+ -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
+ -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
+ -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
+ -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
+
+ # Make sure formatting is reset
+ echo -ne "${RESET_FORMATTING}"
+ )
}
-# either use orignal mvn or the mvn wrapper
+# either use original mvn or the mvn wrapper
alias mvn="mvn-or-mvnw"
# Run mvn against the pom found in a project's root directory (assumes a git repo)
@@ -72,262 +79,262 @@ alias mvn-updates='mvn versions:display-dependency-updates'
function listMavenCompletions {
- local file new_file
- local -a profiles POM_FILES modules
-
- # Root POM
- POM_FILES=(~/.m2/settings.xml)
-
- # POM in the current directory
- if [[ -f pom.xml ]]; then
- local file=pom.xml
- POM_FILES+=("${file:A}")
- fi
-
- # Look for POM files in parent directories
- while [[ -n "$file" ]] && grep -q "<parent>" "$file"; do
- # look for a new relativePath for parent pom.xml
- new_file=$(grep -e "<relativePath>.*</relativePath>" "$file" | sed -e 's/.*<relativePath>\(.*\)<\/relativePath>.*/\1/')
-
- # if <parent> is present but not defined, assume ../pom.xml
- if [[ -z "$new_file" ]]; then
- new_file="../pom.xml"
- fi
-
- # if file doesn't exist break
- file="${file:h}/${new_file}"
- if ! [[ -e "$file" ]]; then
- break
- fi
-
- POM_FILES+=("${file:A}")
- done
-
- # Get profiles from found files
- for file in $POM_FILES; do
- [[ -e $file ]] || continue
- profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?'))
- done
-
- # List modules
- modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|'))
-
- reply=(
- # common lifecycle
- clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
-
- # integration testing
- pre-integration-test integration-test
-
- # common plugins
- deploy failsafe install site surefire checkstyle javadoc jxr pmd ant antrun archetype assembly dependency enforcer gpg help release repository source eclipse idea jetty cargo jboss tomcat tomcat6 tomcat7 exec versions war ear ejb android scm buildnumber nexus repository sonar license hibernate3 liquibase flyway gwt
-
- # deploy
- deploy:deploy-file
- # failsafe
- failsafe:integration-test failsafe:verify
- # install
- install:install-file install:help
- # site
- site:site site:deploy site:run site:stage site:stage-deploy site:attach-descriptor site:jar site:effective-site
- # surefire
- surefire:test
-
- # checkstyle
- checkstyle:checkstyle checkstyle:check checkstyle:checkstyle-aggregate
- # javadoc
- javadoc:javadoc javadoc:test-javadoc javadoc:javadoc-no-fork javadoc:test-javadoc-no-fork javadoc:aggregate javadoc:test-aggregate javadoc:jar javadoc:test-jar javadoc:aggregate-jar javadoc:test-aggregate-jar javadoc:fix javadoc:test-fix javadoc:resource-bundle javadoc:test-resource-bundle
- # jxr
- jxr:jxr jxr:aggregate jxr:test-jxr jxr:test-aggregate
- # pmd
- pmd:pmd pmd:cpd pmd:check pmd:cpd-check
-
- # ant
- ant:ant ant:clean
- # antrun
- antrun:run
- # archetype
- archetype:generate archetype:create-from-project archetype:crawl
- # assembly
- assembly:single assembly:assembly
- # dependency
- dependency:analyze dependency:analyze-dep-mgt dependency:analyze-only dependency:analyze-report dependency:analyze-duplicate dependency:build-classpath dependency:copy dependency:copy-dependencies dependency:display-ancestors dependency:get dependency:go-offline dependency:list dependency:list-repositories dependency:properties dependency:purge-local-repository dependency:resolve dependency:resolve-plugins dependency:sources dependency:tree dependency:unpack dependency:unpack-dependencies
- # enforcer
- enforcer:enforce enforcer:display-info
- # gpg
- gpg:sign gpg:sign-and-deploy-file
- # help
- help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
- # release
- release:clean release:prepare release:prepare-with-pom release:rollback release:perform release:stage release:branch release:update-versions
- # jgitflow
- jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
- # repository
- repository:bundle-create repository:bundle-pack
- # source
- source:aggregate source:jar source:jar-no-fork source:test-jar source:test-jar-no-fork
-
- # eclipse
- eclipse:clean eclipse:eclipse
- # idea
- idea:clean idea:idea
-
- # jetty
- jetty:run jetty:run-exploded
- # cargo
- cargo:start cargo:run cargo:stop cargo:deploy cargo:undeploy cargo:help
- # jboss
- jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
- # tomcat
- tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
- # tomcat6
- tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
- # tomcat7
- tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy
- # tomee
- tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
- # spring-boot
- spring-boot:run spring-boot:repackage
- # quarkus
- quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help
- # exec
- exec:exec exec:java
- # versions
- versions:display-dependency-updates versions:display-plugin-updates versions:display-property-updates versions:update-parent versions:update-properties versions:update-child-modules versions:lock-snapshots versions:unlock-snapshots versions:resolve-ranges versions:set versions:use-releases versions:use-next-releases versions:use-latest-releases versions:use-next-snapshots versions:use-latest-snapshots versions:use-next-versions versions:use-latest-versions versions:commit versions:revert
- # scm
- scm:add scm:bootstrap scm:branch scm:changelog scm:check-local-modification scm:checkin scm:checkout scm:diff scm:edit scm:export scm:list scm:remove scm:status scm:tag scm:unedit scm:update scm:update-subprojects scm:validate
- # buildnumber
- buildnumber:create buildnumber:create-timestamp buildnumber:help buildnumber:hgchangeset
-
- # war
- war:war war:exploded war:inplace war:manifest
- # ear
- ear:ear ear:generate-application-xml
- # ejb
- ejb:ejb
- # android
- android:apk android:apklib android:deploy android:deploy-dependencies android:dex android:emulator-start android:emulator-stop android:emulator-stop-all android:generate-sources android:help android:instrument android:manifest-update android:pull android:push android:redeploy android:run android:undeploy android:unpack android:version-update android:zipalign android:devices
- # nexus
- nexus:staging-list nexus:staging-close nexus:staging-drop nexus:staging-release nexus:staging-build-promotion nexus:staging-profiles-list nexus:settings-download
- # repository
- repository:bundle-create repository:bundle-pack repository:help
-
- # sonar
- sonar:sonar
- # license
- license:format license:check
- # hibernate3
- hibernate3:hbm2ddl hibernate3:help
- # liquibase
- liquibase:changelogSync liquibase:changelogSyncSQL liquibase:clearCheckSums liquibase:dbDoc liquibase:diff liquibase:dropAll liquibase:help liquibase:migrate liquibase:listLocks liquibase:migrateSQL liquibase:releaseLocks liquibase:rollback liquibase:rollbackSQL liquibase:status liquibase:tag liquibase:update liquibase:updateSQL liquibase:updateTestingRollback
- # flyway
- flyway:clean flyway:history flyway:init flyway:migrate flyway:status flyway:validate
- # gwt
- gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test
- # asciidoctor
- asciidoctor:process-asciidoc asciidoctor:auto-refresh asciidoctor:http asciidoctor:zip
- # compiler
- compiler:compile compiler:testCompile
- # resources
- resources:resources resources:testResources resources:copy-resources
- # verifier
- verifier:verify
- # jar
- jar:jar jar:test-jar
- # rar
- rar:rar
- # acr
- acr:acr
- # shade
- shade:shade
- # changelog
- changelog:changelog changelog:dev-activity changelog:file-activity
- # changes
- changes:announcement-mail changes:announcement-generate changes:changes-check changes:changes-validate changes:changes-report changes:jira-report changes:trac-report changes:github-report
- # doap
- doap:generate
- # docck
- docck:check
- # jdeps
- jdeps:jdkinternals jdeps:test-jdkinternals
- # linkcheck
- linkcheck:linkcheck
- # project-info-reports
- project-info-reports:cim project-info-reports:dependencies project-info-reports:dependency-convergence project-info-reports:dependency-info project-info-reports:dependency-management project-info-reports:distribution-management project-info-reports:help project-info-reports:index project-info-reports:issue-tracking project-info-reports:license project-info-reports:mailing-list project-info-reports:modules project-info-reports:plugin-management project-info-reports:plugins project-info-reports:project-team project-info-reports:scm project-info-reports:summary
- # surefire-report
- surefire-report:failsafe-report-only surefire-report:report surefire-report:report-only
- # invoker
- invoker:install invoker:integration-test invoker:verify invoker:run
- # jarsigner
- jarsigner:sign jarsigner:verify
- # patch
- patch:apply
- # pdf
- pdf:pdf
- # plugin
- plugin:descriptor plugin:report plugin:updateRegistry plugin:addPluginArtifactMetadata plugin:helpmojo
- # remote-resources
- remote-resources:bundle remote-resources:process
- # scm-publish
- scm-publish:help scm-publish:publish-scm scm-publish:scmpublish
- # stage
- stage:copy
- # toolchain
- toolchain:toolchain
- #liberty
- liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
-
- # options
- "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile="
-
- # arguments
- -am --also-make
- -amd --also-make-dependents-am
- -B --batch-mode
- -b --builder
- -C --strict-checksums
- -c --lax-checksums
- -cpu --check-plugin-updates
- -D --define
- -e --errors
- -emp --encrypt-master-password
- -ep --encrypt-password
- -f --file
- -fae --fail-at-end
- -ff --fail-fast
- -fn --fail-never
- -gs --global-settings
- -gt --global-toolchains
- -h --help
- -l --log-file
- -llr --legacy-local-repository
- -N --non-recursive
- -npr --no-plugin-registry
- -npu --no-plugin-updates
- -nsu --no-snapshot-updates
- -o --offline
- -P --activate-profiles
- -pl --projects
- -q --quiet
- -rf --resume-from
- -s --settings
- -t --toolchains
- -T --threads
- -U --update-snapshots
- -up --update-plugins
- -v --version
- -V --show-version
- -X --debug
-
- cli:execute cli:execute-phase
- archetype:generate generate-sources
- cobertura:cobertura
- -Dtest=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi)
- -Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi)
-
- $profiles
- $modules
- )
+ local file new_file
+ local -a profiles POM_FILES modules
+
+ # Root POM
+ POM_FILES=(~/.m2/settings.xml)
+
+ # POM in the current directory
+ if [[ -f pom.xml ]]; then
+ local file=pom.xml
+ POM_FILES+=("${file:A}")
+ fi
+
+ # Look for POM files in parent directories
+ while [[ -n "$file" ]] && grep -q "<parent>" "$file"; do
+ # look for a new relativePath for parent pom.xml
+ new_file=$(grep -e "<relativePath>.*</relativePath>" "$file" | sed -e 's/.*<relativePath>\(.*\)<\/relativePath>.*/\1/')
+
+ # if <parent> is present but not defined, assume ../pom.xml
+ if [[ -z "$new_file" ]]; then
+ new_file="../pom.xml"
+ fi
+
+ # if file doesn't exist break
+ file="${file:h}/${new_file}"
+ if ! [[ -e "$file" ]]; then
+ break
+ fi
+
+ POM_FILES+=("${file:A}")
+ done
+
+ # Get profiles from found files
+ for file in $POM_FILES; do
+ [[ -e $file ]] || continue
+ profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?'))
+ done
+
+ # List modules
+ modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|'))
+
+ reply=(
+ # common lifecycle
+ clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
+
+ # integration testing
+ pre-integration-test integration-test
+
+ # common plugins
+ deploy failsafe install site surefire checkstyle javadoc jxr pmd ant antrun archetype assembly dependency enforcer gpg help release repository source eclipse idea jetty cargo jboss tomcat tomcat6 tomcat7 exec versions war ear ejb android scm buildnumber nexus repository sonar license hibernate3 liquibase flyway gwt
+
+ # deploy
+ deploy:deploy-file
+ # failsafe
+ failsafe:integration-test failsafe:verify
+ # install
+ install:install-file install:help
+ # site
+ site:site site:deploy site:run site:stage site:stage-deploy site:attach-descriptor site:jar site:effective-site
+ # surefire
+ surefire:test
+
+ # checkstyle
+ checkstyle:checkstyle checkstyle:check checkstyle:checkstyle-aggregate
+ # javadoc
+ javadoc:javadoc javadoc:test-javadoc javadoc:javadoc-no-fork javadoc:test-javadoc-no-fork javadoc:aggregate javadoc:test-aggregate javadoc:jar javadoc:test-jar javadoc:aggregate-jar javadoc:test-aggregate-jar javadoc:fix javadoc:test-fix javadoc:resource-bundle javadoc:test-resource-bundle
+ # jxr
+ jxr:jxr jxr:aggregate jxr:test-jxr jxr:test-aggregate
+ # pmd
+ pmd:pmd pmd:cpd pmd:check pmd:cpd-check
+
+ # ant
+ ant:ant ant:clean
+ # antrun
+ antrun:run
+ # archetype
+ archetype:generate archetype:create-from-project archetype:crawl
+ # assembly
+ assembly:single assembly:assembly
+ # dependency
+ dependency:analyze dependency:analyze-dep-mgt dependency:analyze-only dependency:analyze-report dependency:analyze-duplicate dependency:build-classpath dependency:copy dependency:copy-dependencies dependency:display-ancestors dependency:get dependency:go-offline dependency:list dependency:list-repositories dependency:properties dependency:purge-local-repository dependency:resolve dependency:resolve-plugins dependency:sources dependency:tree dependency:unpack dependency:unpack-dependencies
+ # enforcer
+ enforcer:enforce enforcer:display-info
+ # gpg
+ gpg:sign gpg:sign-and-deploy-file
+ # help
+ help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
+ # release
+ release:clean release:prepare release:prepare-with-pom release:rollback release:perform release:stage release:branch release:update-versions
+ # jgitflow
+ jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
+ # repository
+ repository:bundle-create repository:bundle-pack
+ # source
+ source:aggregate source:jar source:jar-no-fork source:test-jar source:test-jar-no-fork
+
+ # eclipse
+ eclipse:clean eclipse:eclipse
+ # idea
+ idea:clean idea:idea
+
+ # jetty
+ jetty:run jetty:run-exploded
+ # cargo
+ cargo:start cargo:run cargo:stop cargo:deploy cargo:undeploy cargo:help
+ # jboss
+ jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
+ # tomcat
+ tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
+ # tomcat6
+ tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
+ # tomcat7
+ tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy
+ # tomee
+ tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
+ # spring-boot
+ spring-boot:run spring-boot:repackage
+ # quarkus
+ quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help
+ # exec
+ exec:exec exec:java
+ # versions
+ versions:display-dependency-updates versions:display-plugin-updates versions:display-property-updates versions:update-parent versions:update-properties versions:update-child-modules versions:lock-snapshots versions:unlock-snapshots versions:resolve-ranges versions:set versions:use-releases versions:use-next-releases versions:use-latest-releases versions:use-next-snapshots versions:use-latest-snapshots versions:use-next-versions versions:use-latest-versions versions:commit versions:revert
+ # scm
+ scm:add scm:bootstrap scm:branch scm:changelog scm:check-local-modification scm:checkin scm:checkout scm:diff scm:edit scm:export scm:list scm:remove scm:status scm:tag scm:unedit scm:update scm:update-subprojects scm:validate
+ # buildnumber
+ buildnumber:create buildnumber:create-timestamp buildnumber:help buildnumber:hgchangeset
+
+ # war
+ war:war war:exploded war:inplace war:manifest
+ # ear
+ ear:ear ear:generate-application-xml
+ # ejb
+ ejb:ejb
+ # android
+ android:apk android:apklib android:deploy android:deploy-dependencies android:dex android:emulator-start android:emulator-stop android:emulator-stop-all android:generate-sources android:help android:instrument android:manifest-update android:pull android:push android:redeploy android:run android:undeploy android:unpack android:version-update android:zipalign android:devices
+ # nexus
+ nexus:staging-list nexus:staging-close nexus:staging-drop nexus:staging-release nexus:staging-build-promotion nexus:staging-profiles-list nexus:settings-download
+ # repository
+ repository:bundle-create repository:bundle-pack repository:help
+
+ # sonar
+ sonar:sonar
+ # license
+ license:format license:check
+ # hibernate3
+ hibernate3:hbm2ddl hibernate3:help
+ # liquibase
+ liquibase:changelogSync liquibase:changelogSyncSQL liquibase:clearCheckSums liquibase:dbDoc liquibase:diff liquibase:dropAll liquibase:help liquibase:migrate liquibase:listLocks liquibase:migrateSQL liquibase:releaseLocks liquibase:rollback liquibase:rollbackSQL liquibase:status liquibase:tag liquibase:update liquibase:updateSQL liquibase:updateTestingRollback
+ # flyway
+ flyway:clean flyway:history flyway:init flyway:migrate flyway:status flyway:validate
+ # gwt
+ gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test
+ # asciidoctor
+ asciidoctor:process-asciidoc asciidoctor:auto-refresh asciidoctor:http asciidoctor:zip
+ # compiler
+ compiler:compile compiler:testCompile
+ # resources
+ resources:resources resources:testResources resources:copy-resources
+ # verifier
+ verifier:verify
+ # jar
+ jar:jar jar:test-jar
+ # rar
+ rar:rar
+ # acr
+ acr:acr
+ # shade
+ shade:shade
+ # changelog
+ changelog:changelog changelog:dev-activity changelog:file-activity
+ # changes
+ changes:announcement-mail changes:announcement-generate changes:changes-check changes:changes-validate changes:changes-report changes:jira-report changes:trac-report changes:github-report
+ # doap
+ doap:generate
+ # docck
+ docck:check
+ # jdeps
+ jdeps:jdkinternals jdeps:test-jdkinternals
+ # linkcheck
+ linkcheck:linkcheck
+ # project-info-reports
+ project-info-reports:cim project-info-reports:dependencies project-info-reports:dependency-convergence project-info-reports:dependency-info project-info-reports:dependency-management project-info-reports:distribution-management project-info-reports:help project-info-reports:index project-info-reports:issue-tracking project-info-reports:license project-info-reports:mailing-list project-info-reports:modules project-info-reports:plugin-management project-info-reports:plugins project-info-reports:project-team project-info-reports:scm project-info-reports:summary
+ # surefire-report
+ surefire-report:failsafe-report-only surefire-report:report surefire-report:report-only
+ # invoker
+ invoker:install invoker:integration-test invoker:verify invoker:run
+ # jarsigner
+ jarsigner:sign jarsigner:verify
+ # patch
+ patch:apply
+ # pdf
+ pdf:pdf
+ # plugin
+ plugin:descriptor plugin:report plugin:updateRegistry plugin:addPluginArtifactMetadata plugin:helpmojo
+ # remote-resources
+ remote-resources:bundle remote-resources:process
+ # scm-publish
+ scm-publish:help scm-publish:publish-scm scm-publish:scmpublish
+ # stage
+ stage:copy
+ # toolchain
+ toolchain:toolchain
+ #liberty
+ liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
+
+ # options
+ "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile="
+
+ # arguments
+ -am --also-make
+ -amd --also-make-dependents-am
+ -B --batch-mode
+ -b --builder
+ -C --strict-checksums
+ -c --lax-checksums
+ -cpu --check-plugin-updates
+ -D --define
+ -e --errors
+ -emp --encrypt-master-password
+ -ep --encrypt-password
+ -f --file
+ -fae --fail-at-end
+ -ff --fail-fast
+ -fn --fail-never
+ -gs --global-settings
+ -gt --global-toolchains
+ -h --help
+ -l --log-file
+ -llr --legacy-local-repository
+ -N --non-recursive
+ -npr --no-plugin-registry
+ -npu --no-plugin-updates
+ -nsu --no-snapshot-updates
+ -o --offline
+ -P --activate-profiles
+ -pl --projects
+ -q --quiet
+ -rf --resume-from
+ -s --settings
+ -t --toolchains
+ -T --threads
+ -U --update-snapshots
+ -up --update-plugins
+ -v --version
+ -V --show-version
+ -X --debug
+
+ cli:execute cli:execute-phase
+ archetype:generate generate-sources
+ cobertura:cobertura
+ -Dtest=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi)
+ -Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi)
+
+ $profiles
+ $modules
+ )
}
compctl -K listMavenCompletions mvn mvnw
diff --git a/plugins/osx/README.md b/plugins/osx/README.md
index ecc9327d0..50458f60e 100644
--- a/plugins/osx/README.md
+++ b/plugins/osx/README.md
@@ -12,27 +12,28 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
## Commands
-| Command | Description |
-| :-------------- | :---------------------------------------------------- |
-| `tab` | Open the current directory in a new tab |
-| `split_tab` | Split the current terminal tab horizontally |
-| `vsplit_tab` | Split the current terminal tab vertically |
-| `ofd` | Open the current directory in a Finder window |
-| `pfd` | Return the path of the frontmost Finder window |
-| `pfs` | Return the current Finder selection |
-| `cdf` | `cd` to the current Finder directory |
-| `pushdf` | `pushd` to the current Finder directory |
-| `pxd` | Return the current Xcode project directory |
-| `cdx` | `cd` to the current Xcode project directory |
-| `quick-look` | Quick-Look a specified file |
-| `man-preview` | Open a specified man page in Preview app |
-| `showfiles` | Show hidden files in Finder |
-| `hidefiles` | Hide the hidden files in Finder |
-| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
-| `music` | Control Apple Music. Use `music -h` for usage details |
-| `spotify` | Control Spotify and search by artist, album, track… |
-| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
-| `btrestart` | Restart the Bluetooth daemon |
+| Command | Description |
+| :------------ | :------------------------------------------------------- |
+| `tab` | Open the current directory in a new tab |
+| `split_tab` | Split the current terminal tab horizontally |
+| `vsplit_tab` | Split the current terminal tab vertically |
+| `ofd` | Open the current directory in a Finder window |
+| `pfd` | Return the path of the frontmost Finder window |
+| `pfs` | Return the current Finder selection |
+| `cdf` | `cd` to the current Finder directory |
+| `pushdf` | `pushd` to the current Finder directory |
+| `pxd` | Return the current Xcode project directory |
+| `cdx` | `cd` to the current Xcode project directory |
+| `quick-look` | Quick-Look a specified file |
+| `man-preview` | Open a specified man page in Preview app |
+| `showfiles` | Show hidden files in Finder |
+| `hidefiles` | Hide the hidden files in Finder |
+| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
+| `music` | Control Apple Music. Use `music -h` for usage details |
+| `spotify` | Control Spotify and search by artist, album, track… |
+| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
+| `btrestart` | Restart the Bluetooth daemon |
+| `freespace` | Erases purgeable disk space with 0s on the selected disk |
## Acknowledgements
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index 7842e9f73..16f16ddb6 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -219,7 +219,8 @@ function quick-look() {
}
function man-preview() {
- man -t "$@" | open -f -a Preview
+ # Don't let Preview.app steal focus if the man page doesn't exist
+ man -w "$@" &>/dev/null && man -t "$@" | open -f -a Preview || man "$@"
}
compdef _man man-preview
@@ -232,6 +233,29 @@ function rmdsstore() {
find "${@:-.}" -type f -name .DS_Store -delete
}
+# Erases purgeable disk space with 0s on the selected disk
+function freespace(){
+ if [[ -z "$1" ]]; then
+ echo "Usage: $0 <disk>"
+ echo "Example: $0 /dev/disk1s1"
+ echo
+ echo "Possible disks:"
+ df -h | awk 'NR == 1 || /^\/dev\/disk/'
+ return 1
+ fi
+
+ echo "Cleaning purgeable files from disk: $1 ...."
+ diskutil secureErase freespace 0 $1
+}
+
+_freespace() {
+ local -a disks
+ disks=("${(@f)"$(df | awk '/^\/dev\/disk/{ printf $1 ":"; for (i=9; i<=NF; i++) printf $i FS; print "" }')"}")
+ _describe disks disks
+}
+
+compdef _freespace freespace
+
# Music / iTunes control function
source "${0:h:A}/music"
diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh
index 41de2f91d..7cd673cdb 100644
--- a/plugins/per-directory-history/per-directory-history.zsh
+++ b/plugins/per-directory-history/per-directory-history.zsh
@@ -32,7 +32,7 @@
#
# Copyright (c) 2014 Jim Hester
#
-# This software is provided 'as-is', without any express or implied warranty.
+# This software is provided 'as-is', without any express or implied warranty.
# In no event will the authors be held liable for any damages arising from the
# use of this software.
#
@@ -57,6 +57,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'
#-------------------------------------------------------------------------------
@@ -66,9 +67,11 @@
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"
else
_per-directory-history-set-global-history
+ _per_directory_history_is_global=true
print -n "\nusing global history"
fi
zle .push-line
@@ -114,43 +117,58 @@ function _per-directory-history-addhistory() {
true
else
print -Sr -- "${1%%$'\n'}"
+ # instantly write history if set options require it.
+ if [[ -o share_history ]] || \
+ [[ -o inc_append_history ]] || \
+ [[ -o inc_append_history_time ]]; then
+ fc -AI $HISTFILE
+ fc -AI $_per_directory_history_directory
+ fi
fc -p $_per_directory_history_directory
fi
}
+function _per-directory-history-precmd() {
+ if [[ $_per_directory_history_initialized == false ]]; then
+ _per_directory_history_initialized=true
-function _per-directory-history-set-directory-history() {
- if [[ $_per_directory_history_is_global == true ]]; then
- fc -AI $HISTFILE
- local original_histsize=$HISTSIZE
- HISTSIZE=0
- HISTSIZE=$original_histsize
- if [[ -e "$_per_directory_history_directory" ]]; then
- fc -R "$_per_directory_history_directory"
+ if [[ $HISTORY_START_WITH_GLOBAL == true ]]; then
+ _per-directory-history-set-global-history
+ _per_directory_history_is_global=true
+ else
+ _per-directory-history-set-directory-history
+ _per_directory_history_is_global=false
fi
fi
- _per_directory_history_is_global=false
}
+
+function _per-directory-history-set-directory-history() {
+ fc -AI $HISTFILE
+ local original_histsize=$HISTSIZE
+ HISTSIZE=0
+ HISTSIZE=$original_histsize
+ if [[ -e "$_per_directory_history_directory" ]]; then
+ fc -R "$_per_directory_history_directory"
+ fi
+}
+
function _per-directory-history-set-global-history() {
- if [[ $_per_directory_history_is_global == false ]]; then
- fc -AI $_per_directory_history_directory
- local original_histsize=$HISTSIZE
- HISTSIZE=0
- HISTSIZE=$original_histsize
- if [[ -e "$HISTFILE" ]]; then
- fc -R "$HISTFILE"
- fi
+ fc -AI $_per_directory_history_directory
+ local original_histsize=$HISTSIZE
+ HISTSIZE=0
+ HISTSIZE=$original_histsize
+ if [[ -e "$HISTFILE" ]]; then
+ fc -R "$HISTFILE"
fi
- _per_directory_history_is_global=true
}
+mkdir -p ${_per_directory_history_directory:h}
#add functions to the exec list for chpwd and zshaddhistory
autoload -U add-zsh-hook
add-zsh-hook chpwd _per-directory-history-change-directory
add-zsh-hook zshaddhistory _per-directory-history-addhistory
+add-zsh-hook precmd _per-directory-history-precmd
-#start in directory mode
-mkdir -p ${_per_directory_history_directory:h}
-_per_directory_history_is_global=true
-_per-directory-history-set-directory-history
+# set initialized flag to false
+_per_directory_history_initialized=false
diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh
index d91b5daa7..39897ed16 100644
--- a/plugins/pyenv/pyenv.plugin.zsh
+++ b/plugins/pyenv/pyenv.plugin.zsh
@@ -78,7 +78,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then
eval "$(pyenv init - --no-rehash zsh)"
# If pyenv-virtualenv exists, load it
- if [[ -d "$(pyenv root)/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then
+ if [[ "$(pyenv commands)" =~ "virtualenv-init" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then
eval "$(pyenv virtualenv-init - zsh)"
fi
diff --git a/plugins/python/README.md b/plugins/python/README.md
index 0180218a2..b95ffe679 100644
--- a/plugins/python/README.md
+++ b/plugins/python/README.md
@@ -11,6 +11,7 @@ plugins=(... python)
| Command | Description |
|------------------|---------------------------------------------------------------------------------|
+| `py` | Runs `python` |
| `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/ruby/README.md b/plugins/ruby/README.md
index ad2755bbf..59594ade7 100644
--- a/plugins/ruby/README.md
+++ b/plugins/ruby/README.md
@@ -10,11 +10,22 @@ plugins=(... ruby)
## Aliases
-| Alias | Command | Description |
-|-------|----------------------------------------|------------------------------------------------------|
-| rb | `ruby` | The Ruby command |
-| sgem | `sudo gem` | Run sudo gem on the system ruby, not the active ruby |
-| rfind | `find . -name "*.rb" \| xargs grep -n` | Find ruby file |
-| gin | `gem install` | Install a gem into the local repository |
-| gun | `gem uninstall` | Uninstall gems from the local repository |
-| gli | `gem list` | Display gems installed locally |
+| Alias | Command | Description |
+|--------|----------------------------------------|------------------------------------------------------|
+| rb | `ruby` | The Ruby command |
+| sgem | `sudo gem` | Run sudo gem on the system ruby, not the active ruby |
+| rfind | `find . -name "*.rb" \| xargs grep -n` | Find ruby file |
+| gein | `gem install` | Install a gem into the local repository |
+| geun | `gem uninstall` | Uninstall gems from the local repository |
+| geli | `gem list` | Display gems installed locally |
+| gei | `gem info` | Show information for the given gem |
+| geiall | `gem info --all` | Display all gem versions |
+| geca | `gem cert --add` | Add a trusted certificate |
+| gecr | `gem cert --remove` | Remove a trusted certificate |
+| gecb | `gem cert --build` | Build private key and self-signed certificate |
+| geclup | `gem cleanup -n` | Do not uninstall gem |
+| gegi | `gem generate_index` | Generate index file for gem server |
+| geh | `gem help` | Provide additional help |
+| gel | `gem lock` | Generate a lockdown list of gems |
+| geo | `gem open` | Open gem source in default editor |
+| geoe | `gem open -e` | Open gem sources in preferred editor |
diff --git a/plugins/ruby/ruby.plugin.zsh b/plugins/ruby/ruby.plugin.zsh
index 177b35b31..890fcb179 100644
--- a/plugins/ruby/ruby.plugin.zsh
+++ b/plugins/ruby/ruby.plugin.zsh
@@ -1,5 +1,4 @@
-# TODO: Make this compatible with rvm.
-# Run sudo gem on the system ruby, not the active ruby.
+# Run sudo gem on the system ruby, not the active ruby
alias sgem='sudo gem'
# Find ruby file
@@ -9,6 +8,17 @@ alias rfind='find . -name "*.rb" | xargs grep -n'
alias rb="ruby"
# Gem Command Shorthands
-alias gin="gem install"
-alias gun="gem uninstall"
-alias gli="gem list"
+alias gein="gem install"
+alias geun="gem uninstall"
+alias geli="gem list"
+alias gei="gem info"
+alias geiall="gem info --all"
+alias geca="gem cert --add"
+alias gecr="gem cert --remove"
+alias gecb="gem cert --build"
+alias geclup="gem cleanup -n"
+alias gegi="gem generate_index"
+alias geh="gem help"
+alias gel="gem lock"
+alias geo="gem open"
+alias geoe="gem open -e"
diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
index d1a504b1e..1d6914ec6 100644
--- a/plugins/ssh-agent/README.md
+++ b/plugins/ssh-agent/README.md
@@ -21,7 +21,23 @@ zstyle :omz:plugins:ssh-agent agent-forwarding on
----
-To **load multiple identities** use the `identities` style, For example:
+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).
+
+----
+
+To **load multiple identities** use the `identities` style (**this has no effect
+if the `lazy` setting is enabled**). For example:
```zsh
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
index 2d7d8a2a0..47dfef5b0 100644
--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
@@ -6,9 +6,11 @@ function _start_agent() {
if [[ -f "$ssh_env_cache" ]]; then
. "$ssh_env_cache" > /dev/null
- {
- [[ "$USERNAME" = root ]] && command ps ax || command ps x
- } | command grep ssh-agent | command grep -q $SSH_AGENT_PID && return 0
+ # Test if $SSH_AUTH_SOCK is visible
+ zmodload zsh/net/socket
+ if [[ -S "$SSH_AUTH_SOCK" ]] && zsocket "$SSH_AUTH_SOCK" 2>/dev/null; then
+ return 0
+ fi
fi
# Set a maximum lifetime for identities added to ssh-agent
@@ -96,7 +98,10 @@ else
_start_agent
fi
-_add_identities
+# Don't add identities if lazy-loading is enabled
+if ! zstyle -t :omz:plugins:ssh-agent lazy; then
+ _add_identities
+fi
unset agent_forwarding ssh_env_cache
unfunction _start_agent _add_identities
diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
index 618dd8ee8..dadf37574 100644
--- a/plugins/sublime/sublime.plugin.zsh
+++ b/plugins/sublime/sublime.plugin.zsh
@@ -17,6 +17,7 @@ alias stn=create_project
if [[ "$OSTYPE" == linux* ]]; then
if [[ "$(uname -r)" = *icrosoft* ]]; then
_sublime_paths=(
+ "$(wslpath -u 'C:\Program Files\Sublime Text\sublime_text.exe' 2>/dev/null)"
"$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe' 2>/dev/null)"
"$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe' 2>/dev/null)"
)
@@ -52,6 +53,7 @@ alias stn=create_project
)
elif [[ "$OSTYPE" = msys ]]; then
_sublime_paths=(
+ "/c/Program Files/Sublime Text/sublime_text.exe"
"/c/Program Files/Sublime Text 2/subl.exe"
"/c/Program Files/Sublime Text 3/subl.exe"
)
diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md
index fd748b742..9a0d1708d 100644
--- a/plugins/yarn/README.md
+++ b/plugins/yarn/README.md
@@ -28,6 +28,7 @@ plugins=(... yarn)
| yi | `yarn init` | Interactively creates or updates a package.json file |
| yin | `yarn install` | Install dependencies defined in `package.json` |
| yln | `yarn lint` | Run the lint script defined in `package.json` |
+| ylnf | `yarn lint --fix` | Run the lint script defined in `package.json`to automatically fix problems |
| yls | `yarn list` | List installed packages |
| yout | `yarn outdated` | Check for outdated package dependencies |
| yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn
index 70e783b86..70ed55929 100644
--- a/plugins/yarn/_yarn
+++ b/plugins/yarn/_yarn
@@ -32,15 +32,21 @@
# -------
#
# * Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
+# * Shohei YOSHIDA <syohex@gmail.com>
#
# ------------------------------------------------------------------------------
+declare -g _yarn_run_cwd
+
_commands=(
'access'
+ 'audit:Checks for known security issues with the installed packages'
'autoclean:Clean and remove unnecessary files from package dependencies'
'cache:List or clean every cached package'
- "check:Verify package dependencies agains yarn's lock file"
+ "check:Verify package dependencies against yarn's lock file"
'config:Manages the yarn configuration files'
+ 'create:Creates new projects from any create-* starter kits'
+ 'exec'
'generate-lock-entry:Generates a lock file entry'
'global:Install packages globally on your operating system'
'help:Show information about a command'
@@ -50,25 +56,30 @@ _commands=(
'install:Install all the dependencies listed within package.json'
'licenses:List licenses for installed packages'
'link:Symlink a package folder during development'
- 'list:List installed packages'
'login:Store registry username and email'
'logout:Clear registry username and email'
+ 'node:Runs Node with the same version that the one used by Yarn itself'
'outdated:Check for outdated package dependencies'
'owner:Manage package owners'
'pack:Create a compressed gzip archive of package dependencies'
+ 'policies:Defines project-wide policies for your project'
'publish:Publish a package to the npm registry'
'run:Run a defined package script'
'tag:Add, remove, or list tags on a package'
'team:Maintain team memberships'
'unlink:Unlink a previously created symlink for a package'
+ 'unplug:Temporarily copies a package outside of the global cache for debugging purposes'
'version:Update the package version'
'versions:Display version information of currently installed Yarn, Node.js, and its dependencies'
'why:Show information about why a package is installed'
+ 'workspace'
+ 'workspaces:Show information about your workspaces'
)
_global_commands=(
'add:Installs a package and any packages that it depends on'
'bin:Displays the location of the yarn bin folder'
+ 'list:List installed packages'
'remove:Remove installed package from dependencies updating package.json'
'upgrade:Upgrades packages to their latest version based on the specified range'
'upgrade-interactive:Interactively upgrade packages'
@@ -76,7 +87,12 @@ _global_commands=(
_yarn_commands_scripts() {
local -a scripts
- scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
+ if [[ -n $opt_args[--cwd] ]]; then
+ scripts=($(cd $opt_args[--cwd] && yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
+ else
+ scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
+ fi
+
_describe 'command or script' _commands -- _global_commands -- scripts
}
@@ -85,7 +101,11 @@ _yarn_scripts() {
local -a scriptNames scriptCommands
local i runJSON
- runJSON=$(yarn run --json 2>/dev/null)
+ if [[ -n $_yarn_run_cwd ]]; then
+ runJSON=$(cd $_yarn_run_cwd && yarn run --json 2>/dev/null)
+ else
+ runJSON=$(yarn run --json 2>/dev/null)
+ fi
# Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement
# pattern as a newline. See https://superuser.com/q/307165
binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
@@ -96,7 +116,7 @@ _yarn_scripts() {
scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
done
- commands=($scripts $binaries)
+ commands=('env' $scripts $binaries)
_describe 'command' commands
}
@@ -110,6 +130,17 @@ _yarn_commands() {
_describe 'command' _commands -- _global_commands
}
+_yarn_add_files() {
+ if compset -P "(file|link):"; then
+ _files
+ fi
+}
+
+_yarn_workspaces() {
+ local -a workspaces=(${(@f)$(yarn workspaces info |sed -n -e 's/^ "\([^"]*\)": {/\1/p')})
+ _describe 'workspace' workspaces
+}
+
_yarn() {
local context state state_descr line
typeset -A opt_args
@@ -118,37 +149,51 @@ _yarn() {
'(-h --help)'{-h,--help}'[output usage information]' \
'(-V --version)'{-V,--version}'[output the version number]' \
'--verbose[output verbose messages on internal operations]' \
- '--offline[trigger an error if any required dependencies are not available in local cache]' \
- '--prefer-offline[use network only if dependencies are not available in local cache]' \
- '--strict-semver' \
- '--json' \
- "--ignore-scripts[don't run lifecycle scripts]" \
- '--har[save HAR output of network traffic]' \
- '--ignore-platform[ignore platform checks]' \
- '--ignore-engines[ignore engines check]' \
- '--ignore-optional[ignore optional dependencies]' \
- '--force[install and build packages even if they were built before, overwrite lockfile]' \
- '--skip-integrity-check[run install without checking if node_modules is installed]' \
+ '--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \
'--check-files[install will verify file tree of packages for consistency]' \
- "--no-bin-links[don't generate bin links when setting up packages]" \
+ '--cwd=[working directory to use]:path:_files -/' \
+ "(--enable-pnp --pnp)--disable-pnp[disable the Plug'n'Play installation]" \
+ '(--no-emoji)--emoji=[enable emoji in output(default: false)]:enabled:(true false)' \
+ '(--emoji)--no-emoji[disable emoji in output]' \
+ '(--disable-pnp)'{--enable-pnp,--pnp}"[enable the Plug'n'Play installation]" \
'--flat[only allow one version of a package]' \
- '(--prod --production)'{--prod,--production} \
- "--no-lockfile[don't read or generate a lockfile]" \
- "--pure-lockfile[don't generate a lockfile]" \
+ '--focus[Focus on a single workspace by installing remote copies of its sibiling workspaces]' \
+ '--force[install and build packages even if they were built before, overwrite lockfile]' \
"--frozen-lockfile[don't generate a lockfile and fail if an update is needed]" \
- '--link-duplicates[create hardlinks to the repeated modules in node_modules]' \
'--global-folder=[modules folder]:folder:_files -/' \
+ '--har[save HAR output of network traffic]' \
+ '--https-proxy=[HTTPS proxy]:host:_hosts' \
+ '--ignore-engines[ignore engines check]' \
+ "--ignore-scripts[don't run lifecycle scripts]" \
+ '--ignore-optional[ignore optional dependencies]' \
+ '--ignore-platform[ignore platform checks]' \
+ '--json[format Yarn log messages as lines of JSON]' \
+ '--link-duplicates[create hardlinks to the repeated modules in node_modules]' \
+ '--link-folder=[specify a custom folder to store global links]' \
'--modules-folder=[rather than installing modules into the node_modules folder relative to the cwd, output them here]:folder:_files -/' \
- '--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \
'--mutex=[use a mutex to ensure only one yarn instance is executing]:type[\:specifier]' \
- '--no-emoji[disable emoji in output]' \
- '(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \
- '--proxy=:host:_hosts' \
- '--https-proxy=:host:_hosts' \
- '--no-progress[disable progress bar]' \
'--network-concurrency=[maximum number of concurrent network requests]:number' \
'--network-timeout=[TCP timeout for network requests]:milliseconds' \
+ "--no-bin-links[don't generate bin links when setting up packages]" \
+ '--no-default-rc[prevent Yarn from automatically detecting yarnrc and npmrc files]' \
+ "--no-lockfile[don't read or generate a lockfile]" \
'--non-interactive[do not show interactive prompts]' \
+ '--no-node-version-check[do not warn when using a potentially unsupported Node version]' \
+ '--no-progress[disable progress bar]' \
+ '--offline[trigger an error if any required dependencies are not available in local cache]' \
+ '--otp=[one-time password for two factor authentication]:otpcode' \
+ '--prefer-offline[use network only if dependencies are not available in local cache]' \
+ '--preferred-cache-folder=[specify a custom folder to store the yarn cache if possible]:folder:_files -/' \
+ '(--prod --production)'{--prod,--production}'[install only production dependencies]' \
+ '--proxy=[HTTP proxy]:host:_hosts' \
+ "--pure-lockfile[don't generate a lockfile]" \
+ '--registry=[override configuration registry]:url:_urls' \
+ '(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \
+ '--scripts-prepend-node-path=[prepend the node executable dir to the PATH in scripts]:bool:(true false)' \
+ '--skip-integrity-check[run install without checking if node_modules is installed]' \
+ "--strict-semver[don't compare semver loosely]" \
+ '--update-checksum[update package checksums from current repository]' \
+ '--use-yarnrc=[specifies a yarnrc that Yarn should use]:yarnrc:_files' \
'1: :_yarn_commands_scripts' \
'*:: :->command_args'
@@ -173,18 +218,29 @@ _yarn() {
'(-O --optional)'{-O,--optional}'[install packages in optionalDependencies]' \
'(-E --exact)'{-E,--exact}'[install packages as exact versions]' \
'(-T --tilde)'{-T,--tilde}'[install the most recent release of the packages that have the same minor version]' \
- '*:package-name:'
+ '(--ignore-workspace-root-check -W)'{--ignore-workspace-root-check,-W}'[allows a package to be installed at the workspaces root]' \
+ '--audit[checks for known security issues with the installed packages]' \
+ '*:package-name:_yarn_add_files'
+ ;;
+
+ audit)
+ _arguments \
+ '--verbose[output verbose message]' \
+ '--json[format Yarn log messages as lines of JSON]' \
+ '--level=[only print advisories with severity greater than or equal to]:level:(info low moderate high critical)' \
+ '--groups=[only audit dependencies from listed groups]:groups:->groups_args'
;;
cache)
_arguments \
- '1: :(ls dir clean)'
+ '1: :(list dir clean)' \
+ '*:: :->cache_args'
;;
check)
_arguments \
- '--integrity' \
- '--verify-tree'
+ '--integrity[Verifies that versions and hashed values of the package contents in package.json]' \
+ '--verify-tree[Recursively verifies that the dependencies in package.json are present in node_modules]'
;;
config)
@@ -223,12 +279,13 @@ _yarn() {
list)
_arguments \
- '--depth[Limit the depth of the shown dependencies]:depth'
+ '--depth=[Limit the depth of the shown dependencies]:depth' \
+ '--pattern=[filter the list of dependencies by the pattern]'
;;
owner)
_arguments \
- '1: :(ls add rm)' \
+ '1: :(list add rm)' \
'*:: :->owner_args'
;;
@@ -247,12 +304,22 @@ _yarn() {
'1: :_files'
;;
+ policies)
+ _arguments \
+ '1: :(set-version)'
+ ;;
+
remove|upgrade)
_arguments \
'*:package:'
;;
run)
+ if [[ -n $opt_args[--cwd] ]]; then
+ _yarn_run_cwd=$opt_args[--cwd]
+ else
+ _yarn_run_cwd=''
+ fi
_arguments \
'1: :_yarn_scripts' \
'*:: :_default'
@@ -260,26 +327,33 @@ _yarn() {
tag)
_arguments \
- '1: :(ls add rm)' \
+ '1: :(lists add rm)' \
'*:: :->tag_args'
;;
team)
_arguments \
- '1: :(create destroy add rm ls)' \
+ '1: :(create destroy add rm list)' \
'*:: :->team_args'
;;
upgrade-interactive)
_arguments \
- '--latest:use the version tagged latest in the registry:'
+ '--latest[use the version tagged latest in the registry]'
;;
version)
_arguments \
- '--new-version:version:' \
- '--message:message:' \
- '--no-git-tag-version'
+ '--new-version[create a new version using an interactive session to prompt you]:version:' \
+ '--major[creates a new version by incrementing the major version]' \
+ '--minor[creates a new version by incrementing the minor version]' \
+ '--patch[creates a new version by incrementing the patch version]' \
+ '--premajor[creates a new prerelease version by incrementing the major version]' \
+ '--preminor[creates a new prerelease version by incrementing the minor version]' \
+ '--prepatch[creates a new prerelease version by incrementing the patch version]' \
+ '--prerelease[increments the prerelease version number keeping the main version]' \
+ '--no-git-tag-version[creates a new version without creating a git tag]' \
+ '--no-commit-hooks[bypasses running commit hooks when committing the new version]'
;;
why)
@@ -287,7 +361,19 @@ _yarn() {
'1:query:_files'
;;
- *)
+ workspace)
+ _arguments \
+ '1:workspace:_yarn_workspaces' \
+ '*:: :_yarn_global_commands'
+ ;;
+
+ workspaces)
+ _arguments \
+ '--json[format Yarn log messages as lines of JSON]' \
+ '1:commands:(info run)'
+ ;;
+
+ *)
_default
;;
esac
@@ -295,6 +381,12 @@ _yarn() {
esac
case $state in
+ cache_args)
+ if [[ $words[1] == "list" ]]; then
+ _arguments \
+ '--pattern=[print out every cached package that matches the pattern]:pattern:'
+ fi
+ ;;
config_args)
case $words[1] in
get|delete)
@@ -310,6 +402,10 @@ _yarn() {
;;
esac
;;
+ groups_args)
+ local dependency_groups=(devDependencies dependencies optionalDependencies peerDependencies bundledDependencies)
+ _values -s ',' 'groups' $dependency_groups
+ ;;
owner_args)
case $words[1] in
diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh
index 4a5192c61..a4f595c61 100644
--- a/plugins/yarn/yarn.plugin.zsh
+++ b/plugins/yarn/yarn.plugin.zsh
@@ -1,3 +1,10 @@
+# Add yarn bin directory to $PATH if it exists and not in $PATH already
+bindir=$(yarn global bin 2>/dev/null) \
+ && [[ -d "$bindir" ]] \
+ && (( ! ${path[(Ie)$bindir]} )) \
+ && path+=("$bindir")
+unset bindir
+
alias y="yarn"
alias ya="yarn add"
alias yad="yarn add --dev"
@@ -13,6 +20,7 @@ alias yh="yarn help"
alias yi="yarn init"
alias yin="yarn install"
alias yln="yarn lint"
+alias ylnf="yarn lint --fix"
alias yls="yarn list"
alias yout="yarn outdated"
alias yp="yarn pack"
diff --git a/plugins/z/z.sh b/plugins/z/z.sh
index 13008a60e..67f504e27 100644
--- a/plugins/z/z.sh
+++ b/plugins/z/z.sh
@@ -42,6 +42,8 @@ _z() {
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
_z_dirs () {
+ [ -f "$datafile" ] || return
+
local line
while read line; do
# only count directories
@@ -54,14 +56,16 @@ _z() {
if [ "$1" = "--add" ]; then
shift
- # $HOME isn't worth matching
- [ "$*" = "$HOME" ] && return
+ # $HOME and / aren't worth matching
+ [ "$*" = "$HOME" -o "$*" = '/' ] && return
# don't track excluded directory trees
- local exclude
- for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
- case "$*" in "$exclude*") return;; esac
- done
+ if [ ${#_Z_EXCLUDE_DIRS[@]} -gt 0 ]; then
+ local exclude
+ for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
+ case "$*" in "$exclude"*) return;; esac
+ done
+ fi
# maintain the data file
local tempfile="$datafile.$RANDOM"
diff --git a/plugins/zsh_reload/README.md b/plugins/zsh_reload/README.md
index d31a827fe..0b2e2a775 100644
--- a/plugins/zsh_reload/README.md
+++ b/plugins/zsh_reload/README.md
@@ -1,23 +1,3 @@
# zsh_reload plugin
-The zsh_reload plugin defines a function to reload the zsh session with
-just a few keystrokes.
-
-To use it, add `zsh_reload` to the plugins array in your zshrc file:
-
-```zsh
-plugins=(... zsh_reload)
-```
-
-## Usage
-
-To reload the zsh session, just run `src`:
-
-```zsh
-$ vim ~/.zshrc # enabled a plugin
-$ src
-re-compiling /home/user/.zshrc.zwc: succeeded
-re-compiling /home/user/.oh-my-zsh/cache/zcomp-host.zwc: succeeded
-
-# you now have a fresh zsh session. happy hacking!
-```
+**This plugin is deprecated.** Use `omz reload` or `exec zsh` instead.
diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh
index 0d29a7ce3..6a058ec5e 100644
--- a/plugins/zsh_reload/zsh_reload.plugin.zsh
+++ b/plugins/zsh_reload/zsh_reload.plugin.zsh
@@ -1,22 +1,7 @@
-src() {
- local cache="$ZSH_CACHE_DIR"
- autoload -U compinit zrecompile
- compinit -i -d "$cache/zcomp-$HOST"
-
- for f in ${ZDOTDIR:-~}/.zshrc "$cache/zcomp-$HOST"; do
- zrecompile -p $f && command rm -f $f.zwc.old
- done
+print ${(%):-"%F{yellow}The \`zsh_reload\` plugin is deprecated and will be removed."}
+print ${(%):-"Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f"}
- # Use $SHELL if it's available and a zsh shell
- local shell="$ZSH_ARGZERO"
- if [[ "${${SHELL:t}#-}" = zsh ]]; then
- shell="$SHELL"
- fi
-
- # Remove leading dash if login shell and run accordingly
- if [[ "${shell:0:1}" = "-" ]]; then
- exec -l "${shell#-}"
- else
- exec "$shell"
- fi
+src() {
+ print ${(%):-"%F{yellow}$0 is deprecated. Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f\n"}
+ omz reload
}
diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
index 4a998c2fc..7e1c7997c 100644
--- a/templates/zshrc.zsh-template
+++ b/templates/zshrc.zsh-template
@@ -23,14 +23,13 @@ ZSH_THEME="robbyrussell"
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
-# Uncomment the following line to disable bi-weekly auto-update checks.
-# DISABLE_AUTO_UPDATE="true"
-
-# Uncomment the following line to automatically update without prompting.
-# DISABLE_UPDATE_PROMPT="true"
+# Uncomment one of the following lines to change the auto-update behavior
+# zstyle ':omz:update' mode disabled # disable automatic updates
+# zstyle ':omz:update' mode auto # update automatically without asking
+# zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
-# export UPDATE_ZSH_DAYS=13
+# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme
index c79027ed6..c4d785126 100644
--- a/themes/half-life.zsh-theme
+++ b/themes/half-life.zsh-theme
@@ -7,31 +7,22 @@
# git untracked files modification from Brian Carper:
# https://briancarper.net/blog/570/git-info-in-your-zsh-prompt
-function virtualenv_info {
- [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
-}
-PR_GIT_UPDATE=1
-
-setopt prompt_subst
-
-autoload -U add-zsh-hook
-autoload -Uz vcs_info
-
#use extended color palette if available
-if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
- turquoise="%F{81}"
- orange="%F{166}"
- purple="%F{135}"
- hotpink="%F{161}"
- limegreen="%F{118}"
+if [[ $TERM = (*256color|*rxvt*) ]]; then
+ turquoise="%{${(%):-"%F{81}"}%}"
+ orange="%{${(%):-"%F{166}"}%}"
+ purple="%{${(%):-"%F{135}"}%}"
+ hotpink="%{${(%):-"%F{161}"}%}"
+ limegreen="%{${(%):-"%F{118}"}%}"
else
- turquoise="$fg[cyan]"
- orange="$fg[yellow]"
- purple="$fg[magenta]"
- hotpink="$fg[red]"
- limegreen="$fg[green]"
+ turquoise="%{${(%):-"%F{cyan}"}%}"
+ orange="%{${(%):-"%F{yellow}"}%}"
+ purple="%{${(%):-"%F{magenta}"}%}"
+ hotpink="%{${(%):-"%F{red}"}%}"
+ limegreen="%{${(%):-"%F{green}"}%}"
fi
+autoload -Uz vcs_info
# enable VCS systems you use
zstyle ':vcs_info:*' enable git svn
@@ -47,10 +38,10 @@ zstyle ':vcs_info:*:prompt:*' check-for-changes true
# %R - repository path
# %S - path in the repository
PR_RST="%{${reset_color}%}"
-FMT_BRANCH=" on %{$turquoise%}%b%u%c${PR_RST}"
-FMT_ACTION=" performing a %{$limegreen%}%a${PR_RST}"
-FMT_UNSTAGED="%{$orange%} ●"
-FMT_STAGED="%{$limegreen%} ●"
+FMT_BRANCH=" on ${turquoise}%b%u%c${PR_RST}"
+FMT_ACTION=" performing a ${limegreen}%a${PR_RST}"
+FMT_UNSTAGED="${orange} ●"
+FMT_STAGED="${limegreen} ●"
zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}"
zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}"
@@ -59,38 +50,44 @@ zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
-function steeef_preexec {
- case "$2" in
- *git*)
- PR_GIT_UPDATE=1
- ;;
- *svn*)
- PR_GIT_UPDATE=1
- ;;
- esac
+function steeef_chpwd {
+ PR_GIT_UPDATE=1
}
-add-zsh-hook preexec steeef_preexec
-function steeef_chpwd {
- PR_GIT_UPDATE=1
+function steeef_preexec {
+ case "$2" in
+ *git*|*svn*) PR_GIT_UPDATE=1 ;;
+ esac
}
-add-zsh-hook chpwd steeef_chpwd
function steeef_precmd {
- if [[ -n "$PR_GIT_UPDATE" ]] ; then
- # check for untracked files or updated submodules, since vcs_info doesn't
- if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
- PR_GIT_UPDATE=1
- FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c%{$hotpink%} ●${PR_RST}"
- else
- FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c${PR_RST}"
- fi
- zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
+ (( PR_GIT_UPDATE )) || return
- vcs_info 'prompt'
- PR_GIT_UPDATE=
- fi
+ # check for untracked files or updated submodules, since vcs_info doesn't
+ if [[ -n "$(git ls-files --other --exclude-standard 2>/dev/null)" ]]; then
+ PR_GIT_UPDATE=1
+ FMT_BRANCH="${PM_RST} on ${turquoise}%b%u%c${hotpink} ●${PR_RST}"
+ else
+ FMT_BRANCH="${PM_RST} on ${turquoise}%b%u%c${PR_RST}"
+ fi
+ zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
+
+ vcs_info 'prompt'
+ PR_GIT_UPDATE=
}
+
+# vcs_info running hooks
+PR_GIT_UPDATE=1
+
+autoload -U add-zsh-hook
+add-zsh-hook chpwd steeef_chpwd
add-zsh-hook precmd steeef_precmd
+add-zsh-hook preexec steeef_preexec
+
+# ruby prompt settings
+ZSH_THEME_RUBY_PROMPT_PREFIX="with%F{red} "
+ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_RVM_PROMPT_OPTIONS="v g"
-PROMPT=$'%{$purple%}%n%{$reset_color%} in %{$limegreen%}%~%{$reset_color%}$(ruby_prompt_info " with%{$fg[red]%} " v g "%{$reset_color%}")$vcs_info_msg_0_%{$orange%} λ%{$reset_color%} '
+setopt prompt_subst
+PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} "
diff --git a/themes/obraun.zsh-theme b/themes/obraun.zsh-theme
index cc2769e4b..c64362b04 100644
--- a/themes/obraun.zsh-theme
+++ b/themes/obraun.zsh-theme
@@ -2,10 +2,9 @@ if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
-PROMPT='%{$fg[green]%}[%*]%{$reset_color%} %{$fg_no_bold[cyan]%}%n %{${fg_bold[blue]}%}::%{$reset_color%} %{$fg[yellow]%}%m%{$reset_color%} %{$fg_no_bold[magenta]%} ➜ %{$reset_color%} %{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} '
+PROMPT='%{$fg[green]%}[%D{%H:%M:%S}]%{$reset_color%} %{$fg_no_bold[cyan]%}%n %{${fg_bold[blue]}%}::%{$reset_color%} %{$fg[yellow]%}%m%{$reset_color%} %{$fg_no_bold[magenta]%} ➜ %{$reset_color%} %{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} '
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
-
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index e87da3487..157b0cce2 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -3,22 +3,70 @@ if [[ -f ~/.zsh-update && ! -f "${ZSH_CACHE_DIR}/.zsh-update" ]]; then
mv ~/.zsh-update "${ZSH_CACHE_DIR}/.zsh-update"
fi
+# Get user's update preferences
+#
+# Supported update modes:
+# - prompt (default): the user is asked before updating when it's time to update
+# - auto: the update is performed automatically when it's time
+# - reminder: a reminder is shown to the user when it's time to update
+# - disabled: automatic update is turned off
+zstyle -s ':omz:update' mode update_mode || update_mode=prompt
+
+# Support old-style settings
+[[ "$DISABLE_UPDATE_PROMPT" != true ]] || update_mode=auto
+[[ "$DISABLE_AUTO_UPDATE" != true ]] || update_mode=disabled
+
# Cancel update if:
# - the automatic update is disabled.
# - the current user doesn't have write permissions nor owns the $ZSH directory.
# - git is unavailable on the system.
-if [[ "$DISABLE_AUTO_UPDATE" = true ]] \
+if [[ "$update_mode" = disabled ]] \
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|| ! command -v git &>/dev/null; then
+ unset update_mode
return
fi
-
function current_epoch() {
zmodload zsh/datetime
echo $(( EPOCHSECONDS / 60 / 60 / 24 ))
}
+function is_update_available() {
+ local branch
+ branch=${"$(git -C "$ZSH" config --local oh-my-zsh.branch)":-master}
+
+ local remote remote_url remote_repo
+ remote=${"$(git -C "$ZSH" config --local oh-my-zsh.remote)":-origin}
+ remote_url=$(git -C "$ZSH" config remote.$remote.url)
+
+ local repo
+ case "$remote_url" in
+ https://github.com/*) repo=${${remote_url#https://github.com/}%.git} ;;
+ git@github.com:*) repo=${${remote_url#git@github.com:}%.git} ;;
+ *)
+ # If the remote is not using GitHub we can't check for updates
+ # Let's assume there are updates
+ return 0 ;;
+ esac
+
+ # If the remote repo is not the official one, let's assume there are updates available
+ [[ "$repo" = ohmyzsh/ohmyzsh ]] || return 0
+ local api_url="https://api.github.com/repos/${repo}/commits/${branch}"
+
+ # Get local and remote HEADs and compare them. If we can't get either assume there are updates
+ local local_head remote_head
+ local_head=$(git -C "$ZSH" rev-parse $branch 2>/dev/null) || return 0
+
+ remote_head=$(curl -fsSL -H 'Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null) \
+ || remote_head=$(wget -O- --header='Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null) \
+ || remote_head=$(HTTP_ACCEPT='Accept: application/vnd.github.v3.sha' fetch -o - $api_url 2>/dev/null) \
+ || return 0
+
+ # Compare local and remote HEADs
+ [[ "$local_head" != "$remote_head" ]]
+}
+
function update_last_updated_file() {
echo "LAST_EPOCH=$(current_epoch)" >! "${ZSH_CACHE_DIR}/.zsh-update"
}
@@ -56,7 +104,8 @@ function update_ohmyzsh() {
# the shell actually exits what it's running.
trap "
ret=\$?
- unset -f current_epoch update_last_updated_file update_ohmyzsh 2>/dev/null
+ unset update_mode
+ unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh 2>/dev/null
command rm -rf '$ZSH/log/update.lock'
return \$ret
" EXIT INT QUIT
@@ -68,15 +117,22 @@ function update_ohmyzsh() {
fi
# Number of days before trying to update again
- epoch_target=${UPDATE_ZSH_DAYS:-13}
+ zstyle -s ':omz:update' frequency epoch_target || epoch_target=${UPDATE_ZSH_DAYS:-13}
# Test if enough time has passed until the next update
if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
return
fi
- # Ask for confirmation before updating unless disabled
- if [[ "$DISABLE_UPDATE_PROMPT" = true ]]; then
+ # Check if there are updates available before proceeding
+ if ! is_update_available; then
+ return
+ fi
+
+ # Ask for confirmation before updating unless in auto mode
+ if [[ "$update_mode" = auto ]]; then
update_ohmyzsh
+ elif [[ "$update_mode" = reminder ]]; then
+ echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
else
# input sink to swallow all characters typed before the prompt
# and add a newline if there wasn't one after characters typed
@@ -92,3 +148,6 @@ function update_ohmyzsh() {
esac
fi
}
+
+unset update_mode
+unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index 1424d1433..7642858fe 100755
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -15,11 +15,98 @@ cd "$ZSH"
# Use colors, but only if connected to a terminal
# and that terminal supports them.
+# The [ -t 1 ] check only works when the function is not called from
+# a subshell (like in `$(...)` or `(...)`, so this hack redefines the
+# function at the top level to always return false when stdout is not
+# a tty.
+if [ -t 1 ]; then
+ is_tty() {
+ true
+ }
+else
+ is_tty() {
+ false
+ }
+fi
+
+# This function uses the logic from supports-hyperlinks[1][2], which is
+# made by Kat Marchán (@zkat) and licensed under the Apache License 2.0.
+# [1] https://github.com/zkat/supports-hyperlinks
+# [2] https://crates.io/crates/supports-hyperlinks
+#
+# Copyright (c) 2021 Kat Marchán
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+supports_hyperlinks() {
+ # $FORCE_HYPERLINK must be set and be non-zero (this acts as a logic bypass)
+ if [ -n "$FORCE_HYPERLINK" ]; then
+ [ "$FORCE_HYPERLINK" != 0 ]
+ return $?
+ fi
+
+ # If stdout is not a tty, it doesn't support hyperlinks
+ is_tty || return 1
+
+ # DomTerm terminal emulator (domterm.org)
+ if [ -n "$DOMTERM" ]; then
+ return 0
+ fi
+
+ # VTE-based terminals above v0.50 (Gnome Terminal, Guake, ROXTerm, etc)
+ if [ -n "$VTE_VERSION" ]; then
+ [ $VTE_VERSION -ge 5000 ]
+ return $?
+ fi
+
+ # If $TERM_PROGRAM is set, these terminals support hyperlinks
+ case "$TERM_PROGRAM" in
+ Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
+ esac
+
+ # kitty supports hyperlinks
+ if [ "$TERM" = xterm-kitty ]; then
+ return 0
+ fi
+
+ # Windows Terminal or Konsole also support hyperlinks
+ if [ -n "$WT_SESSION" ] || [ -n "$KONSOLE_VERSION" ]; then
+ return 0
+ fi
+
+ return 1
+}
+
+fmt_link() {
+ # $1: text, $2: url, $3: fallback mode
+ if supports_hyperlinks; then
+ printf '\033]8;;%s\a%s\033]8;;\a\n' "$2" "$1"
+ return
+ fi
+
+ case "$3" in
+ --text) printf '%s\n' "$1" ;;
+ --url|*) fmt_underline "$2" ;;
+ esac
+}
+
+fmt_underline() {
+ is_tty && printf '\033[4m%s\033[24m\n' "$*" || printf '%s\n' "$*"
+}
+
setopt typeset_silent
typeset -a RAINBOW
-typeset RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
-if [ -t 1 ]; then
+if is_tty; then
RAINBOW=(
"$(printf '\033[38;5;196m')"
"$(printf '\033[38;5;202m')"
@@ -35,8 +122,6 @@ if [ -t 1 ]; then
YELLOW=$(printf '\033[33m')
BLUE=$(printf '\033[34m')
BOLD=$(printf '\033[1m')
- DIM=$(printf '\033[2m')
- UNDER=$(printf '\033[4m')
RESET=$(printf '\033[0m')
fi
@@ -104,10 +189,10 @@ 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 '\n'
- printf "${BLUE}%s${RESET}\n" "$message"
- printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "https://twitter.com/ohmyzsh"
- printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Want to get involved in the community? Join our Discord:" "https://discord.gg/ohmyzsh"
- printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Get your Oh My Zsh swag at:" "https://shop.planetargon.com/collections/oh-my-zsh"
+ 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)"
+ printf "${BLUE}${BOLD}%s %s${RESET}\n" "Want to get involved in the community? Join our Discord:" "$(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
+ printf "${BLUE}${BOLD}%s %s${RESET}\n" "Get your Oh My Zsh swag at:" "$(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
else
ret=$?
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'