summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/CODEOWNERS1
-rw-r--r--.github/FUNDING.yml2
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md1
-rw-r--r--.github/ISSUE_TEMPLATE/feature_request.md2
-rw-r--r--.github/ISSUE_TEMPLATE/support.md2
-rw-r--r--README.md63
-rw-r--r--lib/cli.zsh180
-rw-r--r--lib/completion.zsh2
-rw-r--r--lib/functions.zsh17
-rw-r--r--lib/git.zsh124
-rw-r--r--lib/history.zsh1
-rw-r--r--lib/nvm.zsh9
-rw-r--r--lib/termsupport.zsh14
-rw-r--r--oh-my-zsh.sh3
-rw-r--r--plugins/bgnotify/bgnotify.plugin.zsh2
-rw-r--r--plugins/brew/README.md21
-rw-r--r--plugins/brew/brew.plugin.zsh5
-rw-r--r--plugins/bundler/README.md79
-rw-r--r--plugins/bundler/bundler.plugin.zsh116
-rw-r--r--plugins/chucknorris/fortunes/chucknorris286
-rw-r--r--plugins/common-aliases/common-aliases.plugin.zsh6
-rw-r--r--plugins/composer/composer.plugin.zsh2
-rw-r--r--plugins/docker/README.md22
-rw-r--r--plugins/fzf/README.md30
-rw-r--r--plugins/fzf/fzf.plugin.zsh10
-rw-r--r--plugins/git-lfs/README.md24
-rw-r--r--plugins/git-lfs/git-lfs.plugin.zsh17
-rw-r--r--plugins/git/git.plugin.zsh14
-rw-r--r--plugins/ipfs/LICENSE22
-rw-r--r--plugins/ipfs/README.md17
-rw-r--r--plugins/ipfs/_ipfs717
-rw-r--r--plugins/kubectl/README.md8
-rw-r--r--plugins/kubectl/kubectl.plugin.zsh16
-rw-r--r--plugins/lando/LICENSE21
-rw-r--r--plugins/lando/README.md37
-rw-r--r--plugins/lando/lando.plugin.zsh40
-rw-r--r--plugins/laravel5/laravel5.plugin.zsh19
-rw-r--r--plugins/minikube/minikube.plugin.zsh10
-rw-r--r--plugins/mvn/README.md1
-rw-r--r--plugins/mvn/mvn.plugin.zsh13
-rw-r--r--plugins/nvm/README.md19
-rw-r--r--plugins/nvm/nvm.plugin.zsh81
-rw-r--r--plugins/pip/pip.plugin.zsh6
-rw-r--r--plugins/pyenv/pyenv.plugin.zsh2
-rw-r--r--plugins/safe-paste/safe-paste.plugin.zsh128
-rw-r--r--plugins/scd/README.md54
-rw-r--r--plugins/scd/_scd60
-rwxr-xr-x[-rw-r--r--]plugins/scd/scd343
-rw-r--r--plugins/scd/scd.plugin.zsh16
-rw-r--r--plugins/sublime-merge/README.md17
-rw-r--r--plugins/sublime-merge/sublime-merge.plugin.zsh55
-rw-r--r--plugins/sublime/sublime.plugin.zsh2
-rw-r--r--plugins/sudo/sudo.plugin.zsh11
-rw-r--r--plugins/terraform/README.md3
-rw-r--r--plugins/terraform/terraform.plugin.zsh2
-rw-r--r--plugins/timer/timer.plugin.zsh5
-rw-r--r--plugins/vagrant-prompt/vagrant-prompt.plugin.zsh25
-rw-r--r--plugins/wd/README.md186
-rw-r--r--plugins/wd/wd.sh163
-rw-r--r--plugins/z/README8
-rw-r--r--plugins/z/z.13
-rw-r--r--plugins/z/z.sh44
-rw-r--r--plugins/zsh_reload/zsh_reload.plugin.zsh14
-rw-r--r--themes/agnoster.zsh-theme4
-rw-r--r--themes/avit.zsh-theme4
-rw-r--r--themes/fino.zsh-theme29
-rw-r--r--themes/fishy.zsh-theme18
-rw-r--r--themes/pygmalion-virtualenv.zsh-theme10
-rw-r--r--themes/pygmalion.zsh-theme10
-rw-r--r--themes/random.zsh-theme15
-rw-r--r--themes/trapd00r.zsh-theme2
-rwxr-xr-xtools/install.sh18
-rw-r--r--tools/upgrade.sh12
73 files changed, 2511 insertions, 834 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index cba8e93af..c3990c4ee 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,3 +1,4 @@
# Plugin owners
plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg
+plugins/git-lfs/ @vietduc01100001
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000..c44bb2475
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+github: [robbyrussell, mcornella, larson-carter]
+open_collective: ohmyzsh
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index b7f5460c1..611d8ebae 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,7 +1,6 @@
---
name: Bug report
about: Create a report to help us improve Oh My Zsh
-labels: 'Type: support'
---
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 0a8a588db..8c20544c8 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -1,7 +1,7 @@
---
name: Feature request
about: Suggest a feature for Oh My Zsh
-labels: 'Type: feature'
+labels: 'feature'
---
diff --git a/.github/ISSUE_TEMPLATE/support.md b/.github/ISSUE_TEMPLATE/support.md
index d2638412e..697f0c0c8 100644
--- a/.github/ISSUE_TEMPLATE/support.md
+++ b/.github/ISSUE_TEMPLATE/support.md
@@ -1,7 +1,7 @@
---
name: Support
about: Request support for any problem you're having with Oh My Zsh
-labels: 'Type: support'
+labels: 'support'
---
diff --git a/README.md b/README.md
index 329eff178..0c292e100 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,16 @@
-<p align="center">
- <img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh">
-</p>
+<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p>
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
Sounds boring. Let's try again.
-__Oh My Zsh will not make you a 10x developer...but you may feel like one.__
+**Oh My Zsh will not make you a 10x developer...but you may feel like one.**
Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬
-To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on [Discord](https://discord.gg/ohmyzsh).
+To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and join us on [Discord](https://discord.gg/ohmyzsh).
[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
@@ -22,26 +20,20 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
### Prerequisites
-* A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work.
-* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
-* `curl` or `wget` should be installed
-* `git` should be installed (recommended v2.4.11 or higher)
+- A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work.
+- [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
+- `curl` or `wget` should be installed
+- `git` should be installed (recommended v2.4.11 or higher)
### Basic Installation
-Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`, whichever is installed on your machine.
+Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool.
-#### via curl
-
-```shell
-sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
-```
-
-#### via wget
-
-```shell
-sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
-```
+| Method | Command |
+|:----------|:--------------------------------------------------------------------------------------------------|
+| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
+| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
+| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
#### Manual inspection
@@ -50,7 +42,7 @@ that by downloading the install script first, looking through it so everything l
then running it:
```shell
-curl -Lo install.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
+wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh
```
@@ -86,7 +78,7 @@ _Note that the plugins are separated by whitespace (spaces, tabs, new lines...).
#### Using Plugins
-Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are inclued in that particular plugin.
+Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
### Themes
@@ -119,7 +111,6 @@ 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
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
```
@@ -133,10 +124,10 @@ ZSH_THEME_RANDOM_CANDIDATES=(
)
```
-If you only know which themes you don't like, you can add them similarly to a blacklist:
+If you only know which themes you don't like, you can add them similarly to an ignored list:
```shell
-ZSH_THEME_RANDOM_BLACKLIST=(pygmalion tjkirch_mod)
+ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
```
### FAQ
@@ -199,13 +190,13 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
#### Manual Installation
-##### 1. Clone the repository:
+##### 1. Clone the repository
```shell
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
```
-##### 2. *Optionally*, backup your existing `~/.zshrc` file:
+##### 2. *Optionally*, backup your existing `~/.zshrc` file
```shell
cp ~/.zshrc ~/.zshrc.orig
@@ -235,9 +226,9 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
If you have any hiccups installing, here are a few common fixes.
-* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
+- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
switching to `oh-my-zsh`.
-* If you installed manually or changed the install location, check the `ZSH` environment variable in
+- If you installed manually or changed the install location, check the `ZSH` environment variable in
`~/.zshrc`.
### Custom Plugins and Themes
@@ -267,7 +258,7 @@ DISABLE_AUTO_UPDATE=true
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:
```shell
-upgrade_oh_my_zsh
+omz update
```
Magic! 🎉
@@ -300,12 +291,12 @@ Thank you so much!
## Follow Us
-We're on the social media.
+We're on social media:
-* [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
-* [FaceBook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us.
-* [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh!
-* [Discord](https://discord.gg/ohmyzsh) to chat with us!
+- [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
+- [FaceBook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us.
+- [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh!
+- [Discord](https://discord.gg/ohmyzsh) to chat with us!
## Merchandise
diff --git a/lib/cli.zsh b/lib/cli.zsh
index 3c09cdab8..ff865093d 100644
--- a/lib/cli.zsh
+++ b/lib/cli.zsh
@@ -23,16 +23,27 @@ function _omz {
local -a cmds subcmds
cmds=(
'help:Usage information'
+ 'plugin:Commands for Oh My Zsh plugins management'
+ 'pr:Commands for Oh My Zsh Pull Requests management'
+ 'theme:Commands for Oh My Zsh themes management'
'update:Update Oh My Zsh'
- 'pr:Commands for Oh My Zsh Pull Requests'
)
if (( CURRENT == 2 )); then
_describe 'command' cmds
elif (( CURRENT == 3 )); then
case "$words[2]" in
- pr) subcmds=( 'test:Test a Pull Request' 'clean:Delete all Pull Request branches' )
+ plugin) subcmds=('list:List plugins')
_describe 'command' subcmds ;;
+ pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches')
+ _describe 'command' subcmds ;;
+ theme) subcmds=('use:Load a theme' 'list:List themes')
+ _describe 'command' subcmds ;;
+ esac
+ elif (( CURRENT == 4 )); then
+ case "$words[2]::$words[3]" in
+ theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \
+ "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;;
esac
fi
@@ -49,23 +60,41 @@ Usage: omz <command> [options]
Available commands:
help Print this help message
+ plugin <command> Manage plugins
+ pr <command> Manage Oh My Zsh Pull Requests
+ theme <command> Manage themes
update Update Oh My Zsh
- pr <command> Commands for Oh My Zsh Pull Requests
EOF
}
+function _omz::confirm {
+ # If question supplied, ask it before reading the answer
+ # NOTE: uses the logname of the caller function
+ if [[ -n "$1" ]]; then
+ _omz::log prompt "$1" "${${functrace[1]#_}%:*}"
+ fi
+
+ # Read one character
+ read -r -k 1
+
+ # If no newline entered, add a newline
+ if [[ "$REPLY" != $'\n' ]]; then
+ echo
+ fi
+}
+
function _omz::log {
# if promptsubst is set, a message with `` or $()
# will be run even if quoted due to `print -P`
setopt localoptions nopromptsubst
# $1 = info|warn|error|debug
- # $@ = text
+ # $2 = text
+ # $3 = (optional) name of the logger
local logtype=$1
- local logname=${${functrace[1]#_}%:*}
- shift
+ local logname=${3:-${${functrace[1]#_}%:*}}
# Don't print anything if debug is not active
if [[ $logtype = debug && -z $_OMZ_DEBUG ]]; then
@@ -74,14 +103,54 @@ function _omz::log {
# Choose coloring based on log type
case "$logtype" in
- prompt) print -Pn "%S%F{blue}$logname%f%s: $@" ;;
- debug) print -P "%F{white}$logname%f: $@" ;;
- info) print -P "%F{green}$logname%f: $@" ;;
- warn) print -P "%S%F{yellow}$logname%f%s: $@" ;;
- error) print -P "%S%F{red}$logname%f%s: $@" ;;
+ prompt) print -Pn "%S%F{blue}$logname%f%s: $2" ;;
+ debug) print -P "%F{white}$logname%f: $2" ;;
+ info) print -P "%F{green}$logname%f: $2" ;;
+ warn) print -P "%S%F{yellow}$logname%f%s: $2" ;;
+ error) print -P "%S%F{red}$logname%f%s: $2" ;;
esac >&2
}
+function _omz::plugin {
+ (( $# > 0 && $+functions[_omz::plugin::$1] )) || {
+ cat <<EOF
+Usage: omz plugin <command> [options]
+
+Available commands:
+
+ list List all available Oh My Zsh plugins
+
+EOF
+ return 1
+ }
+
+ local command="$1"
+ shift
+
+ _omz::plugin::$command "$@"
+}
+
+function _omz::plugin::list {
+ local -a custom_plugins builtin_plugins
+ custom_plugins=("$ZSH_CUSTOM"/plugins/*(/N:t))
+ builtin_plugins=("$ZSH"/plugins/*(/N:t))
+
+ {
+ (( ${#custom_plugins} )) && {
+ print -Pn "%U%BCustom plugins%b%u: "
+ print -l ${(q-)custom_plugins}
+ }
+
+ (( ${#builtin_plugins} )) && {
+ # add a line of separation
+ (( ${#custom_plugins} )) && echo
+
+ print -Pn "%U%BBuilt-in plugins%b%u: "
+ print -l ${(q-)builtin_plugins}
+ }
+ } | fmt -w $COLUMNS | sed -E $'s/\e?(\\[[0-9]*m)/\e\\1/g' # deal with fmt removing ESC
+}
+
function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
cat <<EOF
@@ -107,6 +176,24 @@ function _omz::pr::clean {
set -e
builtin cd -q "$ZSH"
+ # Check if there are PR branches
+ local fmt branches
+ fmt="%(color:bold blue)%(align:18,right)%(refname:short)%(end)%(color:reset) %(color:dim bold red)%(objectname:short)%(color:reset) %(color:yellow)%(contents:subject)"
+ branches="$(command git for-each-ref --sort=-committerdate --color --format="$fmt" "refs/heads/ohmyzsh/pull-*")"
+
+ # Exit if there are no PR branches
+ if [[ -z "$branches" ]]; then
+ _omz::log info "there are no Pull Request branches to remove."
+ return
+ fi
+
+ # Print found PR branches
+ echo "$branches\n"
+ # Confirm before removing the branches
+ _omz::confirm "do you want remove these Pull Request branches? [Y/n] "
+ # Only proceed if the answer is a valid yes option
+ [[ "$REPLY" != [yY$'\n'] ]] && return
+
_omz::log info "removing all Oh My Zsh Pull Request branches..."
command git branch --list 'ohmyzsh/pull-*' | while read branch; do
command git branch -D "$branch"
@@ -181,13 +268,9 @@ function _omz::pr::test {
command zsh -l
# After testing, go back to the previous HEAD if the user wants
- _omz::log prompt "do you want to go back to the previous branch? [Y/n] "
- read -r -k 1
-
- # If no newline entered, add a newline
- [[ "$REPLY" != $'\n' ]] && echo
- # If NO selected, do nothing else
- [[ "$REPLY" = [nN] ]] && return
+ _omz::confirm "do you want to go back to the previous branch? [Y/n] "
+ # Only proceed if the answer is a valid yes option
+ [[ "$REPLY" != [yY$'\n'] ]] && return
(
set -e
@@ -200,7 +283,68 @@ function _omz::pr::test {
)
}
+function _omz::theme {
+ (( $# > 0 && $+functions[_omz::theme::$1] )) || {
+ cat <<EOF
+Usage: omz theme <command> [options]
+
+Available commands:
+
+ list List all available Oh My Zsh themes
+ use <theme> Load an Oh My Zsh theme
+
+EOF
+ return 1
+ }
+
+ local command="$1"
+ shift
+
+ _omz::theme::$command "$@"
+}
+
+function _omz::theme::list {
+ local -a custom_themes builtin_themes
+ custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
+ builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r))
+
+ {
+ (( ${#custom_themes} )) && {
+ print -Pn "%U%BCustom themes%b%u: "
+ print -l ${(q-)custom_themes}
+ }
+
+ (( ${#builtin_themes} )) && {
+ # add a line of separation
+ (( ${#custom_themes} )) && echo
+
+ print -Pn "%U%BBuilt-in themes%b%u: "
+ print -l ${(q-)builtin_themes}
+ }
+ } | fmt -w $COLUMNS | sed -E $'s/\e?(\\[[0-9]*m)/\e\\1/g' # deal with fmt removing ESC
+}
+
+function _omz::theme::use {
+ if [[ -z "$1" ]]; then
+ echo >&2 "Usage: omz theme use <theme>"
+ return 1
+ fi
+
+ # Respect compatibility with old lookup order
+ if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/$1.zsh-theme"
+ elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/themes/$1.zsh-theme"
+ elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
+ source "$ZSH/themes/$1.zsh-theme"
+ else
+ _omz::log error "theme '$1' not found"
+ return 1
+ fi
+}
+
function _omz::update {
+ # Run update script
env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
# Update last updated file
zmodload zsh/datetime
diff --git a/lib/completion.zsh b/lib/completion.zsh
index 2b62785d5..a3873cd08 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -1,7 +1,7 @@
# fixme - the load process here seems a bit bizarre
zmodload -i zsh/complist
-WORDCHARS=''
+WORDCHARS='_-'
unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
diff --git a/lib/functions.zsh b/lib/functions.zsh
index e85b867a5..58f0e3fb0 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -1,5 +1,7 @@
function zsh_stats() {
- fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
+ fc -l 1 \
+ | awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
+ | grep -v "./" | sort -nr | head -n20 | column -c3 -s " " -t | nl
}
function uninstall_oh_my_zsh() {
@@ -7,8 +9,17 @@ function uninstall_oh_my_zsh() {
}
function upgrade_oh_my_zsh() {
- echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
- omz update
+ if (( $+functions[_omz::update] )); then
+ echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
+ fi
+
+ # Run update script
+ env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
+ # Update last updated file
+ zmodload zsh/datetime
+ echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
+ # Remove update lock if it exists
+ command rm -rf "$ZSH/log/update.lock"
}
function take() {
diff --git a/lib/git.zsh b/lib/git.zsh
index ffc7c01a1..53d39609e 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -147,44 +147,102 @@ function git_prompt_long_sha() {
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}
-# Get the status of the working tree
function git_prompt_status() {
- emulate -L zsh
+ [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
- local INDEX STATUS
- INDEX=$(__git_prompt_git status --porcelain -b 2> /dev/null) || return 0
- STATUS=""
- if [[ "${INDEX}" =~ $'(^|\n)\\?\\? ' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
- fi
- if [[ "${INDEX}" =~ $'(^|\n)(A |M |MM) ' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
- fi
- if [[ "${INDEX}" =~ $'(^|\n)([ AM]M| T) ' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
- fi
- if [[ "${INDEX}" =~ $'(^|\n)R ' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
- fi
- if [[ "${INDEX}" =~ $'(^|\n)([A ]D|D ) ' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
- fi
- if $(__git_prompt_git rev-parse --verify refs/stash >/dev/null 2>&1); then
- STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
- fi
- if [[ "${INDEX}" =~ $'(^|\n)UU ' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
- fi
- if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*ahead' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
+ # Maps a git status prefix to an internal constant
+ # This cannot use the prompt constants, as they may be empty
+ local -A prefix_constant_map
+ prefix_constant_map=(
+ '\?\? ' 'UNTRACKED'
+ 'A ' 'ADDED'
+ 'M ' 'ADDED'
+ 'MM ' 'ADDED'
+ ' M ' 'MODIFIED'
+ 'AM ' 'MODIFIED'
+ ' T ' 'MODIFIED'
+ 'R ' 'RENAMED'
+ ' D ' 'DELETED'
+ 'D ' 'DELETED'
+ 'UU ' 'UNMERGED'
+ 'ahead' 'AHEAD'
+ 'behind' 'BEHIND'
+ 'diverged' 'DIVERGED'
+ 'stashed' 'STASHED'
+ )
+
+ # Maps the internal constant to the prompt theme
+ local -A constant_prompt_map
+ constant_prompt_map=(
+ 'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
+ 'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED"
+ 'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED"
+ 'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED"
+ 'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED"
+ 'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED"
+ 'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD"
+ 'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND"
+ 'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED"
+ 'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED"
+ )
+
+ # The order that the prompt displays should be added to the prompt
+ local status_constants
+ status_constants=(
+ UNTRACKED ADDED MODIFIED RENAMED DELETED
+ STASHED UNMERGED AHEAD BEHIND DIVERGED
+ )
+
+ local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
+
+ # Don't continue on a catastrophic failure
+ if [[ $? -eq 128 ]]; then
+ return 1
fi
- if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*behind' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
+
+ # A lookup table of each git status encountered
+ local -A statuses_seen
+
+ if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
+ statuses_seen[STASHED]=1
fi
- if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*diverged' ]]; then
- STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
+
+ local status_lines
+ status_lines=("${(@f)${status_text}}")
+
+ # If the tracking line exists, get and parse it
+ if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
+ local branch_statuses
+ branch_statuses=("${(@s/,/)match}")
+ for branch_status in $branch_statuses; do
+ if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then
+ continue
+ fi
+ local last_parsed_status=$prefix_constant_map[$match[1]]
+ statuses_seen[$last_parsed_status]=$match[2]
+ done
fi
- echo $STATUS
+
+ # For each status prefix, do a regex comparison
+ for status_prefix in ${(k)prefix_constant_map}; do
+ local status_constant="${prefix_constant_map[$status_prefix]}"
+ local status_regex=$'(^|\n)'"$status_prefix"
+
+ if [[ "$status_text" =~ $status_regex ]]; then
+ statuses_seen[$status_constant]=1
+ fi
+ done
+
+ # Display the seen statuses in the order specified
+ local status_prompt
+ for status_constant in $status_constants; do
+ if (( ${+statuses_seen[$status_constant]} )); then
+ local next_display=$constant_prompt_map[$status_constant]
+ status_prompt="$next_display$status_prompt"
+ fi
+ done
+
+ echo $status_prompt
}
# Outputs the name of the current user
diff --git a/lib/history.zsh b/lib/history.zsh
index 0ee8cfe7a..8d922a30b 100644
--- a/lib/history.zsh
+++ b/lib/history.zsh
@@ -36,4 +36,3 @@ setopt hist_expire_dups_first # delete duplicates first when HISTFILE size excee
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
-setopt share_history # share command history data
diff --git a/lib/nvm.zsh b/lib/nvm.zsh
index 4a8b6811e..2fe57a8f4 100644
--- a/lib/nvm.zsh
+++ b/lib/nvm.zsh
@@ -1,9 +1,6 @@
-# get the node.js version
+# get the nvm-controlled node.js version
function nvm_prompt_info() {
- [[ -f "$NVM_DIR/nvm.sh" ]] || return
- local nvm_prompt
- nvm_prompt=$(node -v 2>/dev/null)
- [[ "${nvm_prompt}x" == "x" ]] && return
- nvm_prompt=${nvm_prompt:1}
+ which nvm &>/dev/null || return
+ local nvm_prompt=${$(nvm current)#v}
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
}
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index 682925211..778f12bca 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -17,17 +17,17 @@ function title {
: ${2=$1}
case "$TERM" in
- cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*)
- print -Pn "\e]2;$2:q\a" # set window name
- print -Pn "\e]1;$1:q\a" # set tab name
+ cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
+ print -Pn "\e]2;${2:q}\a" # set window name
+ print -Pn "\e]1;${1:q}\a" # set tab name
;;
screen*|tmux*)
- print -Pn "\ek$1:q\e\\" # set screen hardstatus
+ print -Pn "\ek${1:q}\e\\" # set screen hardstatus
;;
*)
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
- print -Pn "\e]2;$2:q\a" # set window name
- print -Pn "\e]1;$1:q\a" # set tab name
+ 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
@@ -42,7 +42,7 @@ function title {
}
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
-ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
+ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
# Avoid duplication of directory in terminals with independent dir display
if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 5b057256d..16e244be5 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -1,3 +1,6 @@
+# If ZSH is not defined, use the current script's directory.
+[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
+
# Set ZSH_CACHE_DIR to the path where cache files should be created
# or else we will use the default cache/
if [[ -z "$ZSH_CACHE_DIR" ]]; then
diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh
index b3a6890b8..aecde20ea 100644
--- a/plugins/bgnotify/bgnotify.plugin.zsh
+++ b/plugins/bgnotify/bgnotify.plugin.zsh
@@ -53,7 +53,7 @@ bgnotify () { ## args: (title, subtitle)
bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS
- bgnotify_lastcmd="$1"
+ bgnotify_lastcmd="${1:-$2}"
bgnotify_windowid=$(currentWindowId)
}
diff --git a/plugins/brew/README.md b/plugins/brew/README.md
index 44af05225..b714b7ac0 100644
--- a/plugins/brew/README.md
+++ b/plugins/brew/README.md
@@ -10,16 +10,17 @@ plugins=(... brew)
## Aliases
-| Alias | Command | Description |
-|----------|-------------------------------------------------------------|---------------------------------------------------------------------|
-| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
-| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
-| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
-| `bubo` | `brew update && brew outdated` | Update Homebrew and all formulae, then list outdated formulae. |
-| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae, then run cleanup. |
-| `bubu` | `bubo && bubc` | Do the last two operations above. |
-| `bcubo` | `brew update && brew cask outdated` | Update Homebrew and alll formulae, then list outdated casks. |
-| `bcubc` | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Update outdated casks, then run cleanup. |
+| Alias | Command | Description |
+|----------|------------------------------------------------------------- |---------------------------------------------------------------------|
+| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
+| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
+| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
+| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
+| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
+| `bubu` | `bubo && bubc` | Do the last two operations above. |
+| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
+| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
+| `bcubc` | `brew cask reinstall $(brew outdated --cask) && brew cleanup` | Update outdated casks, then run cleanup. |
## Completion
diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
index fdea76c74..30eb135bb 100644
--- a/plugins/brew/brew.plugin.zsh
+++ b/plugins/brew/brew.plugin.zsh
@@ -4,5 +4,6 @@ alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup'
alias bubu='bubo && bubc'
-alias bcubo='brew update && brew cask outdated'
-alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup'
+alias buf='brew upgrade --formula'
+alias bcubo='brew update && brew outdated --cask'
+alias bcubc='brew cask reinstall $(brew outdated --cask) && brew cleanup'
diff --git a/plugins/bundler/README.md b/plugins/bundler/README.md
index a3bceb0ae..7b79cbcdc 100644
--- a/plugins/bundler/README.md
+++ b/plugins/bundler/README.md
@@ -1,34 +1,48 @@
# Bundler
-- Adds completion for basic bundler commands
-
-- Adds short aliases for common bundler commands
- - `ba` aliased to `bundle add`
- - `be` aliased to `bundle exec`.
- It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`).
- - `bl` aliased to `bundle list`
- - `bp` aliased to `bundle package`
- - `bo` aliased to `bundle open`
- - `bout` aliased to `bundle outdated`
- - `bu` aliased to `bundle update`
- - `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`)
- - `bcn` aliased to `bundle clean`
- - `bck` aliased to `bundle check`
-
-- Adds a wrapper for common gems:
- - Looks for a binstub under `./bin/` and executes it (if present)
- - Calls `bundle exec <gem executable>` otherwise
+This plugin adds completion for basic bundler commands, as well as aliases and helper functions for
+an easier experience with bundler.
+
+To use it, add `bundler` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... bundler)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|--------|--------------------------------------|------------------------------------------------------------------------------------------|
+| `ba` | `bundle add` | Add gem to the Gemfile and run bundle install |
+| `bck` | `bundle check` | Verifies if dependencies are satisfied by installed gems |
+| `bcn` | `bundle clean` | Cleans up unused gems in your bundler directory |
+| `be` | `bundle exec` | Execute a command in the context of the bundle |
+| `bi` | `bundle install --jobs=<core_count>` | Install the dependencies specified in your Gemfile (using all cores in bundler >= 1.4.0) |
+| `bl` | `bundle list` | List all the gems in the bundle |
+| `bo` | `bundle open` | Opens the source directory for a gem in your bundle |
+| `bout` | `bundle outdated` | List installed gems with newer versions available |
+| `bp` | `bundle package` | Package your needed .gem files into your application |
+| `bu` | `bundle update` | Update your gems to the latest available versions |
+
+## Gem wrapper
+
+The plugin adds a wrapper for common gems, which:
+
+- Looks for a binstub under `./bin/` and executes it if present.
+- Calls `bundle exec <gem>` otherwise.
Common gems wrapped by default (by name of the executable):
+
`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
-## Configuration
+### Settings
-Please use the exact name of the executable and not the gem name.
+You can add or remove gems from the list of wrapped commands.
+Please **use the exact name of the executable** and not the gem name.
-### Add additional gems to be wrapped
+#### Include gems to be wrapped (`BUNDLED_COMMANDS`)
-Add this before the plugin-list in your `.zshrc`:
+Add this before the plugin list in your `.zshrc`:
```sh
BUNDLED_COMMANDS=(rubocop)
@@ -37,10 +51,9 @@ plugins=(... bundler ...)
This will add the wrapper for the `rubocop` gem (i.e. the executable).
+#### Exclude gems from being wrapped (`UNBUNDLED_COMMANDS`)
-### Exclude gems from being wrapped
-
-Add this before the plugin-list in your `.zshrc`:
+Add this before the plugin list in your `.zshrc`:
```sh
UNBUNDLED_COMMANDS=(foreman spin)
@@ -49,13 +62,13 @@ plugins=(... bundler ...)
This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped.
-## Excluded gems
+### Excluded gems
-These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification.
+These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification:
-`berks`
-`foreman`
-`mailcatcher`
-`rails`
-`ruby`
-`spin`
+- `berks`
+- `foreman`
+- `mailcatcher`
+- `rails`
+- `ruby`
+- `spin`
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
index 65b0ffa6e..6293dc28a 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -1,13 +1,49 @@
+## Aliases
+
alias ba="bundle add"
+alias bck="bundle check"
+alias bcn="bundle clean"
alias be="bundle exec"
+alias bi="bundle_install"
alias bl="bundle list"
-alias bp="bundle package"
alias bo="bundle open"
alias bout="bundle outdated"
+alias bp="bundle package"
alias bu="bundle update"
-alias bi="bundle_install"
-alias bcn="bundle clean"
-alias bck="bundle check"
+
+## Functions
+
+bundle_install() {
+ # Bail out if bundler is not installed
+ if (( ! $+commands[bundle] )); then
+ echo "Bundler is not installed"
+ return 1
+ fi
+
+ # Bail out if not in a bundled project
+ if ! _within-bundled-project; then
+ echo "Can't 'bundle install' outside a bundled project"
+ return 1
+ fi
+
+ # Check the bundler version is at least 1.4.0
+ autoload -Uz is-at-least
+ local bundler_version=$(bundle version | cut -d' ' -f3)
+ if ! is-at-least 1.4.0 "$bundler_version"; then
+ bundle install "$@"
+ return $?
+ fi
+
+ # If bundler is at least 1.4.0, use all the CPU cores to bundle install
+ if [[ "$OSTYPE" = (darwin|freebsd)* ]]; then
+ local cores_num="$(sysctl -n hw.ncpu)"
+ else
+ local cores_num="$(nproc)"
+ fi
+ bundle install --jobs="$cores_num" "$@"
+}
+
+## Gem wrapper
bundled_commands=(
annotate
@@ -54,65 +90,41 @@ for cmd in $BUNDLED_COMMANDS; do
bundled_commands+=($cmd);
done
-## Functions
-
-bundle_install() {
- if ! _bundler-installed; then
- echo "Bundler is not installed"
- elif ! _within-bundled-project; then
- echo "Can't 'bundle install' outside a bundled project"
- else
- local bundler_version=`bundle version | cut -d' ' -f3`
- if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
- if [[ "$OSTYPE" = (darwin|freebsd)* ]]
- then
- local cores_num="$(sysctl -n hw.ncpu)"
- else
- local cores_num="$(nproc)"
- fi
- bundle install --jobs=$cores_num $@
- else
- bundle install $@
- fi
- fi
-}
-
-_bundler-installed() {
- which bundle > /dev/null 2>&1
-}
-
+# Check if in the root or a subdirectory of a bundled project
_within-bundled-project() {
local check_dir="$PWD"
- while [ "$check_dir" != "/" ]; do
- [ -f "$check_dir/Gemfile" -o -f "$check_dir/gems.rb" ] && return
- check_dir="$(dirname $check_dir)"
+ while [[ "$check_dir" != "/" ]]; do
+ if [[ -f "$check_dir/Gemfile" || -f "$check_dir/gems.rb" ]]; then
+ return 0
+ fi
+ check_dir="${check_dir:h}"
done
- false
-}
-
-_binstubbed() {
- [ -f "./bin/${1}" ]
+ return 1
}
_run-with-bundler() {
- if _bundler-installed && _within-bundled-project; then
- if _binstubbed $1; then
- ./bin/${^^@}
- else
- bundle exec $@
- fi
+ if (( ! $+commands[bundle] )) || ! _within-bundled-project; then
+ "$@"
+ return $?
+ fi
+
+ if [[ -f "./bin/${1}" ]]; then
+ ./bin/${^^@}
else
- $@
+ bundle exec "$@"
fi
}
-## Main program
for cmd in $bundled_commands; do
- eval "function unbundled_$cmd () { $cmd \$@ }"
- eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
- alias $cmd=bundled_$cmd
+ # Create wrappers for bundled and unbundled execution
+ eval "function unbundled_$cmd () { \"$cmd\" \"\$@\"; }"
+ eval "function bundled_$cmd () { _run-with-bundler \"$cmd\" \"\$@\"; }"
+ alias "$cmd"="bundled_$cmd"
- if which _$cmd > /dev/null 2>&1; then
- compdef _$cmd bundled_$cmd=$cmd
+ # Bind completion function to wrapped gem if available
+ if (( $+functions[_$cmd] )); then
+ compdef "_$cmd" "bundled_$cmd"="$cmd"
fi
done
+
+unset cmd bundled_commands
diff --git a/plugins/chucknorris/fortunes/chucknorris b/plugins/chucknorris/fortunes/chucknorris
index 1f4ca7a60..0eb6e2e99 100644
--- a/plugins/chucknorris/fortunes/chucknorris
+++ b/plugins/chucknorris/fortunes/chucknorris
@@ -20,7 +20,7 @@ Aliens fear that Chuck Norris might abduct them.
%
An angry glare from Chuck Norris is known to kill on the spot.
%
-Behind every successful man is Chuck Norris
+Behind every successful man is Chuck Norris.
%
Beware of dogs... Dogs, beware of Chuck Norris.
%
@@ -34,25 +34,25 @@ Chuck Norris - the new standard.
%
Chuck Norris CAN balance the light-switch between ON and OFF.
%
-Chuck Norris CAN believe it's not butter
+Chuck Norris CAN believe it's not butter.
%
Chuck Norris CAN spell with an I before E even after C.
%
-Chuck Norris Can Play the Theme from the Twilight Zone with His Beard
+Chuck Norris can play the theme from the Twilight Zone with his beard.
%
-Chuck Norris Can Power Solar Panels. At Night.
+Chuck Norris can power solar panels. At night.
%
-Chuck Norris Watches "the Nat.Geo. Specials" on Discovery Channel
+Chuck Norris watches "the Nat.Geo. Specials" on Discovery Channel.
%
-Chuck Norris bowled a 301 after constructing another pin out of his beard hair
+Chuck Norris bowled a 301 after constructing another pin out of his beard hair.
%
Chuck Norris burnt a fire proof vest, UNDERWATER!
%
Chuck Norris can French kiss his elbow.
%
-Chuck Norris can bake in a Freezer.
+Chuck Norris can bake in a freezer.
%
-Chuck Norris can defuse bomb even if he cut the wrong wire
+Chuck Norris can defuse a bomb by cutting the wrong wire.
%
Chuck Norris can dig a hole in air.
%
@@ -60,19 +60,19 @@ Chuck Norris can divide by zero.
%
Chuck Norris can do a regime change with a roundhouse kick.
%
-Chuck Norris can fit 10 gallons of water in a 5 gallon water bucket
+Chuck Norris can fit 10 gallons of water in a 5 gallon bucket.
%
-Chuck Norris can grill a popsicle
+Chuck Norris can grill a popsicle.
%
Chuck Norris can lead a horse to water AND make it drink.
%
-Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord"
+Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord".
%
-Chuck Norris can milk an alligator
+Chuck Norris can milk an alligator.
%
Chuck Norris can play the death waltz with his chin.
%
-Chuck Norris can roundhouse kick someone through a window without breaking the glass
+Chuck Norris can roundhouse kick someone through a window without breaking the glass.
%
Chuck Norris can roundhouse-kick round houses into squares.
%
@@ -80,36 +80,30 @@ Chuck Norris can rub two fires together and make a stick!
%
Chuck Norris can see in 3D with just one eye.
%
-Chuck Norris can shoot a person 28 times with an unloaded gun.
-%
Chuck Norris can slam a revolving door.
%
Chuck Norris can terminate a repeating decimal.
%
-Chuck Norris can turn toast back into bread
+Chuck Norris can turn toast back into bread.
%
Chuck Norris can win a game of Connect Four in only three moves.
%
-Chuck Norris can win in a top spinning tournament with a cube
-%
-Chuck Norris can't get fired by Donald Trump
+Chuck Norris can win in a top spinning tournament with a cube.
%
-Chuck Norris can't perform Hadoukens, he IS a Hadouken
+Chuck Norris can't perform Hadoukens, he IS a Hadouken.
%
Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly.
%
Chuck Norris counted to infinity - twice.
%
-Chuck Norris created Heavy Metal when he was upset
+Chuck Norris created Heavy Metal when he was upset.
%
Chuck Norris does not get frostbite. Chuck Norris bites frost.
%
-Chuck Norris does not have a cell phone because he hears everything
+Chuck Norris does not have a cell phone because he hears everything.
%
Chuck Norris does not sleep. He waits.
%
-Chuck Norris does not teabag the ladies. He potato-sacks them.
-%
Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint.
%
Chuck Norris doesn't call the wrong number, you just answer the wrong phone.
@@ -118,39 +112,31 @@ Chuck Norris doesn't cheat death, he beats it fair and square.
%
Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
%
-Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it
+Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it.
%
Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs.
%
-Chuck Norris doesn't fight. He gives motivational seminars to die on their own to avoid a roundhouse kick to the face.
-%
Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
%
Chuck Norris doesn't let it go.
%
-Chuck Norris doesn't like Mudkipz
+Chuck Norris doesn't like Mudkipz.
%
Chuck Norris doesn't look for fun. The fun looks for Chuck Norris.
%
-Chuck Norris doesn't need a bulletproof vest to be bulletproof
-%
Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands.
%
-Chuck Norris doesn't need air, he is air
+Chuck Norris doesn't need air, he is air.
%
-Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses
+Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses.
%
Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach.
%
Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
%
-Chuck Norris doesn't read. He just stares at the book until he gets the information he wants.
-%
Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down!
%
-Chuck Norris doesn't brew up tea. He sucks the bag.
-%
-Chuck Norris doesn't eat salad, he eats vegetarians
+Chuck Norris doesn't eat salad, he eats vegetarians.
%
Chuck Norris doesn't wash his clothes, he disembowels them.
%
@@ -162,26 +148,22 @@ Chuck Norris drives an ice cream truck covered in human skulls.
%
Chuck Norris drowned a man ON LAND.
%
-Chuck Norris fed the Hunger Games
+Chuck Norris fed the Hunger Games.
%
Chuck Norris found the hay in the needle stack.
%
-Chuck Norris found the last digit of pie
+Chuck Norris found the last digit of pi.
%
-Chuck Norris had a knife thrown at him............ the knife didn't impale him, he impaled the knife
+Chuck Norris had a knife thrown at him. The knife didn't impale him; he impaled the knife.
%
Chuck Norris has a battle cruiser AND a car.
%
-Chuck Norris has killed the Dead Sea
-%
-Chuck Norris has made a 148 break a snooker.
+Chuck Norris has killed the Dead Sea.
%
-Chuck Norris has two speeds. Walk, and Kill.
+Chuck Norris has made a 148 break at snooker.
%
Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
%
-Chuck Norris is Chuck Norris
-%
Chuck Norris is allowed two carry-ons.
%
Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
@@ -192,13 +174,11 @@ Chuck Norris is entitled to his own facts.
%
Chuck Norris is my Homeboy.
%
-Chuck Norris is overra...
-%
Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
%
Chuck Norris is so hard, he uses diamonds as stress balls.
%
-Chuck Norris is so scary he makes Sharks swim backwards away from him
+Chuck Norris is so scary, he makes sharks swim backwards away from him.
%
Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
%
@@ -212,101 +192,81 @@ Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
%
Chuck Norris is the only one who can tear a facebook page!
%
-Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth
+Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth.
%
-Chuck Norris is the reason tumbleweeds tumble
+Chuck Norris is the reason tumbleweeds tumble.
%
Chuck Norris is the reason why Waldo is hiding.
%
Chuck Norris is waiting for Mt. St. Helens to erupt again. He's hoping the lava is hot enough to soften his beard so he can shave for the first time.
%
-Chuck Norris isn't allowed at the zoo because when he's there the animals are terriefied to come out their cages
-%
-Chuck Norris isn't appropriate...appropriate isn't Chuck Norris
-%
-Chuck Norris killed Kemper
-%
-Chuck Norris likes everyone on the earth, cause everyone he didn't like... Is dead...
+Chuck Norris isn't allowed at the zoo, because when he's there the animals are too terrified to come out of their cages.
%
Chuck Norris made a statue bleed.
%
-Chuck Norris made the big bang just by clicking his fingers
+Chuck Norris made the big bang just by clicking his fingers.
%
Chuck Norris never trains, because he's Chuck Norris.
%
-Chuck Norris once asked a man to turn down his music, he refused, that man's baby was born deaf.
-%
Chuck Norris once cried just to see what it was like. The end result was the creation of life.
%
Chuck Norris once cut a knife with a stick of butter.
%
-Chuck Norris once got a 200 yard punt return
+Chuck Norris once got a 200 yard punt return.
%
-Chuck Norris once had a pet monkey........his name was KING KONG
+Chuck Norris once had a pet monkey named KING KONG.
%
-Chuck Norris once had a street named after him. But the name removed at once, because nobody crosses Chuck Norris, and lives
+Chuck Norris once had a street named after him. The name removed at once, because nobody crosses Chuck Norris, and lives.
%
Chuck Norris once had a weak moment, just to know what it felt like.
%
-Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade
+Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade.
%
Chuck Norris once proved p^~p by induction on his beard hairs.
%
-Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill
+Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill.
%
Chuck Norris once round-house kicked a salesman. Over the phone.
%
-Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean.
-%
-Chuck Norris once rounhouse kicked a football ...... it is now considered as a planet
-%
-Chuck Norris once taught a class of martial arts.Unfortunately Chuck had forgiven to take elephant tranquilizers and killed every one just by saluting
+Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet.
%
Chuck Norris once thought he was wrong. He was, however, mistaken.
%
-Chuck Norris once tried to teach a fat, stupid kid Martial Arts. Unsuccessfully. The kid grew up to be Steven Seagal.
-%
Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons.
%
-Chuck Norris once won the tour de france riding a " big wheel"
+Chuck Norris once won the Tour de France riding a "big wheel".
%
Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch."
%
Chuck Norris owns all number 1 pencils.
%
-Chuck Norris pees Adamantium
+Chuck Norris pees Adamantium.
%
-Chuck Norris play's Texas hold em with Zeus, every second Wednesday of the month
+Chuck Norris plays Texas Hold'Em with Zeus, every second Wednesday of the month.
%
Chuck Norris played "Got your Nose" with Voldemort and won.
%
-Chuck Norris played the game of thrones and won
+Chuck Norris played the game of thrones and won.
%
-Chuck Norris protects his body guards.
+Chuck Norris protects his bodyguards.
%
Chuck Norris rolled a 20 on a 6 sided die.
%
Chuck Norris roundhouse kicks people in the face first and asks questions later.
%
-Chuck Norris sent a BBM to an iphone.
-%
-Chuck Norris shops at Sam's Club, but leaves without having his receipt checked
+Chuck Norris sent a BBM to an iPhone.
%
-Chuck Norris shot a man with a knife
+Chuck Norris shops at Sam's Club, but leaves without having his receipt checked.
%
-Chuck Norris sleeps in Seattle.
-%
-Chuck Norris splattered tiger blood and Adonis' dna on Charlie Sheen with 1 roundhouse kick!
+Chuck Norris splattered tiger blood and Adonis' DNA on Charlie Sheen with 1 roundhouse kick!
%
Chuck Norris started Chuck Norris.
%
-Chuck Norris starts his day with 6 live chickens two cows, three pigs and a boiling hot cup of pure fury
-%
-Chuck Norris thretened to kill Michael Jackson, MJ got so scared to turned white.
+Chuck Norris starts his day with 6 live chickens, two cows, three pigs, and a boiling hot cup of pure fury.
%
Chuck Norris told me to put this here.
%
-Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, use photoshop, bring coffee.
+Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, and make coffee.
%
Chuck Norris uses pepper spray to spice up his steaks.
%
@@ -322,21 +282,21 @@ Chuck Norris was the reason why the Great Wall of China was constructed. It fail
%
Chuck Norris was what Willis was talking about.
%
-Chuck Norris wasn't born on his birthday
+Chuck Norris wasn't born on his birthday.
%
-Chuck Norris watched the first steps on the moon... From his summer home on Mars
+Chuck Norris watched the first steps on the moon... from his summer home on Mars.
%
-Chuck Norris went up the creek without a paddle... or a canoe
+Chuck Norris went up the creek without a paddle... or a canoe.
%
Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
%
Chuck Norris wins NASCAR races with all right turns.
%
-Chuck Norris won a stepdance contest by standing on his hands
+Chuck Norris won a stepdance contest by standing on his hands.
%
-Chuck Norris yells at Drill Sergeants
+Chuck Norris yells at drill Sergeants.
%
-Chuck Norris' dog pick up after him.
+Chuck Norris' dog picks up after him.
%
Chuck Norris' films are factual documentaries.
%
@@ -346,55 +306,47 @@ Chuck Norris' glass is never half full or half empty. It stays full even after h
%
Chuck Norris' hand is the only hand that can beat a Royal Flush.
%
-Chuck Norris' personal airplane is called Air Force Chuck
+Chuck Norris' personal airplane is called Air Force Chuck.
%
Chuck Norris. Enough said.
%
-Chuck Norris: even Naruto can't believe it
+Chuck Norris: even Naruto can't believe it.
%
-Chunk Norris can make sour milk turn fresh
+Chunk Norris can make sour milk turn fresh.
%
-Contrary to popular beleif, Rome WAS built in a day, by Chuck Norris.
+Contrary to popular belief, Rome WAS built in a day, by Chuck Norris.
%
Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on Earth.
%
-Cops don't need a badges in their wallets but only a picture of Chuck Norris.
+Cops don't need badges in their wallets, but only a picture of Chuck Norris.
%
Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
%
-Dead bodies were found of people that are still alive. These people will cross Chuck Norris in the future and will be round-house kicked back in time.
-%
-Did you here about the boy who cried Chuck Norris?
-%
-Do you know why Chuck Norris didn't star in The Expandebles? Because all the others guys would have surrended at the beginning.
+Did you hear about the boy who cried Chuck Norris?
%
Dog the Bounty Hunter can't track Chuck Norris down.
%
-Don't get Chuck Norris angry, last time somebody did that Chuck Norris made the Grand Canyon.
-%
-During the Civil War Chuck Norris was a slave, his master would often beg him for mercy
+Don't get Chuck Norris angry. Last time somebody did that, Chuck Norris made the Grand Canyon.
%
Earth's rotation is purely governed by the direction that Chuck Norris is walking.
%
-Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming
+Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming.
%
-Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
+Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
%
-Every phobia known to man has a phobia of Chuck Norris
+Every phobia known to man has a phobia of Chuck Norris.
%
Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling.
%
-Everyone is so scared of Chuck Norris that they kiss his arse by writing these facts, too right they should
-%
Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
%
-Fear of spiders is aracnaphobia, fear of tight spaces is chlaustraphobia, fear of Chuck Norris is called Logic
+Fear of spiders is arachnaphobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
%
Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
%
-Ghosts can see Chuck Norris
+Ghosts can see Chuck Norris.
%
Guns don't kill people. Chuck Norris kills people.
%
@@ -404,55 +356,47 @@ If Chuck Norris were a calendar, every month would be named Chucktober, and ever
%
If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win.
%
-If Chuck was ever captured, he could win a game of Russian Roulette with six bullets in the revolver, he would shoot everyone else!
-%
-If God doesn't know, Chuck does
+If God doesn't know, Chuck does.
%
-If Goliath listened to Chuck Norris he would have won.
+If Goliath listened to Chuck Norris, he would have won.
%
If at first you don't succeed, you're not Chuck Norris.
%
If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face.
%
-If you put in the correct cheat code in Halo 2, you can have Master Cheif play without his helmet; revealing to be Chuck Norris.
+If you put in the correct cheat code in Halo 2, you can have Master Chief play without his helmet, revealing himself to be Chuck Norris.
%
If you see a man in the street who looks like Chuck Norris, but isn't, run: you don't want to be caught in the resulting roundhouse kick to his face.
%
If you spell Chuck Norris in Scrabble, you win. Forever.
%
-In 1945 The US army asked if they could clone Chuck Norris. instead he said he could sort out the Japanese.
+In 1945 The US army asked if they could clone Chuck Norris. Instead he said he could sort out the Japanese.
%
-In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris Sized. It is a cup made of a human skull.
+In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris sized. It is a cup made of a human skull.
%
In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him.
%
-In fine print on the last page of the Guinness Book of World Records it notes that all world records are held by Chuck Norris, and those listed in the book are simply the closest anyone else has ever gotten.
-%
In the back of the book of world records, it says "All records are held by Chuck Norris. The ones listed are in second place."
%
James Bond has a license to kill. He got it from Chuck Norris.
%
-Jedis are now taught to use the "Chuck"
+Jedis are now taught to use the "Chuck".
%
MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart.
%
Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris.
%
-May the Force be with Chuck Norris... for it's own good.
+May the Force be with Chuck Norris... for its own good.
%
Merlin was Chuck Norris' assistant.
%
-More of a question than a fact: in a fight between Chuck Norris and Gordan Freeman who would win?
-%
Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
%
-Note to everyone: Please do not give beans to Chuck Norris or do you want another atombomb on hiroshima?
-%
-Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
+Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
%
-On the keyboard there is no control button because Chuck Norris is always in control.
+Chuck Norris' keyboard has no control key. Chuck Norris is always in control.
%
-Once upon a time, Chuck Norris found himself in a town called Shit Creek.....He opened a Paddle Store.
+Once upon a time, Chuck Norris found himself in a town called Shit Creek. He opened a Paddle Store.
%
One glance from Chuck Norris and snow turns itself yellow.
%
@@ -472,11 +416,9 @@ Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
%
Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
%
-Simon doesn't say...Chuck Norris says.
+Simon doesn't say... Chuck Norris says.
%
-Since 1940, the year Chuck Norris was born, roundhouse-kick related deaths have increased 13,000 percent.?
-%
-Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boot walk THROUGH you.
+Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boots walk THROUGH you.
%
Some kids pee their name in snow. Chuck Norris pees his name in concrete.
%
@@ -486,9 +428,9 @@ Someone once videotaped Chuck Norris getting pissed off. It was called Walker: T
%
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face.
%
-Taking Karate Lessons = $100, Buying MMA DVD's= $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS
+Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
%
-That's not an eclipse....that's the sun hiding from Chuck Norris.
+That's not an eclipse. That's the sun hiding from Chuck Norris.
%
The Beatles are on iTunes because Chuck Norris bought a Mac.
%
@@ -498,29 +440,25 @@ The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norri
%
The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
%
-The Jone's are trying to keep up with Chuck Norris
+The Joneses are trying to keep up with Chuck Norris.
%
-The Matrix Trilogy would have ended on the first movie if Keanu Reeves said, “I know Chuck Norris.”
+The Matrix Trilogy would have ended on the first movie had Keanu Reeves said, “I know Chuck Norris.”
%
-The answer to life, the universe and everything isnt 42. It's Chuck Norris.
+The answer to life, the universe and everything isn't 42. It's Chuck Norris.
%
-The apple falls far from the tree, when a roundhouse kick is taken to the trunk.
+The apple falls far from the tree, when Chuck's roundhouse kick is taken to the trunk.
%
-The best part of waking up is not Folgers in your cup, it's knowing that Chuck Norris let you live.
+The best part of waking up is not Folgers in your cup. it's knowing that Chuck Norris let you live.
%
-The chief export of Chuck Norris is Pain.
+The chief export of Chuck Norris is pain.
%
The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship.
%
-The kids said when Chuck was eating Trix cereal ´´silly Chuck, Trix are for kids´´...what happened next?..............................Darfur happened.
-%
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
%
The letters in Chuck Norris cannot be unscrambled.
%
-The meaning of life is Chuck Norris
-%
-The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet...which is all of them.
+The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet... which is all of them.
%
The only reason that USA lost the 2011 world cup to Japan is because Chuck Norris wasn't there.
%
@@ -528,21 +466,19 @@ The only sure things are Death and Taxes, and when Chuck Norris goes to work for
%
The only way sharks will come near CN underwater is when CN is inside of a cage.
%
-The only word that rhymes with orange is Chuck Norris
-%
-The planes in 9/11 were not hijacked. Chuck Norris was just playing with his old radio controller.
+The only word that rhymes with orange is Chuck Norris.
%
The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender".
%
The quickest way to a man's heart is with Chuck Norris' fist.
%
-The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon.
+The reason why Batman only comes out at night is because he's afraid he might encounter Chuck Norris in the morning and afternoon.
%
-The red phone in the oval office...Rings directly to Chuck Norris Cell Phone
+The red phone in the oval office rings directly to Chuck Norris' cell phone.
%
The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage.
%
-The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death
+The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death.
%
The sun only rises every morning because Chuck Norris allows it to.
%
@@ -550,25 +486,17 @@ The truth hurts, doesn't it? Chuck Norris' truth kills.
%
There is no chin behind Chuck Norris' beard. There is only another fist.
%
-There is no chin behind Chuck Norris' beard. There is only another fist.
-%
-There is no limbo, only a world that doesn't know of Chuck Norris
-%
-There is no such thing as being hard its called the Chuck Norris factor.
+There is no limbo, only a world that doesn't know of Chuck Norris.
%
There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up.
%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-They say death by a 1000 lashes was the most painful way to die, that was before they got roundhouse kicked in the face by Chuck Norris
+There is no theory of evolution, just a list of creatures Chuck Norris has allowed to live.
%
This one time at band camp... BAM! Chuck Norris.
%
Those who ignore history, are doomed by Chuck Norris.
%
-Trick me once, shame on you, trick Chuck Norris.....rest in peace.
+Trick me once, shame on you, trick Chuck Norris.. rest in peace.
%
Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast.
%
@@ -580,7 +508,7 @@ Whatever Chuck Norris wants, it will instantly appear.
%
When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris.
%
-When Chuck Norris creates a login, it tells him "password not strong enough", he types in his name and it tells him "password too strong."
+When Chuck Norris creates a login, it tells him "password not strong enough." He types in his name and it tells him "password too strong."
%
When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
%
@@ -590,7 +518,7 @@ When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just giv
%
When Chuck Norris goes to rodeos, bulls ride him.
%
-When Chuck Norris goes to the library, he looks for the guinness book of records in the comedy section.
+When Chuck Norris goes to the library, he looks for the Guinness book of records in the comedy section.
%
When Chuck Norris inhales helium, his voice doesn't change.
%
@@ -600,36 +528,32 @@ When Chuck Norris played the card game War with a friend, France surrendered.
%
When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter.
%
-When Chuck Norris roundhouse-kicks you HE decides when you will feel the impact .
+When Chuck Norris roundhouse-kicks you, he decides when you will feel the impact.
%
When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever.
%
-When Chuck Norris tosses a coin, it lands on both head and tail.
+When Chuck Norris tosses a coin, it lands on both heads and tails.
%
-When God said "Let there be light!", Chuck Norris said "Only for half the day
+When God said "Let there be light!", Chuck Norris said "Only for half the day."
%
-When President Roosevelt dropped the atomic bomb on Hiroshima, he did so only because it was more human then sending Chuck Norris.
-%
-When Presidents speak, their nation listens. When Chuck Norris blinks, the whole World listens.
+When Presidents speak, their nation listens. When Chuck Norris blinks, the whole world listens.
%
When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part.
%
When chuck Norris was in school, he made his PE teacher run laps.
%
-When does Chuck Norris run out of shotgun bullets?.....whenever he wants to.
+When does Chuck Norris run out of shotgun bullets? whenever he wants to.
%
When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000.
%
When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
%
-When things go bump in the night.... it's Chuck Norris
+When things go bump in the night, it's Chuck Norris
%
-While visiting the hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
+While visiting the Hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
%
Why didn't the chicken cross the road? Because Chuck Norris got to it first.
%
-World War II began because Chuck Norris took a nap. When he woke up, Hitler found out and killed himself out of fear Chuck Norris would kill him.
-%
You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "Godzilla". Oh, and his pet turtle starred in "Gamera" as well.
%
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
index 023b1a51e..a9d4f1a3d 100644
--- a/plugins/common-aliases/common-aliases.plugin.zsh
+++ b/plugins/common-aliases/common-aliases.plugin.zsh
@@ -55,15 +55,15 @@ if is-at-least 4.2.0; then
# open browser on urls
if [[ -n "$BROWSER" ]]; then
_browser_fts=(htm html de org net com at cx nl se dk)
- for ft in $_browser_fts; do alias -s $ft=$BROWSER; done
+ for ft in $_browser_fts; do alias -s $ft='$BROWSER'; done
fi
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
- for ft in $_editor_fts; do alias -s $ft=$EDITOR; done
+ for ft in $_editor_fts; do alias -s $ft='$EDITOR'; done
if [[ -n "$XIVIEWER" ]]; then
_image_fts=(jpg jpeg png gif mng tiff tif xpm)
- for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done
+ for ft in $_image_fts; do alias -s $ft='$XIVIEWER'; done
fi
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh
index 330360cdd..75b03ffe7 100644
--- a/plugins/composer/composer.plugin.zsh
+++ b/plugins/composer/composer.plugin.zsh
@@ -51,6 +51,8 @@ alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH, using Composer if available.
if (( $+commands[composer] )); then
+ autoload -Uz _store_cache _retrieve_cache
+
_retrieve_cache composer
if [[ -z $__composer_bin_dir ]]; then
diff --git a/plugins/docker/README.md b/plugins/docker/README.md
index 241a6a448..fab7aa8f1 100644
--- a/plugins/docker/README.md
+++ b/plugins/docker/README.md
@@ -10,3 +10,25 @@ plugins=(... docker)
A copy of the completion script from the docker/cli git repo:
https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker
+
+## Settings
+
+By default, the completion doesn't allow option-stacking, meaning if you try to
+complete `docker run -it <TAB>` it won't work, because you're _stacking_ the
+`-i` and `-t` options.
+
+[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding
+the lines below to your zshrc file**, but be aware of the side effects:
+
+> This enables Zsh to understand commands like `docker run -it
+> ubuntu`. However, by enabling this, this also makes Zsh complete
+> `docker run -u<tab>` with `docker run -uapprox` which is not valid. The
+> users have to put the space or the equal sign themselves before trying
+> to complete.
+>
+> Therefore, this behavior is disabled by default. To enable it:
+>
+> ```
+> zstyle ':completion:*:*:docker:*' option-stacking yes
+> zstyle ':completion:*:*:docker-*:*' option-stacking yes
+> ```
diff --git a/plugins/fzf/README.md b/plugins/fzf/README.md
index b3a434347..d9617563a 100644
--- a/plugins/fzf/README.md
+++ b/plugins/fzf/README.md
@@ -2,18 +2,32 @@
This plugin enables [junegunn's fzf](https://github.com/junegunn/fzf) fuzzy auto-completion and key bindings
+To use it, add `fzf` to the plugins array in your zshrc file:
+```zsh
+plugins=(... fzf)
+```
+
+## Settings
+
+Add these before the `plugins=()` line in your zshrc file:
+
```zsh
# Set fzf installation directory path
-export FZF_BASE=/path/to/fzf/install/dir
+# export FZF_BASE=/path/to/fzf/install/dir
+
+# Uncomment to set the FZF_DEFAULT_COMMAND
+# export FZF_DEFAULT_COMMAND='<your fzf default commmand>'
# Uncomment the following line to disable fuzzy completion
-# export DISABLE_FZF_AUTO_COMPLETION="true"
+# DISABLE_FZF_AUTO_COMPLETION="true"
# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C)
-# export DISABLE_FZF_KEY_BINDINGS="true"
-
-plugins=(
- ...
- fzf
-)
+# DISABLE_FZF_KEY_BINDINGS="true"
```
+
+| Setting | Example value | Description |
+|-----------------------------|----------------------------|-------------------------------------------------------------|
+| FZF_BASE | `/path/to/fzf/install/dir` | Set fzf installation directory path (**export**) |
+| FZF_DEFAULT_COMMAND | `fd --type f` | Set default command to use when input is tty (**export**) |
+| DISABLE_FZF_AUTO_COMPLETION | `true` | Set whether to load fzf auto-completion |
+| DISABLE_FZF_KEY_BINDINGS | `true` | Set whether to disable key bindings (CTRL-T, CTRL-R, ALT-C) |
diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh
index 53bdcbc97..0b831b7f7 100644
--- a/plugins/fzf/fzf.plugin.zsh
+++ b/plugins/fzf/fzf.plugin.zsh
@@ -98,3 +98,13 @@ function indicate_error() {
setup_using_debian_package || setup_using_base_dir || indicate_error
unset -f setup_using_debian_package setup_using_base_dir indicate_error
+
+if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
+ if (( $+commands[rg] )); then
+ export FZF_DEFAULT_COMMAND='rg --files --hidden'
+ elif (( $+commands[fd] )); then
+ export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
+ elif (( $+commands[ag] )); then
+ export FZF_DEFAULT_COMMAND='ag -l --hidden -g ""'
+ fi
+fi
diff --git a/plugins/git-lfs/README.md b/plugins/git-lfs/README.md
new file mode 100644
index 000000000..1222b2767
--- /dev/null
+++ b/plugins/git-lfs/README.md
@@ -0,0 +1,24 @@
+# git lfs plugin
+
+The git lfs plugin provides [aliases](#aliases) and [functions](#functions) for [git-lfs](https://github.com/git-lfs/git-lfs).
+
+To use it, add `git-lfs` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... git-lfs)
+```
+
+## Aliases
+
+| Alias | Command |
+| :------- | :---------------------------------- |
+| `glfsi` | `git lfs install` |
+| `glfst` | `git lfs track` |
+| `glfsls` | `git lfs ls-files` |
+| `glfsmi` | `git lfs migrate import --include=` |
+
+## Functions
+
+| Function | Command |
+| :------- | :---------------------------------------------- |
+| `gplfs` | `git lfs push origin "$(current_branch)" --all` |
diff --git a/plugins/git-lfs/git-lfs.plugin.zsh b/plugins/git-lfs/git-lfs.plugin.zsh
new file mode 100644
index 000000000..e7bb67603
--- /dev/null
+++ b/plugins/git-lfs/git-lfs.plugin.zsh
@@ -0,0 +1,17 @@
+#
+# Aliases
+#
+
+alias glfsi='git lfs install'
+alias glfst='git lfs track'
+alias glfsls='git lfs ls-files'
+alias glfsmi='git lfs migrate import --include='
+
+#
+# Functions
+#
+
+function gplfs() {
+ local b="$(git_current_branch)"
+ git lfs push origin "$b" --all
+}
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 5a9ccff5c..ccb9d8461 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -1,3 +1,7 @@
+# Git version checking
+autoload -Uz is-at-least
+git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
+
#
# Functions
#
@@ -104,7 +108,10 @@ function gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gf='git fetch'
-alias gfa='git fetch --all --prune'
+# --jobs=<n> was added in git 2.8
+is-at-least 2.8 "$git_version" \
+ && alias gfa='git fetch --all --prune --jobs=10' \
+ || alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'
alias gfg='git ls-files | grep'
@@ -240,8 +247,7 @@ alias gss='git status -s'
alias gst='git status'
# use the default stash push on git 2.13 and newer
-autoload -Uz is-at-least
-is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \
+is-at-least 2.13 "$git_version" \
&& alias gsta='git stash push' \
|| alias gsta='git stash save'
@@ -291,3 +297,5 @@ function grename() {
git push --set-upstream origin "$2"
fi
}
+
+unset git_version
diff --git a/plugins/ipfs/LICENSE b/plugins/ipfs/LICENSE
new file mode 100644
index 000000000..cf84491bb
--- /dev/null
+++ b/plugins/ipfs/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Angel Ramboi
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/plugins/ipfs/README.md b/plugins/ipfs/README.md
new file mode 100644
index 000000000..0808a26c1
--- /dev/null
+++ b/plugins/ipfs/README.md
@@ -0,0 +1,17 @@
+# zsh-ipfs
+
+zsh completion plugin for [The InterPlanetary File System (IPFS)][1]
+
+Please submit issues and pull requests to the [main zsh-ipfs repo][2].
+
+### About
+
+[IPFS (InterPlanetary File System)][1] is a peer-to-peer hypermedia protocol
+designed to make the web faster, safer, and more open.
+
+### License
+
+See: https://github.com/hellounicorn/zsh-ipfs/blob/master/LICENSE
+
+[1]: http://ipfs.io/
+[2]: https://github.com/hellounicorn/zsh-ipfs
diff --git a/plugins/ipfs/_ipfs b/plugins/ipfs/_ipfs
new file mode 100644
index 000000000..9ee8bd79c
--- /dev/null
+++ b/plugins/ipfs/_ipfs
@@ -0,0 +1,717 @@
+#compdef ipfs
+#autoload
+
+local -a _1st_arguments
+_1st_arguments=(
+ 'add:Add a file or directory to ipfs.'
+ 'bitswap:Interact with the bitswap agent.'
+ 'block:Interact with raw IPFS blocks.'
+ 'bootstrap:Show or edit the list of bootstrap peers.'
+ 'cat:Show IPFS object data.'
+ 'cid:Convert and discover properties of CIDs'
+ 'commands:List all available commands.'
+ 'config:Get and set ipfs config values.'
+ 'daemon:Run a network-connected IPFS node.'
+ 'dag:Interact with ipld dag objects. (experimental)'
+ 'dht:Issue commands directly through the DHT.'
+ 'diag:Generate diagnostic reports.'
+ 'dns:Resolve DNS links.'
+ 'files:Interact with unixfs files.'
+ 'filestore:Interact with filestore objects. (experimental)'
+ 'get:Download IPFS objects.'
+ 'id:Show ipfs node id info.'
+ 'init:Initializes ipfs config file.'
+ 'key:Create and list IPNS name keypairs.'
+ 'log:Interact with the daemon log output.'
+ 'ls:List directory contents for Unix filesystem objects.'
+ 'mount:Mounts IPFS to the filesystem (read-only).'
+ 'name:Publish and resolve IPNS names.'
+ 'object:Interact with IPFS objects.'
+ 'p2p:Libp2p stream mounting.'
+ 'pin:Pin (and unpin) objects to local storage.'
+ 'ping:Send echo request packets to IPFS hosts.'
+ 'refs:List links (references) from an object.'
+ 'repo:Manipulate the IPFS repo.'
+ 'resolve:Resolve the value of names to IPFS.'
+ 'stats:Query IPFS statistics.'
+ 'swarm:Interact with the swarm.'
+ 'tar:Utility functions for tar files in ipfs.'
+ 'update:Download and apply go-ipfs updates'
+ 'version:Show ipfs version information.'
+)
+
+_ipfs_subcommand(){
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+ _arguments -C ':command:->command' '*::options:->options'
+ case $state in
+ (command)
+ _describe -t commands "ipfs subcommand" $1
+ return
+ ;;
+ (options)
+ case $line[1] in
+ (wantlist)
+ case $MAIN_SUBCOMMAND in
+ (bitswap)
+ _arguments '(-p --peer)'{-p,--peer}'[Specify which peer to show wantlist for. Default: self.]'
+ ;;
+ esac
+ ;;
+ (add)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Recursively pin the object linked to by the specified object(s). Default: true.]' \
+ '--progress[Show progress.]'
+ ;;
+ (bootstrap)
+ local -a _bootstrap_rm_arguments
+ _bootstrap_rm_arguments=(
+ 'default:Add default peers to the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_rm_arguments
+ ;;
+ esac
+ ;;
+ (rm)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments '(-r --recursive)'{-r,--recursive}'[Recursively unpin the object linked to by the specified object(s). Default: true.]'
+ ;;
+ (bootstrap)
+ local -a _bootstrap_rm_arguments
+ _bootstrap_rm_arguments=(
+ 'all:Remove all peers from the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_rm_arguments
+ ;;
+ esac
+ ;;
+ (ls)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '(-t --type)'{-t,--type}'[The type of pinned keys to list. Can be "direct", "indirect", "recursive", or "all". Default: all.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write just hashes of objects.]'
+ ;;
+ (p2p)
+ _arguments '(-v --headers)'{-v,--headers}'[Print table headers (Protocol, Listen, Target).]'
+ ;;
+ esac
+ ;;
+ (update)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments '--unpin[Remove the old pin. Default: true.]'
+ ;;
+ esac
+ ;;
+ (verify)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '--verbose[Also write the hashes of non-broken pins.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write just hashes of broken pins.]'
+ ;;
+ esac
+ ;;
+ (get|query|findpeer)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ (object)
+ _arguments '--data-encoding[Encoding type of the data field, either "text" or "base64". Default: text.]'
+ ;;
+ esac
+ ;;
+ (put)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ (object)
+ _arguments \
+ '--inputenc[Encoding type of input data. One of: {"protobuf", "json"}. Default: json.]' \
+ '--datafieldenc[Encoding type of the data field, either "text" or "base64". Default: text.]' \
+ '--pin[Pin this object when adding.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output]'
+ ;;
+ esac
+ ;;
+ (findprovs)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '(-n --num-providers)'{-n,--num-providers}'[The number of providers to find. Default: 20.]'
+ ;;
+ esac
+ ;;
+ (provide)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '(-r --recursive)'{-r,--recursive}'[Recursively provide entire graph.]'
+ ;;
+ esac
+ ;;
+ (cmds|diff)
+ case $MAIN_SUBCOMMAND in
+ (diag|object)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ esac
+ ;;
+ (stat)
+ case $MAIN_SUBCOMMAND in
+ (object)
+ _arguments '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ (repo)
+ _arguments \
+ '--size-only[Only report RepoSize and StorageMax.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (publish)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ _arguments \
+ '--resolve[Check if the given path can be resolved before publishing. Default: true.]' \
+ '(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for. Default: 24h.]' \
+ '--allow-offline[When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing.]' \
+ '--ttl[Time duration this record should be cached for. Uses the same syntax as the lifetime option. (caution: experimental).]' \
+ '(-k --key)'{-k,--key}"[Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: self.]" \
+ '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]'
+ ;;
+ esac
+ ;;
+ (pubsub)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ local -a _name_pubsub_arguments
+ _name_pubsub_arguments=(
+ 'cancel:Cancel a name subscription'
+ 'state:Query the state of IPNS pubsub'
+ 'subs:Show current name subscriptions'
+ )
+ _ipfs_subcommand _name_pubsub_arguments
+ ;;
+ esac
+ ;;
+ (resolve)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not an IPNS name. Default: true.]' \
+ '(-n --nocache)'{-n,--nocache}'[Do not use cached entries.]' \
+ '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
+ '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]' \
+ '(-s --stream)'{-s,--stream}'[Stream entries as they are found.]'
+ ;;
+ esac
+ ;;
+ (patch)
+ case $MAIN_SUBCOMMAND in
+ (object)
+ local -a _object_patch_arguments
+ _object_patch_arguments=(
+ 'add-link:Add a link to a given object.'
+ 'append-data:Append data to the data segment of a dag node.'
+ 'rm-link:Remove a link from a given object.'
+ 'set-data:Set the data field of an IPFS object.'
+ )
+ _ipfs_subcommand _object_patch_arguments
+ ;;
+ esac
+ ;;
+ (gc)
+ case $MAIN_SUBCOMMAND in
+ (repo)
+ _arguments \
+ '--stream-errors[Stream errors.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output.]'
+ ;;
+ esac
+ ;;
+ (bitswap)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (bw)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '(-p --peer)'{-p,--peer}'[Specify a peer to print bandwidth for.]' \
+ '(-t --proto)'{-t,--proto}'[Specify a protocol to print bandwidth for.]' \
+ '--poll[Print bandwidth at an interval.]' \
+ '(-i --interval)'{-i,--interval}'[Time interval to wait between updating output, if 'poll' is true.]'
+ ;;
+ esac
+ ;;
+ (repo)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '--size-only[Only report RepoSize and StorageMax.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (bases)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments \
+ '--prefix[also include the single leter prefixes in addition to the code.]' \
+ '--numeric[also include numeric codes.]'
+ ;;
+ esac
+ ;;
+ (codecs|hashes)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments '--numeric[also include numeric codes.]'
+ ;;
+ esac
+ ;;
+ (format)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments \
+ '-f[Printf style format string. Default: %s.]' \
+ '-v[CID version to convert to.]' \
+ '-b[Multibase to display CID in.]'
+ ;;
+ esac
+ ;;
+ (close)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments \
+ '(-a --all)'{-a,--all}'[Close all listeners.]' \
+ '(-p --protocol)'{-p,--protocol}'[Match protocol name.]' \
+ '(-l --listen-address)'{-l,--listen-address}'[Match listen address.]' \
+ '(-t --target-address)'{-t,--target-address}'[Match target address.]'
+ ;;
+ esac
+ ;;
+ (forward)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments "--allow-custom-protocol[Don't require /x/ prefix.]"
+ ;;
+ esac
+ ;;
+ (listen)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments \
+ "--allow-custom-protocol[Don't require /x/ prefix.]" \
+ '(-r --report-peer-id)'{-r,--report-peer-id}'[Send remote base58 peerid to target when a new connection is established.]'
+ ;;
+ esac
+ ;;
+ (stream)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ local -a _p2p_stream_arguments
+ _p2p_stream_arguments=(
+ 'close:Close active p2p stream.'
+ 'ls:List active p2p streams.'
+ )
+ _ipfs_subcommand _p2p_stream_arguments
+ ;;
+ esac
+ ;;
+ (addrs)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ local -a _swarm_addrs_arguments
+ _swarm_addrs_arguments=(
+ 'listen:List interface listening addresses.'
+ 'local:List local addresses.'
+ )
+ _ipfs_subcommand _swarm_addrs_arguments
+ ;;
+ esac
+ ;;
+ (filters)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ local -a _swarm_filters_arguments
+ _swarm_filters_arguments=(
+ 'add:Add an address filter.'
+ 'rm:Remove an address filter.'
+ )
+ _ipfs_subcommand _swarm_filters_arguments
+ ;;
+ esac
+ ;;
+ (peers)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[display all extra information.]' \
+ '--streams[Also list information about open streams for each peer.]' \
+ '--latency[Also list information about latency to each peer.]' \
+ '--direction[Also list information about the direction of connection.]'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+}
+
+local expl
+
+_arguments \
+ '(-c --config)'{-c,--config}'[Path to the configuration file to use.]' \
+ '(-D --debug)'{-D,--debug}'[Operate in debug mode.]' \
+ '(--help)--help[Show the full command help text.]' \
+ '(--h)-h[Show a short version of the command help text.]' \
+ '(-L --local)'{-L,--local}'[Run the command locally, instead of using the daemon. DEPRECATED: use --offline.]' \
+ '(--offline)--offline[Run the command offline.]' \
+ '(--api)--api[Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001).]' \
+ '(--cid-base)--cid-base[Multibase encoding used for version 1 CIDs in output.]' \
+ '(--upgrade-cidv0-in-output)--upgrade-cidv0-in-output[Upgrade version 0 to version 1 CIDs in output.]' \
+ '(--enc --encoding)'{--enc,--encoding}'[The encoding type the output should be encoded with (json, xml, or text). Default: text.]' \
+ '(--stream-channels)--stream-channels[Stream channel output.]' \
+ '(--timeout)--timeout[Set a global timeout on the command.]' \
+ '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "ipfs subcommand" _1st_arguments
+ return
+fi
+
+MAIN_SUBCOMMAND="$words[1]"
+case $MAIN_SUBCOMMAND in
+ (add)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Add directory paths recursively.]' \
+ '(--dereference-args)--dereference-args[Symlinks supplied in arguments are dereferenced.]' \
+ '(--stdin-name)--stdin-name[Assign a name if the file source is stdin.]' \
+ '(-H --hidden)'{-H,--hidden}'[Include files that are hidden. Only takes effect on recursive add.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output.]' \
+ '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
+ '(--silent)--silent[Write no output.]' \
+ '(-p --progress)'{-p,--progress}'[Stream progress data.]' \
+ '(-t --trickle)'{-t,--trickle}'[Use trickle-dag format for dag generation.]' \
+ '(-n --only-hash)'{-n,--only-hash}'[Only chunk and hash - do not write to disk.]' \
+ '(-w --wrap-with-directory)'{-w,--wrap-with-directory}'[Wrap files with a directory object.]' \
+ '(-s --chunker)'{-s,--chunker}'[Chunking algorithm, size-(bytes) or rabin-(min)-(avg)-(max). Default: size-262144.]' \
+ '(--pin)--pin[Pin this object when adding. Default: true.]' \
+ '(--raw-leaves)--raw-leaves[Use raw blocks for leaf nodes. (experimental).]' \
+ '(--nocopy)--nocopy[Add the file using filestore. Implies raw-leaves. (experimental).]' \
+ '(--fscache)--fscache[Check the filestore for pre-existing blocks. (experimental).]' \
+ '(--cid-version)--cid-version[CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental).]' \
+ '(--hash)--hash[Hash function to use. Implies CIDv1 if not sha2-256. (experimental). Default: sha2-256.]' \
+ '(--inline)--inline[Inline small blocks into CIDs. (experimental).]' \
+ '(--inline-limit)--inline-limit[Maximum block size to inline. (experimental). Default: 32.]'
+ ;;
+ (bitswap)
+ local -a _bitswap_arguments
+ _bitswap_arguments=(
+ 'ledger:Show the current ledger for a peer.'
+ 'reprovide:Trigger reprovider.'
+ 'stat:Show some diagnostic information on the bitswap agent.'
+ 'wantlist:Show blocks currently on the wantlist.'
+ )
+ _ipfs_subcommand _bitswap_arguments
+ ;;
+ (block)
+ local -a _block_arguments
+ _block_arguments=(
+ 'get:Get a raw IPFS block.'
+ 'put:Store input as an IPFS block.'
+ 'rm:Remove IPFS block(s).'
+ 'stat:Print information of a raw IPFS block.'
+ )
+ _ipfs_subcommand _block_arguments
+ ;;
+ (bootstrap)
+ local -a _bootstrap_arguments
+ _bootstrap_arguments=(
+ 'add:Add peers to the bootstrap list.'
+ 'list:Show peers in the bootstrap list.'
+ 'rm:Remove peers from the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_arguments
+ ;;
+ (cat)
+ _arguments \
+ '(-o --offset)'{-o,--offset}'[Byte offset to begin reading from.]' \
+ '(-l --length)'{-l,--length}'[Maximum number of bytes to read.]'
+ ;;
+ (cid)
+ local -a _cid_arguments
+ _cid_arguments=(
+ 'base32:Convert CIDs to Base32 CID version 1.'
+ 'bases:List available multibase encodings.'
+ 'codecs:List available CID codecs.'
+ 'format:Format and convert a CID in various useful ways.'
+ 'hashes:List available multihashes.'
+ )
+ _ipfs_subcommand _cid_arguments
+ ;;
+ (commands)
+ _arguments '(-f --flags)'{-f,--flags}'[Show command flags.]'
+ ;;
+ (config)
+ _arguments \
+ '--bool[Set a boolean value.]' \
+ '--json[Parse stringified JSON.]'
+ local -a _config_arguments
+ _config_arguments=(
+ 'edit:Open the config file for editing in $EDITOR.'
+ 'profile:Apply profiles to config.'
+ 'replace:Replace the config with <file>.'
+ 'show:Output config file contents.'
+ )
+ _ipfs_subcommand _config_arguments
+ ;;
+ (daemon)
+ _arguments \
+ '--init[Initialize ipfs with default settings if not already initialized.]' \
+ '--init-profile[Configuration profiles to apply for --init. See ipfs init --help for more.]' \
+ '--routing[Overrides the routing option. Default: default.]' \
+ '--mount[Mounts IPFS to the filesystem.]' \
+ '--writable[Enable writing objects (with POST, PUT and DELETE).]' \
+ '--mount-ipfs[Path to the mountpoint for IPFS (if using --mount). Defaults to config setting.]' \
+ '--mount-ipns[Path to the mountpoint for IPNS (if using --mount). Defaults to config setting.]' \
+ '--unrestricted-api[Allow API access to unlisted hashes.]' \
+ '--disable-transport-encryption[Disable transport encryption (for debugging protocols).]' \
+ '--enable-gc[Enable automatic periodic repo garbage collection.]' \
+ '--manage-fdlimit[Check and raise file descriptor limits if needed. Default: true.]' \
+ '--migrate[If true, assume yes at the migrate prompt. If false, assume no.]' \
+ '--enable-pubsub-experiment[Instantiate the ipfs daemon with the experimental pubsub feature enabled.]' \
+ '--enable-namesys-pubsub[Enable IPNS record distribution through pubsub; enables pubsub.]' \
+ '--enable-mplex-experiment[Add the experimental 'go-multiplex' stream muxer to libp2p on construction. Default: true.]'
+ ;;
+ (dag)
+ local -a _dag_arguments
+ _dag_arguments=(
+ 'get:Get a dag node from ipfs.'
+ 'put:Add a dag node to ipfs.'
+ 'resolve:Resolve ipld block.'
+ )
+ _ipfs_subcommand _dag_arguments
+ ;;
+ (dht)
+ local -a _dht_arguments
+ _dht_arguments=(
+ 'findpeer:Find the multiaddresses associated with a Peer ID.'
+ 'findprovs:Find peers that can provide a specific value, given a key.'
+ 'get:Given a key, query the routing system for its best value.'
+ 'provide:Announce to the network that you are providing given values.'
+ 'put:Write a key/value pair to the routing system.'
+ 'query:Find the closest Peer IDs to a given Peer ID by querying the DHT.'
+ )
+ _ipfs_subcommand _dht_arguments
+ ;;
+ (diag)
+ local -a _diag_arguments
+ _diag_arguments=(
+ 'cmds:List commands run on this IPFS node.'
+ 'sys:Print system diagnostic information.'
+ )
+ _ipfs_subcommand _diag_arguments
+ ;;
+ (dns)
+ _arguments '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not a DNS link. Default: true.]'
+ ;;
+ (files)
+ _arguments '(-f --flush)'{-f,--flush}'[Flush target and ancestors after write. Default: true.]'
+ local -a _files_arguments
+ _files_arguments=(
+ 'chcid:Change the cid version or hash function of the root node of a given path.'
+ 'cp:Copy files into mfs.'
+ "flush:Flush a given path's data to disk."
+ 'ls:List directories in the local mutable namespace.'
+ 'mkdir:Make directories.'
+ 'mv:Move files.'
+ 'read:Read a file in a given mfs.'
+ 'rm:Remove a file.'
+ 'stat:Display file status.'
+ 'write:Write to a mutable file in a given filesystem.'
+ )
+ _ipfs_subcommand _files_arguments
+ ;;
+ (filestore)
+ local -a _filestore_arguments
+ _filestore_arguments=(
+ 'dups:List blocks that are both in the filestore and standard block storage.'
+ 'ls:List objects in filestore.'
+ 'verify:Verify objects in filestore.'
+ )
+ _ipfs_subcommand _filestore_arguments
+ ;;
+ (get)
+ _arguments \
+ '(-o --output)'{-o,--output}'[The path where the output should be stored.]'\
+ '(-a --archive)'{-a,--archive}'[Output a TAR archive.]' \
+ '(-C --compress)'{-C,--compress}'[Compress the output with GZIP compression.]' \
+ '(-l --compression-level)'{-l,--compression-level}'[The level of compression (1-9).]'
+ ;;
+ (id)
+ _arguments '(-f --format)'{-f,--format}'[Optional output format.]'
+ ;;
+ (init)
+ _arguments \
+ '(-b --bits)'{-b,--bits}'[Number of bits to use in the generated RSA private key. Default: 2048.]' \
+ '(-e --empty-repo)'{-e,--empty-repo}"[Don't add and pin help files to the local storage.]" \
+ '(-p --profile)'{-p,--profile}"[Apply profile settings to config. Multiple profiles can be separated by ','.]"
+ ;;
+ (key)
+ local -a _key_arguments
+ _key_arguments=(
+ 'gen:Create a new keypair'
+ 'list:List all local keypairs'
+ 'rename:Rename a keypair'
+ 'rm:Remove a keypair'
+ )
+ _ipfs_subcommand _key_arguments
+ ;;
+ (log)
+ local -a _log_arguments
+ _log_arguments=(
+ 'level:Change the logging level.'
+ 'ls:List the logging subsystems.'
+ 'tail:Read the event log.'
+ )
+ _ipfs_subcommand _log_arguments
+ ;;
+ (ls)
+ _arguments \
+ '(-v --headers)'{-v,--headers}'[Print table headers (Hash, Size, Name).]' \
+ '--resolve-type[Resolve linked objects to find out their types. Default: true.]' \
+ '--size[Resolve linked objects to find out their file size. Default: true.]' \
+ '(-s --stream)'{-s,--stream}'[Enable exprimental streaming of directory entries as they are traversed.]' \
+ ;;
+ (mount)
+ _arguments \
+ '(-f --ipfs-path)'{-f,--ipfs-path}'[The path where IPFS should be mounted.]' \
+ '(-n --ipns-path)'{-n,--ipns-path}'[The path where IPNS should be mounted.]'
+ ;;
+ (name)
+ local -a _name_arguments
+ _name_arguments=(
+ 'publish:Publish IPNS names.'
+ 'pubsub:IPNS pubsub management.'
+ 'resolve:Resolve IPNS names.'
+ )
+ _ipfs_subcommand _name_arguments
+ ;;
+ (object)
+ local -a _object_arguments
+ _object_arguments=(
+ 'data:Output the raw bytes of an IPFS object.'
+ 'diff:Display the diff between two ipfs objects.'
+ 'get:Get and serialize the DAG node named by <key>.'
+ 'links:Output the links pointed to by the specified object.'
+ 'new:Create a new object from an ipfs template.'
+ 'patch:Create a new merkledag object based on an existing one.'
+ 'put:Store input as a DAG object, print its key.'
+ 'stat:Get stats for the DAG node named by <key>.'
+ )
+ _ipfs_subcommand _object_arguments
+ ;;
+ (p2p)
+ local -a _p2p_arguments
+ _p2p_arguments=(
+ 'close:Stop listening for new connections to forward.'
+ 'forward:Forward connections to libp2p service'
+ 'listen:Create libp2p service'
+ 'ls:List active p2p listeners.'
+ 'stream:P2P stream management.'
+ )
+ _ipfs_subcommand _p2p_arguments
+ ;;
+ (pin)
+ local -a _pin_arguments
+ _pin_arguments=(
+ 'add:Pin objects to local storage.'
+ 'ls:List objects pinned to local storage.'
+ 'rm:Remove pinned objects from local storage.'
+ 'update:Update a recursive pin'
+ 'verify:Verify that recursive pins are complete.'
+ )
+ _ipfs_subcommand _pin_arguments
+ ;;
+ (ping)
+ _arguments '(-n --count)'{-n,--count}'[Number of ping messages to send. Default: 10.]'
+ ;;
+ (refs)
+ _arguments \
+ '--format[Emit edges with given format. Available tokens: <src> <dst> <linkname>. Default: <dst>.]' \
+ '(-e --edges)'{-e,--edges}'[Emit edge format: `<from> -> <to>`.]' \
+ '(-u --unique)'{-u,--unique}'[Omit duplicate refs from output.]' \
+ '(-r --recursive)'{-r,--recursive}'[Recursively list links of child nodes.]' \
+ '--max-depth[Only for recursive refs, limits fetch and listing to the given depth. Default: -1.]'
+ local -a _refs_arguments
+ _refs_arguments='local:List all local references.'
+ _ipfs_subcommand _refs_arguments
+ ;;
+ (repo)
+ local -a _repo_arguments
+ _repo_arguments=(
+ 'fsck:Remove repo lockfiles.'
+ 'gc:Perform a garbage collection sweep on the repo.'
+ 'stat:Get stats for the currently used repo.'
+ 'verify:Verify all blocks in repo are not corrupted.'
+ 'version:Show the repo version.'
+ )
+ _ipfs_subcommand _repo_arguments
+ ;;
+ (resolve)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Resolve until the result is an IPFS name. Default: true.]' \
+ '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
+ '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]'
+ ;;
+ (stats)
+ local -a _stats_arguments
+ _stats_arguments=(
+ 'bitswap:Show some diagnostic information on the bitswap agent.'
+ 'bw:Print ipfs bandwidth information.'
+ 'repo:Get stats for the currently used repo.'
+ )
+ _ipfs_subcommand _stats_arguments
+ ;;
+ (swarm)
+ local -a _swarm_arguments
+ _swarm_arguments=(
+ 'addrs:List known addresses. Useful for debugging.'
+ 'connect:Open connection to a given address.'
+ 'disconnect:Close connection to a given address.'
+ 'filters:Manipulate address filters.'
+ 'peers:List peers with open connections.'
+ )
+ _ipfs_subcommand _swarm_arguments
+ ;;
+ (tar)
+ local -a _tar_arguments
+ _tar_arguments=(
+ 'add:Import a tar file into ipfs.'
+ 'cat:Export a tar file from IPFS.'
+ )
+ _ipfs_subcommand _tar_arguments
+ ;;
+ (version)
+ _arguments \
+ '(-n --number)'{-n,--number}'[Only show the version number.]' \
+ '--commit[Show the commit hash.]' \
+ '--repo[Show repo version.]' \
+ '--all[Show all version information.]'
+ ;;
+esac
diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md
index ee05a8af1..84f5f8d89 100644
--- a/plugins/kubectl/README.md
+++ b/plugins/kubectl/README.md
@@ -106,3 +106,11 @@ plugins=(... kubectl)
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
| ksss | `kubectl scale statefulset` | Scale a statefulset |
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
+
+## Wrappers
+
+This plugin provides 3 wrappers to colorize kubectl output in JSON and YAML using various tools (which must be installed):
+
+- `kj`: JSON, colorized with [`jq`](https://stedolan.github.io/jq/).
+- `kjx`: JSON, colorized with [`fx`](https://github.com/antonmedv/fx).
+- `ky`: YAML, colorized with [`yh`](https://github.com/andreazorzetto/yh).
diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
index 647d029c1..6292a0b2f 100644
--- a/plugins/kubectl/kubectl.plugin.zsh
+++ b/plugins/kubectl/kubectl.plugin.zsh
@@ -150,3 +150,19 @@ alias kepvc='kubectl edit pvc'
alias kdpvc='kubectl describe pvc'
alias kdelpvc='kubectl delete pvc'
+# Colored JSON output
+kj() {
+ kubectl "$@" -o json | jq
+}
+compdef kj=kubectl
+
+kjx() {
+ kubectl "$@" -o json | fx
+}
+compdef kjx=kubectl
+
+# Colored YAML output
+ky() {
+ kubectl "$@" -o yaml | yh
+}
+compdef ky=kubectl
diff --git a/plugins/lando/LICENSE b/plugins/lando/LICENSE
new file mode 100644
index 000000000..1d4983163
--- /dev/null
+++ b/plugins/lando/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Joshua Bedford
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/plugins/lando/README.md b/plugins/lando/README.md
new file mode 100644
index 000000000..928a42bca
--- /dev/null
+++ b/plugins/lando/README.md
@@ -0,0 +1,37 @@
+# Lando ZSH (lando-zsh)
+
+This plugin adds aliases for using various languages and frameworks with [Lando](https://docs.lando.dev/basics/) for Docker. It will only run within lando-driven project directories.
+
+To use it, add `lando` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... lando)
+```
+
+## ALIASES:
+
+| Alias | Description |
+|:----------:|:----------------:|
+| `artisan` | `lando artisan` |
+| `composer` | `lando composer` |
+| `drush` | `lando drush` |
+| `gulp` | `lando gulp` |
+| `npm` | `lando npm` |
+| `wp` | `lando wp` |
+| `yarn` | `lando yarn` |
+
+## How It Works:
+
+This plugin removes the requirement to type `lando` before a command. It utilizes the lando version of supported commands run within directories with the following criteria:
+- The `.lando.yml` file is found in the current directory or any parent directory within `$LANDO_ZSH_SITES_DIRECTORY`.
+- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself.
+
+## Settings:
+
+- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory.
+- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando.
+
+## Author:
+
+- Author: Joshua Bedford
+- URL: [https://github.com/joshuabedford/lando-zsh](https://github.com/joshuabedford/lando-zsh)
diff --git a/plugins/lando/lando.plugin.zsh b/plugins/lando/lando.plugin.zsh
new file mode 100644
index 000000000..aa74c9924
--- /dev/null
+++ b/plugins/lando/lando.plugin.zsh
@@ -0,0 +1,40 @@
+# Settings
+: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
+: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
+
+# Enable multiple commands with lando.
+function artisan \
+ composer \
+ drush \
+ gulp \
+ npm \
+ wp \
+ yarn {
+ if checkForLandoFile; then
+ lando "$0" "$@"
+ else
+ command "$0" "$@"
+ fi
+}
+
+# Check for the file in the current and parent directories.
+checkForLandoFile() {
+ # Only bother checking for lando within the Sites directory.
+ if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
+ # Not within $LANDO_ZSH_SITES_DIRECTORY
+ return 1
+ fi
+
+ local curr_dir="$PWD"
+ # Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY...
+ while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do
+ if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then
+ return 0
+ fi
+ curr_dir="${curr_dir:h}"
+ done
+
+ # Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
+ # or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
+ return 1
+} \ No newline at end of file
diff --git a/plugins/laravel5/laravel5.plugin.zsh b/plugins/laravel5/laravel5.plugin.zsh
index 487a0742b..70dc4ed02 100644
--- a/plugins/laravel5/laravel5.plugin.zsh
+++ b/plugins/laravel5/laravel5.plugin.zsh
@@ -1,20 +1,19 @@
+# Alias
+alias la5='php artisan'
+alias la5cache='php artisan cache:clear'
+alias la5routes='php artisan route:list'
+alias la5vendor='php artisan vendor:publish'
+
# Laravel5 basic command completion
_laravel5_get_command_list () {
- php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
+ php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
}
_laravel5 () {
- if [ -f artisan ]; then
- compadd `_laravel5_get_command_list`
+ if [[ -f artisan ]]; then
+ compadd $(_laravel5_get_command_list)
fi
}
compdef _laravel5 artisan
compdef _laravel5 la5
-
-#Alias
-alias la5='php artisan'
-
-alias la5cache='php artisan cache:clear'
-alias la5routes='php artisan route:list'
-alias la5vendor='php artisan vendor:publish'
diff --git a/plugins/minikube/minikube.plugin.zsh b/plugins/minikube/minikube.plugin.zsh
index f7b365c7f..e87abceaf 100644
--- a/plugins/minikube/minikube.plugin.zsh
+++ b/plugins/minikube/minikube.plugin.zsh
@@ -1,13 +1,13 @@
# Autocompletion for Minikube.
#
if (( $+commands[minikube] )); then
- __MINICUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minicube_completion"
+ __MINIKUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minikube_completion"
- if [[ ! -f $__MINICUBE_COMPLETION_FILE ]]; then
- minikube completion zsh >! $__MINICUBE_COMPLETION_FILE
+ if [[ ! -f $__MINIKUBE_COMPLETION_FILE ]]; then
+ minikube completion zsh >! $__MINIKUBE_COMPLETION_FILE
fi
- [[ -f $__MINICUBE_COMPLETION_FILE ]] && source $__MINICUBE_COMPLETION_FILE
+ [[ -f $__MINIKUBE_COMPLETION_FILE ]] && source $__MINIKUBE_COMPLETION_FILE
- unset __MINICUBE_COMPLETION_FILE
+ unset __MINIKUBE_COMPLETION_FILE
fi
diff --git a/plugins/mvn/README.md b/plugins/mvn/README.md
index cbe7f30fa..815dfd57c 100644
--- a/plugins/mvn/README.md
+++ b/plugins/mvn/README.md
@@ -19,6 +19,7 @@ if it's found, or the mvn command otherwise.
| `mvn!` | `mvn -f <root>/pom.xml` |
| `mvnag` | `mvn archetype:generate` |
| `mvnboot` | `mvn spring-boot:run` |
+| `mvnqdev` | `mvn quarkus:dev` |
| `mvnc` | `mvn clean` |
| `mvncd` | `mvn clean deploy` |
| `mvnce` | `mvn clean eclipse:clean eclipse:eclipse` |
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index 7cb94b42f..27d63a6f9 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -62,6 +62,7 @@ alias mvne='mvn eclipse:eclipse'
alias mvnfmt='mvn fmt:format'
alias mvnjetty='mvn jetty:run'
alias mvnp='mvn package'
+alias mvnqdev='mvn quarkus:dev'
alias mvns='mvn site'
alias mvnsrc='mvn dependency:sources'
alias mvnt='mvn test'
@@ -72,7 +73,7 @@ alias mvn-updates='mvn versions:display-dependency-updates'
function listMavenCompletions {
local file new_file
- local -a profiles POM_FILES
+ local -a profiles POM_FILES modules
# Root POM
POM_FILES=(~/.m2/settings.xml)
@@ -108,6 +109,9 @@ function listMavenCompletions {
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
@@ -184,6 +188,8 @@ function listMavenCompletions {
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
@@ -268,8 +274,8 @@ function listMavenCompletions {
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
+ #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="
@@ -320,6 +326,7 @@ function listMavenCompletions {
-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
)
}
diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md
index 079cf0009..749a43403 100644
--- a/plugins/nvm/README.md
+++ b/plugins/nvm/README.md
@@ -1,9 +1,26 @@
# nvm plugin
-This plugin adds autocompletions for [nvm](https://github.com/creationix/nvm) — a Node.js version manager.
+This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager.
It also automatically sources nvm, so you don't need to do it manually in your `.zshrc`.
To use it, add `nvm` to the plugins array of your zshrc file:
+
```zsh
plugins=(... nvm)
```
+
+## Settings
+
+- **`NVM_DIR`**: if you have installed nvm in a directory other than `$HOME/.nvm`, set and export `NVM_DIR`
+ to be the directory where you installed nvm.
+
+- **`NVM_HOMEBREW`**: if you installed nvm via Homebrew, in a directory other than `/usr/local/opt/nvm`, you
+ can set `NVM_HOMEBREW` to be the directory where you installed it.
+
+- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session,
+ set `NVM_LAZY` to `1`. This will use the `--no-use` parameter when loading nvm, and will create a function
+ for `node`, `npm` and `yarn`, so when you call either of these three, nvm will load with `nvm use default`.
+
+- **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when
+ if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating
+ which node version to load.
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
index 4bab8e9d7..1e9b26e7a 100644
--- a/plugins/nvm/nvm.plugin.zsh
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -1,8 +1,77 @@
-# Set NVM_DIR if it isn't already defined
-[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm"
+# See https://github.com/nvm-sh/nvm#installation-and-update
+if [[ -z "$NVM_DIR" ]]; then
+ if [[ -d "$HOME/.nvm" ]]; then
+ export NVM_DIR="$HOME/.nvm"
+ elif [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/nvm" ]]; then
+ export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvm"
+ fi
+fi
+
+# Don't try to load nvm if command already available
+which nvm &> /dev/null && return
+
+if [[ -f "$NVM_DIR/nvm.sh" ]]; then
+ # Load nvm if it exists in $NVM_DIR
+ source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"}
+else
+ # Otherwise try to load nvm installed via Homebrew
+ # User can set this if they have an unusual Homebrew setup
+ NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}"
+ # Load nvm from Homebrew location if it exists
+ if [[ -f "$NVM_HOMEBREW/nvm.sh" ]]; then
+ source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"}
+ else
+ # Exit the plugin if we couldn't find nvm
+ return
+ fi
+fi
+
+# Call nvm when first using node, npm or yarn
+if (( $+NVM_LAZY )); then
+ function node npm yarn {
+ unfunction node npm yarn
+ nvm use default
+ command "$0" "$@"
+ }
+fi
-# Try to load nvm only if command not already available
-if ! type "nvm" &> /dev/null; then
- # Load nvm if it exists
- [[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
+# Autoload nvm when finding a .nvmrc file in the current directory
+# Adapted from: https://github.com/nvm-sh/nvm#zsh
+if (( $+NVM_AUTOLOAD )); then
+ load-nvmrc() {
+ local node_version="$(nvm version)"
+ local nvmrc_path="$(nvm_find_nvmrc)"
+
+ if [[ -n "$nvmrc_path" ]]; then
+ local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
+
+ if [[ "$nvmrc_node_version" = "N/A" ]]; then
+ nvm install
+ elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
+ nvm use
+ fi
+ elif [[ "$node_version" != "$(nvm version default)" ]]; then
+ echo "Reverting to nvm default version"
+ nvm use default
+ fi
+ }
+
+ autoload -U add-zsh-hook
+ add-zsh-hook chpwd load-nvmrc
+
+ load-nvmrc
fi
+
+# Load nvm bash completion
+for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
+ if [[ -f "$nvm_completion" ]]; then
+ # Load bashcompinit
+ autoload -U +X bashcompinit && bashcompinit
+ # Bypass compinit call in nvm bash completion script. See:
+ # https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93
+ ZSH_VERSION= source "$nvm_completion"
+ break
+ fi
+done
+
+unset NVM_HOMEBREW NVM_LAZY NVM_AUTOLOAD nvm_completion
diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh
index aaae90185..a46e7658c 100644
--- a/plugins/pip/pip.plugin.zsh
+++ b/plugins/pip/pip.plugin.zsh
@@ -9,7 +9,11 @@
# If you would like to clear your cache, go ahead and do a
# "zsh-pip-clear-cache".
-ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
+if [[ -d "${XDG_CACHE_HOME:-$HOME/.cache}/pip" ]]; then
+ ZSH_PIP_CACHE_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/pip/zsh-cache"
+else
+ ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
+fi
ZSH_PIP_INDEXES=(https://pypi.org/simple/)
zsh-pip-clear-cache() {
diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh
index b7ae2046f..82ba6ff8c 100644
--- a/plugins/pyenv/pyenv.plugin.zsh
+++ b/plugins/pyenv/pyenv.plugin.zsh
@@ -29,7 +29,7 @@ if [[ $FOUND_PYENV -ne 1 ]]; then
fi
if [[ $FOUND_PYENV -eq 1 ]]; then
- eval "$(pyenv init - zsh)"
+ eval "$(pyenv init - --no-rehash zsh)"
if (( $+commands[pyenv-virtualenv-init] )); then
eval "$(pyenv virtualenv-init - zsh)"
fi
diff --git a/plugins/safe-paste/safe-paste.plugin.zsh b/plugins/safe-paste/safe-paste.plugin.zsh
index 75f1791d7..db524538c 100644
--- a/plugins/safe-paste/safe-paste.plugin.zsh
+++ b/plugins/safe-paste/safe-paste.plugin.zsh
@@ -1,54 +1,100 @@
+# A good summary of the zsh 5.1 Bracketed Paste Mode changes is at:
+# https://archive.zhimingwang.org/blog/2015-09-21-zsh-51-and-bracketed-paste.html
+
+# zsh 5.1 (September 2015) introduced built-in support for Bracketed Paste Mode
+# https://github.com/zsh-users/zsh/blob/68405f31a043bdd5bf338eb06688ed3e1f740937/README#L38-L45
+#
+# zsh 5.1 breaks url-quote-magic and other widgets replacing self-insert
+# zsh-users' bracketed-paste-magic resolves these issues:
+# https://github.com/zsh-users/zsh/blob/f702e17b14d75aa21bff014168fa9048124db286/Functions/Zle/bracketed-paste-magic#L9-L12
+
+# Load bracketed-paste-magic if zsh version is >= 5.1
+if [[ ${ZSH_VERSION:0:3} -ge 5.1 ]]; then
+ set zle_bracketed_paste # Explicitly restore this zsh default
+ autoload -Uz bracketed-paste-magic
+ zle -N bracketed-paste bracketed-paste-magic
+ return ### The rest of this file is NOT executed on zsh version >= 5.1 ###
+fi
+
+######################################################################
+# The rest of this file is ONLY executed if zsh version < 5.1
+######################################################################
+
# Code from Mikael Magnusson: https://www.zsh.org/mla/users/2011/msg00367.html
#
-# Requires xterm, urxvt, iTerm2 or any other terminal that supports bracketed
-# paste mode as documented: https://www.xfree86.org/current/ctlseqs.html
-
-# create a new keymap to use while pasting
-bindkey -N paste
-# make everything in this keymap call our custom widget
-bindkey -R -M paste "^@"-"\M-^?" paste-insert
-# these are the codes sent around the pasted text in bracketed
-# paste mode.
-# do the first one with both -M viins and -M vicmd in vi mode
-bindkey '^[[200~' _start_paste
-bindkey -M paste '^[[201~' _end_paste
-# insert newlines rather than carriage returns when pasting newlines
-bindkey -M paste -s '^M' '^J'
-
-zle -N _start_paste
-zle -N _end_paste
-zle -N zle-line-init _zle_line_init
-zle -N zle-line-finish _zle_line_finish
-zle -N paste-insert _paste_insert
-
-# switch the active keymap to paste mode
-function _start_paste() {
- bindkey -A paste main
+# Requires xterm, urxvt, iTerm2 or any other terminal that supports
+# Bracketed Paste Mode as documented:
+# https://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode
+#
+# For tmux, use: bind ] paste-buffer -p
+#
+# Additional technical details: https://cirw.in/blog/bracketed-paste
+
+# Create a new keymap to use while pasting
+bindkey -N bracketed-paste
+# Make everything in this new keymap enqueue characters for pasting
+bindkey -RM bracketed-paste '\x00-\xFF' bracketed-paste-enqueue
+# These are the codes sent around the pasted text in bracketed paste mode
+bindkey -M main '^[[200~' _bracketed_paste_begin
+bindkey -M bracketed-paste '^[[201~' _bracketed_paste_end
+# Insert newlines rather than carriage returns when pasting newlines
+bindkey -M bracketed-paste -s '^M' '^J'
+
+zle -N _bracketed_paste_begin
+zle -N _bracketed_paste_end
+zle -N bracketed-paste-enqueue _bracketed_paste_enqueue
+
+# Attempt to not clobber zle_line_{init,finish}
+# Use https://github.com/willghatch/zsh-hooks if available
+if typeset -f hooks-add-hook > /dev/null; then
+ hooks-add-hook zle_line_init_hook _bracketed_paste_zle_init
+ hooks-add-hook zle_line_finish_hook _bracketed_paste_zle_finish
+else
+ zle -N zle-line-init _bracketed_paste_zle_init
+ zle -N zle-line-finish _bracketed_paste_zle_finish
+fi
+
+# Switch the active keymap to paste mode
+_bracketed_paste_begin() {
+ # Save the bindkey command to restore the active ("main") keymap
+ # Tokenise the restorative bindkey command into an array
+ _bracketed_paste_restore_keymap=( ${(z)"$(bindkey -lL main)"} )
+ bindkey -A bracketed-paste main
}
-# go back to our normal keymap, and insert all the pasted text in the
-# command line. this has the nice effect of making the whole paste be
+# Go back to our normal keymap, and insert all the pasted text in the
+# command line. This has the nice effect of making the whole paste be
# a single undo/redo event.
-function _end_paste() {
-#use bindkey -v here with vi mode probably. maybe you want to track
-#if you were in ins or cmd mode and restore the right one.
- bindkey -e
- LBUFFER+=$_paste_content
- unset _paste_content
+_bracketed_paste_end() {
+ # Only execute the restore command if it starts with 'bindkey'
+ # Allow for option KSH_ARRAYS being set (indexing starts at 0)
+ if [ ${_bracketed_paste_restore_keymap[@]:0:1} = 'bindkey' ]; then
+ $_bracketed_paste_restore_keymap
+ fi
+ LBUFFER+=$_bracketed_paste_content
+ unset _bracketed_paste_content _bracketed_paste_restore_keymap
}
-function _paste_insert() {
- _paste_content+=$KEYS
+# Append a pasted character to the content which is later inserted as a whole
+_bracketed_paste_enqueue() {
+ _bracketed_paste_content+=$KEYS
}
-function _zle_line_init() {
- # Tell terminal to send escape codes around pastes.
- [[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004h'
+# Run at zle-line-init
+_bracketed_paste_zle_init() {
+ _bracketed_paste_content=''
+ # Tell terminal to send escape codes around pastes
+ if [ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]; then
+ printf '\e[?2004h'
+ fi
}
-function _zle_line_finish() {
- # Tell it to stop when we leave zle, so pasting in other programs
- # doesn't get the ^[[200~ codes around the pasted text.
- [[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004l'
+# Run at zle-line-finish
+_bracketed_paste_zle_finish() {
+ # Turn off bracketed paste when we leave ZLE, so pasting in other programs
+ # doesn't get the ^[[200~ codes around the pasted text
+ if [ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]; then
+ printf '\e[?2004l'
+ fi
}
diff --git a/plugins/scd/README.md b/plugins/scd/README.md
index 8c156da1f..d8535f9f2 100644
--- a/plugins/scd/README.md
+++ b/plugins/scd/README.md
@@ -14,8 +14,9 @@ directory aliases, which appear as named directories in zsh session.
## INSTALLATION NOTES
Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh*
-shells and is also available as [Vim](https://www.vim.org/) plugin and
-[IPython](https://ipython.org/) extension. For installation details, see
+shells and is also available as Vim plugin
+[scd.vim](https://github.com/pavoljuhas/scd.vim) and
+[IPython](https://ipython.org) extension. For installation details, see
https://github.com/pavoljuhas/smart-change-directory.
## SYNOPSIS
@@ -24,11 +25,31 @@ https://github.com/pavoljuhas/smart-change-directory.
scd [options] [pattern1 pattern2 ...]
```
+## PATTERNS
+
+Patterns may use all zsh [glob operators](
+http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators)
+available with *extendedglob* option. Specified patterns must match
+the absolute path and at least one of them must match in the tail.
+Several special patterns are also recognized as follows:
+
+<dl><dt>
+^PAT</dt><dd>
+ PAT must match at the beginning of the path, for example, "^/home"</dd><dt>
+PAT$</dt><dd>
+ require PAT to match the end of the path, "man$"</dd><dt>
+./</dt><dd>
+ match only subdirectories of the current directory</dd><dt>
+:PAT</dt><dd>
+ require PAT to match over the tail component, ":doc", ":re/doc"</dd>
+</dl>
+
+
## OPTIONS
<dl><dt>
-a, --add</dt><dd>
- add specified directories to the directory index.</dd><dt>
+ add current or specified directories to the directory index.</dd><dt>
--unindex</dt><dd>
remove current or specified directories from the index.</dd><dt>
@@ -42,11 +63,16 @@ scd [options] [pattern1 pattern2 ...]
--unalias</dt><dd>
remove ALIAS definition for the current or specified directory from
- <em>~/.scdalias.zsh</em>.</dd><dt>
+ <em>~/.scdalias.zsh</em>. Use "OLD" to purge aliases to non-existent
+ directories.</dd><dt>
-A, --all</dt><dd>
- include all matching directories. Disregard matching by directory
- alias and filtering of less likely paths.</dd><dt>
+ display all directories even those excluded by patterns in
+ <em>~/.scdignore</em>. Disregard the unique matching for a
+ directory alias and filtering of less likely paths.</dd><dt>
+
+-p, --push</dt><dd>
+ use "pushd" to change to the target directory.</dd><dt>
--list</dt><dd>
show matching directories and exit.</dd><dt>
@@ -58,6 +84,7 @@ scd [options] [pattern1 pattern2 ...]
display this options summary and exit.</dd>
</dl>
+
## Examples
```sh
@@ -83,17 +110,26 @@ scd --alias=xray
scd xray
```
-# FILES
+## FILES
<dl><dt>
~/.scdhistory</dt><dd>
time-stamped index of visited directories.</dd><dt>
~/.scdalias.zsh</dt><dd>
- scd-generated definitions of directory aliases.</dd>
+ scd-generated definitions of directory aliases.</dd><dt>
+
+~/.scdignore</dt><dd>
+ <a href="http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators">
+ glob patterns</a> for paths to be ignored in the scd search, for example,
+ <code>/mnt/backup/*</code>. The patterns are specified one per line
+ and are matched assuming the <em>extendedglob</em> zsh option. Lines
+ starting with "#" are skipped as comments. The .scdignore patterns
+ are not applied in the <em>--all</em> mode.</dd>
</dl>
-# ENVIRONMENT
+
+## ENVIRONMENT
<dl><dt>
SCD_HISTFILE</dt><dd>
diff --git a/plugins/scd/_scd b/plugins/scd/_scd
new file mode 100644
index 000000000..39c7fa463
--- /dev/null
+++ b/plugins/scd/_scd
@@ -0,0 +1,60 @@
+#compdef scd
+#description smart change directory
+
+local curcontext="$curcontext" state line expl ret=1
+typeset -A opt_args
+
+local -a indexopts myargs
+indexopts=( --add -a --unindex )
+
+myargs=(
+ # common options
+ "(--help -h)"{--help,-h}"[print help and exit]"
+
+ # options for manipulating directory index
+ - index
+ "(--recursive -r)"{--recursive,-r}"[use recursive --add or --unindex]"
+ "($indexopts)"{--add,-a}"[add specified directories to the index]"
+ "($indexopts)--unindex[remove specified directories from the index]"
+ "*:directory:{ (( ${words[(I)-a|--add|--unindex]} )) && _path_files -/ }"
+
+ # define new directory alias
+ - alias
+ "--alias=[create alias for this or given directory]:directory-alias:()"
+ '1:directory:{ (( words[(I)--alias*] )) && _path_files -/ }'
+
+ # remove definition of directory alias
+ - unalias
+ "--unalias[remove definition of directory alias]"
+ "*::directory alias:->scd-alias-target"
+
+ # act on the directory change
+ - scd
+ "(--all -A)"{--all,-A}"[include less likely and ignored paths]"
+ "--list[print matching directories and exit]"
+ "(--verbose -v)"{--verbose,-v}"[show directory ranking and full paths]"
+ "(--push -p)"{--push,-p}"[change directory with 'pushd']"
+ "1::directory alias:->scd-alias-target"
+ "*:patterns:()"
+)
+
+_arguments -S -C $myargs && ret=0
+
+
+if [[ "$state" == scd-alias-target && -s ~/.scdalias.zsh ]]; then
+ local -a scdaliases
+ scdaliases=( )
+ eval "$(setopt extendedglob
+ phome="(#b)(#s)${HOME}(/*)#(#e)"
+ builtin hash -dr
+ source ~/.scdalias.zsh &&
+ for k v in ${(kv)nameddirs}; do
+ scdaliases+=( $k:${v/${~phome}/"~"${match[1]}} )
+ done
+ complete_unalias=${+opt_args[unalias---unalias]}
+ if (( complete_unalias && ! ${+nameddirs[OLD]} )); then
+ scdaliases+=( 'OLD:all aliases to non-existent paths' )
+ fi
+ typeset -p scdaliases )"
+ _describe -t scdaliases scdalias scdaliases
+fi
diff --git a/plugins/scd/scd b/plugins/scd/scd
index 39b28237d..a7db6c265 100644..100755
--- a/plugins/scd/scd
+++ b/plugins/scd/scd
@@ -1,29 +1,39 @@
#!/bin/zsh -f
emulate -L zsh
+
+local RUNNING_AS_COMMAND=
local EXIT=return
if [[ $(whence -w $0) == *:' 'command ]]; then
- emulate -R zsh
- local RUNNING_AS_COMMAND=1
+ RUNNING_AS_COMMAND=1
EXIT=exit
fi
local DOC='scd -- smart change to a recently used directory
usage: scd [options] [pattern1 pattern2 ...]
-Go to a directory path that contains all fixed string patterns. Prefer
-recent or frequently visited directories as found in the directory index.
+Go to a directory path that matches all patterns. Prefer recent or
+frequently visited directories as found in the directory index.
Display a selection menu in case of multiple matches.
+Special patterns:
+ ^PAT match at the path root, "^/home"
+ PAT$ match paths ending with PAT, "man$"
+ ./ match paths under the current directory
+ :PAT require PAT to span the tail, ":doc", ":re/doc"
+
Options:
- -a, --add add specified directories to the directory index.
+ -a, --add add current or specified directories to the index.
--unindex remove current or specified directories from the index.
-r, --recursive apply options --add or --unindex recursively.
--alias=ALIAS create alias for the current or specified directory and
store it in ~/.scdalias.zsh.
--unalias remove ALIAS definition for the current or specified
directory from ~/.scdalias.zsh.
- -A, --all include all matching directories. Disregard matching by
- directory alias and filtering of less likely paths.
+ Use "OLD" to purge aliases to non-existent directories.
+ -A, --all display all directories even those excluded by patterns
+ in ~/.scdignore. Disregard unique match for a directory
+ alias and filtering of less likely paths.
+ -p, --push use "pushd" to change to the target directory.
--list show matching directories and exit.
-v, --verbose display directory rank in the selection menu.
-h, --help display this message and exit.
@@ -36,18 +46,28 @@ local SCD_MEANLIFE=${SCD_MEANLIFE:-86400}
local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005}
local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT}
local SCD_ALIAS=~/.scdalias.zsh
+local SCD_IGNORE=~/.scdignore
-local ICASE a d m p i maxrank threshold
+# Minimum logarithm of probability. Avoids out of range warning in exp().
+local -r MINLOGPROB=-15
+
+# When false, use case-insensitive globbing to fix PWD capitalization.
+local PWDCASECORRECT=true
+if [[ ${OSTYPE} == darwin* ]]; then
+ PWDCASECORRECT=false
+fi
+
+local a d m p i maxrank threshold
local opt_help opt_add opt_unindex opt_recursive opt_verbose
-local opt_alias opt_unalias opt_all opt_list
-local -A drank dalias
+local opt_alias opt_unalias opt_all opt_push opt_list
+local -A drank dalias scdignore
local dmatching
local last_directory
-setopt extendedhistory extendedglob noautonamedirs brace_ccl
+setopt extendedglob noautonamedirs brace_ccl
-# If SCD_SCRIPT is defined make sure the file exists and is empty.
-# This removes any previous old commands.
+# If SCD_SCRIPT is defined make sure that that file exists and is empty.
+# This removes any old previous commands from the SCD_SCRIPT file.
[[ -n "$SCD_SCRIPT" ]] && [[ -s $SCD_SCRIPT || ! -f $SCD_SCRIPT ]] && (
umask 077
: >| $SCD_SCRIPT
@@ -56,13 +76,17 @@ setopt extendedhistory extendedglob noautonamedirs brace_ccl
# process command line options
zmodload -i zsh/zutil
zmodload -i zsh/datetime
-zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \
+zmodload -i zsh/parameter
+zparseopts -D -E -- a=opt_add -add=opt_add -unindex=opt_unindex \
r=opt_recursive -recursive=opt_recursive \
-alias:=opt_alias -unalias=opt_unalias \
- A=opt_all -all=opt_all -list=opt_list \
+ A=opt_all -all=opt_all p=opt_push -push=opt_push -list=opt_list \
v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \
|| $EXIT $?
+# remove the first instance of "--" from positional arguments
+argv[(i)--]=( )
+
if [[ -n $opt_help ]]; then
print $DOC
$EXIT
@@ -71,6 +95,22 @@ fi
# load directory aliases if they exist
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
+# load scd-ignore patterns if available
+if [[ -s $SCD_IGNORE ]]; then
+ setopt noglob
+ <$SCD_IGNORE \
+ while read p; do
+ [[ $p != [\#]* ]] || continue
+ [[ -n $p ]] || continue
+ # expand leading tilde if it has valid expansion
+ if [[ $p == [~]* ]] && ( : ${~p} ) 2>/dev/null; then
+ p=${~p}
+ fi
+ scdignore[$p]=1
+ done
+ setopt glob
+fi
+
# Private internal functions are prefixed with _scd_Y19oug_.
# Clean them up when the scd function returns.
setopt localtraps
@@ -79,9 +119,17 @@ trap 'unfunction -m "_scd_Y19oug_*"' EXIT
# works faster than the (:a) modifier and is compatible with zsh 4.2.6
_scd_Y19oug_abspath() {
set -A $1 ${(ps:\0:)"$(
- unfunction -m "*"; shift
+ setopt pushdsilent
+ unfunction -m "*"
+ unalias -m "*"
+ unset CDPATH
+ shift
for d; do
- cd $d && print -Nr -- $PWD && cd $OLDPWD
+ pushd $d || continue
+ $PWDCASECORRECT &&
+ print -Nr -- $PWD ||
+ print -Nr -- (#i)$PWD
+ popd 2>/dev/null
done
)"}
}
@@ -106,47 +154,76 @@ if [[ -n $opt_alias ]]; then
$EXIT $?
fi
-# undefine directory alias
+# undefine one or more directory aliases
if [[ -n $opt_unalias ]]; then
- if [[ -n $1 && ! -d $1 ]]; then
- print -u2 "'$1' is not a directory."
- $EXIT 1
- fi
- _scd_Y19oug_abspath a ${1:-$PWD}
- a=$(print -rD ${a})
- if [[ $a != [~][^/]## ]]; then
- $EXIT
+ local -U uu
+ local ec=0
+ uu=( ${*:-${PWD}} )
+ if (( ${uu[(I)OLD]} && ${+nameddirs[OLD]} == 0 )); then
+ uu=( ${uu:#OLD} ${(ps:\0:)"$(
+ hash -dr
+ if [[ -r $SCD_ALIAS ]]; then
+ source $SCD_ALIAS
+ fi
+ for a d in ${(kv)nameddirs}; do
+ [[ -d $d ]] || print -Nr -- $a
+ done
+ )"}
+ )
fi
- a=${a#[~]}
- # unalias in the current shell, update alias file if successful
- if unhash -d -- $a 2>/dev/null && [[ -r $SCD_ALIAS ]]; then
+ m=( )
+ for p in $uu; do
+ d=$p
+ if [[ ${+nameddirs[$d]} == 0 && -d $d ]]; then
+ _scd_Y19oug_abspath d $d
+ fi
+ a=${(k)nameddirs[$d]:-${(k)nameddirs[(r)$d]}}
+ if [[ -z $a ]]; then
+ ec=1
+ print -u2 "'$p' is neither a directory alias nor an aliased path."
+ continue
+ fi
+ # unalias in the current shell and remember to update the alias file
+ if unhash -d -- $a 2>/dev/null; then
+ m+=( $a )
+ fi
+ done
+ if [[ $#m != 0 && -r $SCD_ALIAS ]]; then
(
umask 077
hash -dr
source $SCD_ALIAS
- unhash -d -- $a 2>/dev/null &&
+ for a in $m; do
+ unhash -d -- $a 2>/dev/null
+ done
hash -dL >| $SCD_ALIAS
- )
+ ) || ec=$?
fi
- $EXIT $?
+ $EXIT $ec
fi
-# The "compress" function collapses repeated directories to
-# one entry with a time stamp that gives equivalent-probability.
+# The "compress" function collapses repeated directories into
+# a single entry with a time-stamp yielding an equivalent probability.
_scd_Y19oug_compress() {
- awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
- BEGIN { FS = "[:;]"; }
- length($0) < 4096 && $2 > 0 {
+ awk -v epochseconds=$EPOCHSECONDS \
+ -v meanlife=$SCD_MEANLIFE \
+ -v minlogprob=$MINLOGPROB \
+ '
+ BEGIN {
+ FS = "[:;]";
+ pmin = exp(minlogprob);
+ }
+ /^: deleted:0;/ { next; }
+ length($0) < 4096 && $2 > 1000 {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ if (!df) next;
tau = 1.0 * ($2 - epochseconds) / meanlife;
- if (tau < -6.9078) tau = -6.9078;
- prob = exp(tau);
- sub(/^[^;]*;/, "");
- if (NF) {
- dlist[last[$0]] = "";
- dlist[NR] = $0;
- last[$0] = NR;
- ptot[$0] += prob;
- }
+ prob = (tau < minlogprob) ? pmin : exp(tau);
+ dlist[last[df]] = "";
+ dlist[NR] = df;
+ last[df] = NR;
+ ptot[df] += prob;
}
END {
for (i = 1; i <= NR; ++i) {
@@ -157,26 +234,38 @@ _scd_Y19oug_compress() {
}
}
}
- ' $*
+ ' $*
}
-# Rewrite directory index if it is at least 20% oversized
-if [[ -s $SCD_HISTFILE ]] && \
-(( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then
- # compress repeated entries
- m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
- # purge non-existent directories
- m=( ${(f)"$(
- for a in $m; do
- if [[ -d ${a#*;} ]]; then print -r -- $a; fi
- done
- )"}
- )
- # cut old entries if still oversized
- if [[ $#m -gt $SCD_HISTSIZE ]]; then
- m=( ${m[-$SCD_HISTSIZE,-1]} )
- fi
- print -lr -- $m >| ${SCD_HISTFILE}
+# Rewrite directory index if it is at least 20% oversized.
+local curhistsize
+if [[ -z $opt_unindex && -s $SCD_HISTFILE ]] && \
+curhistsize=$(wc -l <$SCD_HISTFILE) && \
+(( $curhistsize > 1.2 * $SCD_HISTSIZE )); then
+ # Compress repeated entries in a background process.
+ (
+ m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
+ # purge non-existent and ignored directories
+ m=( ${(f)"$(
+ for a in $m; do
+ d=${a#*;}
+ [[ -z ${scdignore[(k)$d]} ]] || continue
+ [[ -d $d ]] || continue
+ $PWDCASECORRECT || d=( (#i)${d} )
+ t=${a%%;*}
+ print -r -- "${t};${d}"
+ done
+ )"}
+ )
+ # cut old entries if still oversized
+ if [[ $#m -gt $SCD_HISTSIZE ]]; then
+ m=( ${m[-$SCD_HISTSIZE,-1]} )
+ fi
+ # Checking existence of many directories could have taken a while.
+ # Append any index entries added in meantime.
+ m+=( ${(f)"$(sed "1,${curhistsize}d" $SCD_HISTFILE)"} )
+ print -lr -- $m >| ${SCD_HISTFILE}
+ ) &|
fi
# Determine the last recorded directory
@@ -197,13 +286,8 @@ _scd_Y19oug_record() {
}
if [[ -n $opt_add ]]; then
- for d; do
- if [[ ! -d $d ]]; then
- print -u2 "Directory '$d' does not exist."
- $EXIT 2
- fi
- done
- _scd_Y19oug_abspath m ${*:-$PWD}
+ m=( ${^${argv:-$PWD}}(N-/) )
+ _scd_Y19oug_abspath m ${m}
_scd_Y19oug_record $m
if [[ -n $opt_recursive ]]; then
for d in $m; do
@@ -220,6 +304,7 @@ if [[ -n $opt_unindex ]]; then
if [[ ! -s $SCD_HISTFILE ]]; then
$EXIT
fi
+ argv=( ${argv:-$PWD} )
# expand existing directories in the argument list
for i in {1..$#}; do
if [[ -d ${argv[i]} ]]; then
@@ -227,24 +312,28 @@ if [[ -n $opt_unindex ]]; then
argv[i]=${d}
fi
done
+ # strip trailing slashes, but preserve the root path
+ argv=( ${argv/(#m)?\/##(#e)/${MATCH[1]}} )
m="$(awk -v recursive=${opt_recursive} '
BEGIN {
for (i = 2; i < ARGC; ++i) {
argset[ARGV[i]] = 1;
delete ARGV[i];
}
+ unindex_root = ("/" in argset);
}
1 {
d = $0; sub(/^[^;]*;/, "", d);
if (d in argset) next;
}
recursive {
+ if (unindex_root) exit;
for (a in argset) {
if (substr(d, 1, length(a) + 1) == a"/") next;
}
}
{ print $0 }
- ' $SCD_HISTFILE ${*:-$PWD} )" || $EXIT $?
+ ' $SCD_HISTFILE $* )" || $EXIT $?
: >| ${SCD_HISTFILE}
[[ ${#m} == 0 ]] || print -r -- $m >> ${SCD_HISTFILE}
$EXIT
@@ -252,67 +341,113 @@ fi
# The "action" function is called when there is just one target directory.
_scd_Y19oug_action() {
- cd $1 || return $?
+ local cdcmd=cd
+ [[ -z ${opt_push} ]] || cdcmd=pushd
+ builtin $cdcmd $1 || return $?
if [[ -z $SCD_SCRIPT && -n $RUNNING_AS_COMMAND ]]; then
print -u2 "Warning: running as command with SCD_SCRIPT undefined."
fi
if [[ -n $SCD_SCRIPT ]]; then
- print -r "cd ${(q)1}" >| $SCD_SCRIPT
+ local d=$1
+ if [[ $OSTYPE == cygwin && ${(L)SCD_SCRIPT} == *.bat ]]; then
+ d=$(cygpath -aw .)
+ fi
+ print -r "${cdcmd} ${(qqq)d}" >| $SCD_SCRIPT
fi
}
-# Match and rank patterns to the index file
-# set global arrays dmatching and drank
+# Select and order indexed directories by matching command-line patterns.
+# Set global arrays dmatching and drank.
_scd_Y19oug_match() {
## single argument that is an existing directory or directory alias
if [[ -z $opt_all && $# == 1 ]] && \
- [[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]];
+ [[ -d ${d::=${nameddirs[$1]}} || -d ${d::=$1} ]] && [[ -x $d ]];
then
_scd_Y19oug_abspath dmatching $d
drank[${dmatching[1]}]=1
return
fi
- # ignore case unless there is an argument with an uppercase letter
- [[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)'
- # support "$" as an anchor for the directory name ending
+ # quote brackets when PWD is /Volumes/[C]/
+ local qpwd=${PWD//(#m)[][]/\\${MATCH}}
+
+ # support "./" as an alias for $PWD to match only subdirectories.
+ argv=( ${argv/(#s).\/(#e)/(#s)${qpwd}(|/*)(#e)} )
+
+ # support "./pat" as an alias for $PWD/pat.
+ argv=( ${argv/(#m)(#s).\/?*/(#s)${qpwd}${MATCH#.}} )
+
+ # support "^" as an anchor for the root directory, e.g., "^$HOME".
+ argv=( ${argv/(#m)(#s)\^?*/(#s)${${~MATCH[2,-1]}}} )
+
+ # support "$" as an anchor at the end of directory name.
argv=( ${argv/(#m)?[$](#e)/${MATCH[1]}(#e)} )
- # calculate rank of all directories in the SCD_HISTFILE and keep it as drank
- # include a dummy entry for splitting of an empty string is buggy
+ # support prefix ":" to match over the tail component.
+ argv=( ${argv/(#m)(#s):?*/${MATCH[2,-1]}[^/]#(#e)} )
+
+ # calculate rank of all directories in SCD_HISTFILE and store it in drank.
+ # include a dummy entry to avoid issues with splitting an empty string.
[[ -s $SCD_HISTFILE ]] && drank=( ${(f)"$(
print -l /dev/null -10
<$SCD_HISTFILE \
- awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
- BEGIN { FS = "[:;]"; }
+ awk -v epochseconds=$EPOCHSECONDS \
+ -v meanlife=$SCD_MEANLIFE \
+ -v minlogprob=$MINLOGPROB \
+ '
+ BEGIN {
+ FS = "[:;]";
+ pmin = exp(minlogprob);
+ }
+ /^: deleted:0;/ {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ delete ptot[df];
+ next;
+ }
length($0) < 4096 && $2 > 0 {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ if (!df) next;
+ dp = df;
+ while (!(dp in ptot)) {
+ ptot[dp] = pmin;
+ sub("//*[^/]*$", "", dp);
+ if (!dp) break;
+ }
+ if ($2 <= 1000) next;
tau = 1.0 * ($2 - epochseconds) / meanlife;
- if (tau < -6.9078) tau = -6.9078;
- prob = exp(tau);
- sub(/^[^;]*;/, "");
- if (NF) ptot[$0] += prob;
+ prob = (tau < minlogprob) ? pmin : exp(tau);
+ ptot[df] += prob;
}
- END { for (di in ptot) { print di; print ptot[di]; } }'
+ END { for (di in ptot) { print di; print ptot[di]; } }
+ '
)"}
)
unset "drank[/dev/null]"
# filter drank to the entries that match all arguments
for a; do
- p=${ICASE}"*(${a})*"
+ p="(#l)*(${a})*"
drank=( ${(kv)drank[(I)${~p}]} )
done
- # require at least one argument matches the directory name
- p=${ICASE}"*(${(j:|:)argv})[^/]#"
+ # require that at least one argument matches in directory tail name.
+ p="(#l)*(${(j:|:)argv})[^/]#"
drank=( ${(kv)drank[(I)${~p}]} )
+ # discard ignored directories
+ if [[ -z ${opt_all} ]]; then
+ for d in ${(k)drank}; do
+ [[ -z ${scdignore[(k)$d]} ]] || unset "drank[$d]"
+ done
+ fi
+
# build a list of matching directories reverse-sorted by their probabilities
dmatching=( ${(f)"$(
- for d p in ${(kv)drank}; do
- print -r -- "$p $d";
- done | sort -grk1 | cut -d ' ' -f 2-
- )"}
+ builtin printf "%s %s\n" ${(Oakv)drank} |
+ /usr/bin/sort -grk1 )"}
)
+ dmatching=( ${dmatching#*[[:blank:]]} )
# do not match $HOME or $PWD when run without arguments
if [[ $# == 0 ]]; then
@@ -320,12 +455,20 @@ _scd_Y19oug_match() {
fi
# keep at most SCD_MENUSIZE of matching and valid directories
+ # mark up any deleted entries in the index
+ local -A isdeleted
m=( )
+ isdeleted=( )
for d in $dmatching; do
[[ ${#m} == $SCD_MENUSIZE ]] && break
- [[ -d $d && -x $d ]] && m+=$d
+ (( ${+isdeleted[$d]} == 0 )) || continue
+ [[ -d $d ]] || { isdeleted[$d]=1; continue }
+ [[ -x $d ]] && m+=$d
done
dmatching=( $m )
+ if [[ -n ${isdeleted} ]]; then
+ print -lr -- ": deleted:0;"${^${(k)isdeleted}} >> $SCD_HISTFILE
+ fi
# find the maximum rank
maxrank=0.0
@@ -343,7 +486,7 @@ _scd_Y19oug_match() {
_scd_Y19oug_match $*
-## process whatever directories that remained
+## process matching directories.
if [[ ${#dmatching} == 0 ]]; then
print -u2 "No matching directory."
$EXIT 1
@@ -367,13 +510,13 @@ if [[ -n $opt_list ]]; then
$EXIT
fi
-## process single directory match
+## handle a single matching directory here.
if [[ ${#dmatching} == 1 ]]; then
_scd_Y19oug_action $dmatching
$EXIT $?
fi
-## here we have multiple matches - display selection menu
+## Here we have multiple matches. Let's use the selection menu.
a=( {a-z} {A-Z} )
a=( ${a[1,${#dmatching}]} )
p=( )
diff --git a/plugins/scd/scd.plugin.zsh b/plugins/scd/scd.plugin.zsh
index 0197c53a1..1a6c18654 100644
--- a/plugins/scd/scd.plugin.zsh
+++ b/plugins/scd/scd.plugin.zsh
@@ -1,19 +1,17 @@
## The scd script should autoload as a shell function.
-autoload scd
+autoload -Uz scd
## If the scd function exists, define a change-directory-hook function
## to record visited directories in the scd index.
if [[ ${+functions[scd]} == 1 ]]; then
- scd_chpwd_hook() { scd --add $PWD }
- autoload add-zsh-hook
- add-zsh-hook chpwd scd_chpwd_hook
+ chpwd_scd() { scd --add $PWD }
+ autoload -Uz add-zsh-hook
+ add-zsh-hook chpwd chpwd_scd
fi
-## Allow scd usage with unquoted wildcard characters such as "*" or "?".
-alias scd='noglob scd'
-
-
## Load the directory aliases created by scd if any.
-if [[ -s ~/.scdalias.zsh ]]; then source ~/.scdalias.zsh; fi
+if [[ -s ~/.scdalias.zsh ]]; then
+ source ~/.scdalias.zsh
+fi
diff --git a/plugins/sublime-merge/README.md b/plugins/sublime-merge/README.md
new file mode 100644
index 000000000..534479179
--- /dev/null
+++ b/plugins/sublime-merge/README.md
@@ -0,0 +1,17 @@
+## sublime-merge
+
+Plugin for Sublime Merge, a cross platform text and code editor, available for Linux, Mac OS X, and Windows.
+
+### Requirements
+
+ * [Sublime Merge](https://www.sublimemerge.com)
+
+### Usage
+
+ * If `sm` command is called without an argument, launch Sublime Merge
+
+ * If `sm` is passed a directory, `cd` to it and open the existing git repository in Sublime Merge
+
+ * If `smt` command is called, it is equivalent to `sm .`, opening the existing git repository in the current folder in Sublime Merge
+
+ * If `ssm` command is called, it is like `sudo sm`, opening the git repository in Sublime Merge. Useful for editing system protected repositories. \ No newline at end of file
diff --git a/plugins/sublime-merge/sublime-merge.plugin.zsh b/plugins/sublime-merge/sublime-merge.plugin.zsh
new file mode 100644
index 000000000..15452e61a
--- /dev/null
+++ b/plugins/sublime-merge/sublime-merge.plugin.zsh
@@ -0,0 +1,55 @@
+# Sublime Merge Aliases
+
+() {
+
+ if [[ "$OSTYPE" == linux* ]]; then
+ local _sublime_linux_paths
+ _sublime_linux_paths=(
+ "$HOME/bin/sublime_merge"
+ "/opt/sublime_merge/sublime_merge"
+ "/usr/bin/sublime_merge"
+ "/usr/local/bin/sublime_merge"
+ "/usr/bin/sublime_merge"
+ "/usr/local/bin/smerge"
+ "/usr/bin/smerge"
+ )
+ for _sublime_merge_path in $_sublime_linux_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ sm_run() { $_sublime_merge_path "$@" >/dev/null 2>&1 &| }
+ ssm_run_sudo() {sudo $_sublime_merge_path "$@" >/dev/null 2>&1}
+ alias ssm=ssm_run_sudo
+ alias sm=sm_run
+ break
+ fi
+ done
+ elif [[ "$OSTYPE" = darwin* ]]; then
+ local _sublime_darwin_paths
+ _sublime_darwin_paths=(
+ "/usr/local/bin/smerge"
+ "/Applications/Sublime Merge.app/Contents/SharedSupport/bin/smerge"
+ "$HOME/Applications/Sublime Merge.app/Contents/SharedSupport/bin/smerge"
+ )
+ for _sublime_merge_path in $_sublime_darwin_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ subm () { "$_sublime_merge_path" "$@" }
+ alias sm=subm
+ break
+ fi
+ done
+ elif [[ "$OSTYPE" = 'cygwin' ]]; then
+ local sublime_merge_cygwin_paths
+ sublime_merge_cygwin_paths=(
+ "$(cygpath $ProgramW6432/Sublime\ Merge)/sublime_merge.exe"
+ )
+ for _sublime_merge_path in $_sublime_merge_cygwin_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ subm () { "$_sublime_merge_path" "$@" }
+ alias sm=subm
+ break
+ fi
+ done
+ fi
+
+}
+
+alias smt='sm .'
diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
index 179342595..618dd8ee8 100644
--- a/plugins/sublime/sublime.plugin.zsh
+++ b/plugins/sublime/sublime.plugin.zsh
@@ -37,9 +37,11 @@ alias stn=create_project
_sublime_paths=(
"/usr/local/bin/subl"
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
+ "/Applications/Sublime Text 4.app/Contents/SharedSupport/bin/subl"
"/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
+ "$HOME/Applications/Sublime Text 4.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
)
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index 51579377d..b3749eff7 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -14,6 +14,14 @@
sudo-command-line() {
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
+
+ # Save beginning space
+ local WHITESPACE=""
+ if [[ ${LBUFFER:0:1} == " " ]] ; then
+ WHITESPACE=" "
+ LBUFFER="${LBUFFER:1}"
+ fi
+
if [[ -n $EDITOR && $BUFFER == $EDITOR\ * ]]; then
if [[ ${#LBUFFER} -le ${#EDITOR} ]]; then
RBUFFER=" ${BUFFER#$EDITOR }"
@@ -38,6 +46,9 @@ sudo-command-line() {
else
LBUFFER="sudo $LBUFFER"
fi
+
+ # Preserve beginning space
+ LBUFFER="${WHITESPACE}${LBUFFER}"
}
zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc]
diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
index 471aef24e..9e9f0cdfb 100644
--- a/plugins/terraform/README.md
+++ b/plugins/terraform/README.md
@@ -2,7 +2,7 @@
Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
-Current as of Terraform v0.11.7
+Current as of Terraform v0.13
### Requirements
@@ -17,6 +17,7 @@ plugins=(... terraform)
```
* Type `terraform` into your prompt and hit `TAB` to see available completion options
+ * Type `tf` into your prompt as a short alias to `terraform`
### Expanding ZSH prompt with current Terraform workspace name
diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh
index d727c1ee0..2c42d394d 100644
--- a/plugins/terraform/terraform.plugin.zsh
+++ b/plugins/terraform/terraform.plugin.zsh
@@ -7,3 +7,5 @@ function tf_prompt_info() {
echo "[${workspace}]"
fi
}
+
+alias tf='terraform'
diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh
index 1be7516a3..b261f71c5 100644
--- a/plugins/timer/timer.plugin.zsh
+++ b/plugins/timer/timer.plugin.zsh
@@ -1,5 +1,8 @@
+zmodload zsh/datetime
+
__timer_current_time() {
- perl -MTime::HiRes=time -e'print time'
+ zmodload zsh/datetime
+ echo $EPOCHREALTIME
}
__timer_format_duration() {
diff --git a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
index 28bf31f91..d7c76c3c9 100644
--- a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
+++ b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
@@ -16,22 +16,17 @@
# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
function vagrant_prompt_info() {
- test -d .vagrant && test -f Vagrantfile
- if [[ "$?" == "0" ]]; then
- statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)")
- statuses=("${(f)statuses}")
+ local vm_states vm_state
+ if [[ -d .vagrant && -f Vagrantfile ]]; then
+ vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^.*(saved|poweroff|running|not created) \([[:alnum:]_]+\)$/\1/p')"})
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
- for vm_details in $statuses; do
- vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running")
- if [[ "$vm_state" == "running" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING
- elif [[ "$vm_state" == "saved" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED
- elif [[ "$vm_state" == "not created" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED
- elif [[ "$vm_state" == "poweroff" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF
- fi
+ for vm_state in $vm_states; do
+ case "$vm_state" in
+ saved) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
+ running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
+ poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
+ "not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
+ esac
done
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
fi
diff --git a/plugins/wd/README.md b/plugins/wd/README.md
index a454a6c1e..8791f9f0e 100644
--- a/plugins/wd/README.md
+++ b/plugins/wd/README.md
@@ -2,19 +2,19 @@
[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)
-`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems inefficient when the folder is frequently visited or has a long path.
+`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`.
+Why?
+Because `cd` seems inefficient when the folder is frequently visited or has a long path.
![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
-*NEWS*: If you are not using zsh, check out the c-port, [wd-c](https://github.com/mfaerevaag/wd-c), which works with all shells using wrapper functions.
-
## Setup
-### oh-my-zsh
+### [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
-`wd` comes bundled with [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)!
+`wd` comes bundled with oh-my-zsh!
-Just add the plugin in your `~/.zshrc` file:
+Just add the plugin in your `.zshrc` file:
```zsh
plugins=(... wd)
@@ -38,11 +38,21 @@ antibody bundle mfaerevaag/wd
### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
+1. Install from the AUR
+
```zsh
yay -S zsh-plugin-wd-git
# or use any other AUR helper
```
+2. Then add to your `.zshrc`:
+
+```zsh
+wd() {
+ . /usr/share/wd/wd.sh
+}
+```
+
### [zplug](https://github.com/zplug/zplug)
```zsh
@@ -51,7 +61,9 @@ zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS
### Automatic
-Run either in terminal:
+_Note: automatic install does not provide the manpage. It is also poor security practice to run remote code without first reviewing it, so you ought to look [here](https://github.com/mfaerevaag/wd/blob/master/install.sh)_
+
+Run either command in your terminal:
```zsh
curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
@@ -65,28 +77,33 @@ wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.
### Manual
-* Clone this repo to your liking
+1. Clone this repository on your local machine in a sensible location (if you know what you're doing of course all of this is up to you):
-* Add `wd` function to `.zshrc` (or `.profile` etc.):
+```zsh
+git clone git@github.com:mfaerevaag/wd.git ~/.local/wd --depth 1
+```
- ```zsh
- wd() {
- . ~/path/to/cloned/repo/wd/wd.sh
- }
- ```
+2. Add `wd` function to `.zshrc` (or `.profile` etc.):
-* Install manpage. From `wd`'s base directory (requires root permissions):
+```zsh
+wd() {
+ . ~/.local/wd/wd.sh
+}
+```
- ```zsh
- cp wd.1 /usr/share/man/man1/wd.1
- chmod 644 /usr/share/man/man1/wd.1
- ```
+3. Install manpage (optional):
- **Note:** when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
+```zsh
+sudo cp ~/.local/wd/wd.1 /usr/share/man/man1/wd.1
+sudo chmod 644 /usr/share/man/man1/wd.1
+```
+
+**Note:** when pulling and updating `wd`, you'll need to repeat step 3 should the manpage change
## Completion
-If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`:
+If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`.
+E.g. in your `~/.zshrc`:
```zsh
fpath=(~/path/to/wd $fpath)
@@ -102,109 +119,110 @@ rm -f ~/.zcompdump; compinit
* Add warp point to current working directory:
- ```zsh
- wd add foo
- ```
+```zsh
+wd add foo
+```
- If a warp point with the same name exists, use `wd add! foo` to overwrite it.
+If a warp point with the same name exists, use `wd add foo --force` to overwrite it.
- **Note:** a warp point cannot contain colons, or consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
+**Note:** a warp point cannot contain colons, or consist of only spaces and dots.
+The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
- You can omit point name to automatically use the current directory's name instead.
+You can omit point name to automatically use the current directory's name instead.
* From any directory, warp to `foo` with:
- ```zsh
- wd foo
- ```
+```zsh
+wd foo
+```
-* You can also warp to a directory within foo, with autocompletion:
+* You can also warp to a directory within `foo`, with autocompletion:
- ```zsh
- wd foo some/inner/path
- ```
+```zsh
+wd foo some/inner/path
+```
* You can warp back to previous directory and higher, with this dot syntax:
- ```zsh
- wd ..
- wd ...
- ```
+```zsh
+wd ..
+wd ...
+```
- This is a wrapper for the zsh's `dirs` function.
- _You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh))._
+This is a wrapper for the zsh's `dirs` function.
+_You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)._
* Remove warp point:
- ```zsh
- wd rm foo
- ```
+```zsh
+wd rm foo
+```
- You can omit point name to use the current directory's name instead.
+You can omit point name to use the current directory's name instead.
-* List all warp points (stored in `~/.warprc`):
+* List all warp points (stored in `~/.warprc` by default):
- ```zsh
- wd list
- ```
+```zsh
+wd list
+```
* List files in given warp point:
- ```zsh
- wd ls foo
- ```
+```zsh
+wd ls foo
+```
* Show path of given warp point:
- ```zsh
- wd path foo
- ```
+```zsh
+wd path foo
+```
* List warp points to current directory, or optionally, path to given warp point:
- ```zsh
- wd show
- ```
+```zsh
+wd show
+```
* Remove warp points to non-existent directories.
- ```zsh
- wd clean
- ```
+```zsh
+wd clean
+```
- Use `wd clean!` to not be prompted with confirmation (force).
+Use `wd clean --force` to not be prompted with confirmation.
* Print usage info:
- ```zsh
- wd help
- ```
+```zsh
+wd help
+```
- The usage will be printed also if you call `wd` with no command
+The usage will be printed also if you call `wd` with no command
* Print the running version of `wd`:
- ```zsh
- wd --version
- ```
+```zsh
+wd --version
+```
* Specifically set the config file (default being `~/.warprc`), which is useful for testing:
- ```zsh
- wd --config ./file <command>
- ```
+```zsh
+wd --config ./file <command>
+```
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required for testing/debugging.
- ```zsh
- wd --debug <command>
- ```
+```zsh
+wd --debug <command>
+```
* Silence all output:
- ```zsh
- wd --quiet <command>
- ```
+```zsh
+wd --quiet <command>
+```
## Configuration
@@ -216,7 +234,7 @@ Defines the path where warp points get stored. Defaults to `$HOME/.warprc`.
## Testing
-`wd` comes with a small test suite, run with [shunit2](https://code.google.com/p/shunit2/). This can be used to confirm that things are working as they should on your setup, or to demonstrate an issue.
+`wd` comes with a small test suite, run with [shunit2](https://github.com/kward/shunit2). This can be used to confirm that things are working as they should on your setup, or to demonstrate an issue.
To run, simply `cd` into the `test` directory and run the `tests.sh`.
@@ -225,15 +243,17 @@ cd ./test
./tests.sh
```
-## License
+## Maintainers
+
+Following @mfaerevaag stepping away from active maintainership of this repository, the following users now are also maintainers of the repo:
-The project is licensed under the [MIT license](https://github.com/mfaerevaag/wd/blob/master/LICENSE).
+* @alpha-tango-kilo
-## Contributing
+* @MattLewin
-If you have issues, feedback or improvements, don't hesitate to report it or submit a pull request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. For an explanation on how to run the tests, read the section "Testing" in this README.
+Anyone else contributing is greatly appreciated and will be mentioned in the release notes!
-----
+---
Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
index 618995c63..9085c5b7b 100644
--- a/plugins/wd/wd.sh
+++ b/plugins/wd/wd.sh
@@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd
# version
-readonly WD_VERSION=0.4.6
+readonly WD_VERSION=0.5.0
# colors
readonly WD_BLUE="\033[96m"
@@ -71,7 +71,7 @@ wd_print_msg()
wd_print_usage()
{
- cat <<- EOF
+ command cat <<- EOF
Usage: wd [command] [point]
Commands:
@@ -79,8 +79,6 @@ Commands:
<point> <path> Warps to the directory specified by the warp point with path appended
add <point> Adds the current working directory to your warp points
add Adds the current working directory to your warp points with current directory's name
- add! <point> Overwrites existing warp point
- add! Overwrites existing warp point with current directory's name
rm <point> Removes the given warp point
rm Removes the given warp point with current directory's name
show <point> Print path to given warp point
@@ -88,12 +86,13 @@ Commands:
list Print all stored warp points
ls <point> Show files from given warp point (ls)
path <point> Show the path to given warp point (pwd)
- clean! Remove points warping to nonexistent directories
+ clean Remove points warping to nonexistent directories (will prompt unless --force is used)
-v | --version Print version
-d | --debug Exit after execution with exit codes (for testing)
-c | --config Specify config file (default ~/.warprc)
-q | --quiet Suppress all output
+ -f | --force Allows overwriting without warning (for add & clean)
help Show this extremely helpful text
EOF
@@ -103,7 +102,7 @@ wd_exit_fail()
{
local msg=$1
- wd_print_msg $WD_RED $msg
+ wd_print_msg "$WD_RED" "$msg"
WD_EXIT_CODE=1
}
@@ -111,7 +110,7 @@ wd_exit_warn()
{
local msg=$1
- wd_print_msg $WD_YELLOW $msg
+ wd_print_msg "$WD_YELLOW" "$msg"
WD_EXIT_CODE=1
}
@@ -119,7 +118,7 @@ wd_getdir()
{
local name_arg=$1
- point=$(wd_show $name_arg)
+ point=$(wd_show "$name_arg")
dir=${point:28+$#name_arg+7}
if [[ -z $name_arg ]]; then
@@ -162,12 +161,12 @@ wd_warp()
wd_add()
{
- local force=$1
- local point=$2
+ local point=$1
+ local force=$2
if [[ $point == "" ]]
then
- point=$(basename $PWD)
+ point=$(basename "$PWD")
fi
if [[ $point =~ "^[\.]+$" ]]
@@ -176,60 +175,62 @@ wd_add()
elif [[ $point =~ "[[:space:]]+" ]]
then
wd_exit_fail "Warp point should not contain whitespace"
- elif [[ $point == *:* ]]
+ elif [[ $point =~ : ]] || [[ $point =~ / ]]
then
- wd_exit_fail "Warp point cannot contain colons"
- elif [[ ${points[$point]} == "" ]] || $force
+ wd_exit_fail "Warp point contains illegal character (:/)"
+ elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ]
then
- wd_remove $point > /dev/null
- printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
+ wd_remove "$point" > /dev/null
+ printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> "$WD_CONFIG"
if (whence sort >/dev/null); then
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
# use 'cat' below to ensure we respect $WD_CONFIG as a symlink
- sort -o "${config_tmp}" $WD_CONFIG && cat "${config_tmp}" > $WD_CONFIG && rm "${config_tmp}"
+ command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" > "$WD_CONFIG" && command rm "${config_tmp}"
fi
wd_export_static_named_directories
- wd_print_msg $WD_GREEN "Warp point added"
+ wd_print_msg "$WD_GREEN" "Warp point added"
# override exit code in case wd_remove did not remove any points
# TODO: we should handle this kind of logic better
WD_EXIT_CODE=0
else
- wd_exit_warn "Warp point '${point}' already exists. Use 'add!' to overwrite."
+ wd_exit_warn "Warp point '${point}' already exists. Use 'add --force' to overwrite."
fi
}
wd_remove()
{
- local point=$1
+ local point_list=$1
- if [[ $point == "" ]]
+ if [[ "$point_list" == "" ]]
then
- point=$(basename $PWD)
+ point_list=$(basename "$PWD")
fi
- if [[ ${points[$point]} != "" ]]
- then
- local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
- # Copy and delete in two steps in order to preserve symlinks
- if sed -n "/^${point}:.*$/!p" $WD_CONFIG > $config_tmp && cp $config_tmp $WD_CONFIG && rm $config_tmp
+ for point_name in $point_list ; do
+ if [[ ${points[$point_name]} != "" ]]
then
- wd_print_msg $WD_GREEN "Warp point removed"
+ local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
+ # Copy and delete in two steps in order to preserve symlinks
+ if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" > "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp"
+ then
+ wd_print_msg "$WD_GREEN" "Warp point removed"
+ else
+ wd_exit_fail "Something bad happened! Sorry."
+ fi
else
- wd_exit_fail "Something bad happened! Sorry."
+ wd_exit_fail "Warp point was not found"
fi
- else
- wd_exit_fail "Warp point was not found"
- fi
+ done
}
wd_list_all()
{
- wd_print_msg $WD_BLUE "All warp points:"
+ wd_print_msg "$WD_BLUE" "All warp points:"
- entries=$(sed "s:${HOME}:~:g" $WD_CONFIG)
+ entries=$(sed "s:${HOME}:~:g" "$WD_CONFIG")
max_warp_point_length=0
while IFS= read -r line
@@ -242,7 +243,7 @@ wd_list_all()
then
max_warp_point_length=$length
fi
- done <<< $entries
+ done <<< "$entries"
while IFS= read -r line
do
@@ -254,35 +255,35 @@ wd_list_all()
if [[ -z $wd_quiet_mode ]]
then
- printf "%${max_warp_point_length}s -> %s\n" $key $val
+ printf "%${max_warp_point_length}s -> %s\n" "$key" "$val"
fi
fi
- done <<< $entries
+ done <<< "$entries"
}
wd_ls()
{
- wd_getdir $1
- ls ${dir/#\~/$HOME}
+ wd_getdir "$1"
+ ls "${dir/#\~/$HOME}"
}
wd_path()
{
- wd_getdir $1
- echo $(echo $dir | sed "s:${HOME}:~:g")
+ wd_getdir "$1"
+ echo "$(echo "$dir" | sed "s:~:${HOME}:g")"
}
wd_show()
{
local name_arg=$1
# if there's an argument we look up the value
- if [[ ! -z $name_arg ]]
+ if [[ -n $name_arg ]]
then
if [[ -z $points[$name_arg] ]]
then
- wd_print_msg $WD_BLUE "No warp point named $name_arg"
+ wd_print_msg "$WD_BLUE" "No warp point named $name_arg"
else
- wd_print_msg $WD_GREEN "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]"
+ wd_print_msg "$WD_GREEN" "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]"
fi
else
# hax to create a local empty array
@@ -290,19 +291,19 @@ wd_show()
wd_matches=()
# do a reverse lookup to check whether PWD is in $points
PWD="${PWD/$HOME/~}"
- if [[ ${points[(r)$PWD]} == $PWD ]]
+ if [[ ${points[(r)$PWD]} == "$PWD" ]]
then
for name in ${(k)points}
do
- if [[ $points[$name] == $PWD ]]
+ if [[ $points[$name] == "$PWD" ]]
then
wd_matches[$(($#wd_matches+1))]=$name
fi
done
- wd_print_msg $WD_BLUE "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
+ wd_print_msg "$WD_BLUE" "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
else
- wd_print_msg $WD_YELLOW "No warp point to $(echo $PWD | sed "s:$HOME:~:")"
+ wd_print_msg "$WD_YELLOW" "No warp point to $(echo "$PWD" | sed "s:$HOME:~:")"
fi
fi
}
@@ -312,7 +313,7 @@ wd_clean() {
local count=0
local wd_tmp=""
- while read line
+ while read -r line
do
if [[ $line != "" ]]
then
@@ -322,32 +323,32 @@ wd_clean() {
if [ -d "${val/#\~/$HOME}" ]
then
- wd_tmp=$wd_tmp"\n"`echo $line`
+ wd_tmp=$wd_tmp"\n"`echo "$line"`
else
- wd_print_msg $WD_YELLOW "Nonexistent directory: ${key} -> ${val}"
+ wd_print_msg "$WD_YELLOW" "Nonexistent directory: ${key} -> ${val}"
count=$((count+1))
fi
fi
- done < $WD_CONFIG
+ done < "$WD_CONFIG"
if [[ $count -eq 0 ]]
then
- wd_print_msg $WD_BLUE "No warp points to clean, carry on!"
+ wd_print_msg "$WD_BLUE" "No warp points to clean, carry on!"
else
- if $force || wd_yesorno "Removing ${count} warp points. Continue? (Y/n)"
+ if [ ! -z "$force" ] || wd_yesorno "Removing ${count} warp points. Continue? (y/n)"
then
- echo $wd_tmp >! $WD_CONFIG
- wd_print_msg $WD_GREEN "Cleanup complete. ${count} warp point(s) removed"
+ echo "$wd_tmp" >! "$WD_CONFIG"
+ wd_print_msg "$WD_GREEN" "Cleanup complete. ${count} warp point(s) removed"
else
- wd_print_msg $WD_BLUE "Cleanup aborted"
+ wd_print_msg "$WD_BLUE" "Cleanup aborted"
fi
fi
}
wd_export_static_named_directories() {
- if [[ -z $WD_SKIP_EXPORT ]]
+ if [[ ! -z $WD_EXPORT ]]
then
- command grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read warpdir ; do
+ command grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read -r warpdir ; do
hash -d "$warpdir"
done
fi
@@ -366,7 +367,8 @@ zparseopts -D -E \
c:=wd_alt_config -config:=wd_alt_config \
q=wd_quiet_mode -quiet=wd_quiet_mode \
v=wd_print_version -version=wd_print_version \
- d=wd_debug_mode -debug=wd_debug_mode
+ d=wd_debug_mode -debug=wd_debug_mode \
+ f=wd_force_mode -force=wd_force_mode
if [[ ! -z $wd_print_version ]]
then
@@ -379,10 +381,10 @@ then
fi
# check if config file exists
-if [ ! -e $WD_CONFIG ]
+if [ ! -e "$WD_CONFIG" ]
then
# if not, create config file
- touch $WD_CONFIG
+ touch "$WD_CONFIG"
else
wd_export_static_named_directories
fi
@@ -397,25 +399,24 @@ do
val=${(j,:,)arr[2,-1]}
points[$key]=$val
-done < $WD_CONFIG
+done < "$WD_CONFIG"
# get opts
-args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,list,ls:,path:,help,show -- $*)
+args=$(getopt -o a:r:c:lhs -l add:,rm:,clean,list,ls:,path:,help,show -- $*)
# check if no arguments were given, and that version is not set
if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]]
then
wd_print_usage
- # check if config file is writeable
-elif [ ! -w $WD_CONFIG ]
+# check if config file is writeable
+elif [ ! -w "$WD_CONFIG" ]
then
# do nothing
# can't run `exit`, as this would exit the executing shell
wd_exit_fail "\'$WD_CONFIG\' is not writeable."
else
-
# parse rest of options
local wd_o
for wd_o
@@ -423,11 +424,7 @@ else
case "$wd_o"
in
"-a"|"--add"|"add")
- wd_add false $2
- break
- ;;
- "-a!"|"--add!"|"add!")
- wd_add true $2
+ wd_add "$2" "$wd_force_mode"
break
;;
"-e"|"export")
@@ -435,10 +432,8 @@ else
break
;;
"-r"|"--remove"|"rm")
- # Loop over all arguments after "rm", separated by whitespace
- for pointname in "${@:2}" ; do
- wd_remove $pointname
- done
+ # Passes all the arguments as a single string separated by whitespace to wd_remove
+ wd_remove "${@:2}"
break
;;
"-l"|"list")
@@ -446,11 +441,11 @@ else
break
;;
"-ls"|"ls")
- wd_ls $2
+ wd_ls "$2"
break
;;
"-p"|"--path"|"path")
- wd_path $2
+ wd_path "$2"
break
;;
"-h"|"--help"|"help")
@@ -458,19 +453,15 @@ else
break
;;
"-s"|"--show"|"show")
- wd_show $2
+ wd_show "$2"
break
;;
"-c"|"--clean"|"clean")
- wd_clean false
- break
- ;;
- "-c!"|"--clean!"|"clean!")
- wd_clean true
+ wd_clean "$wd_force_mode"
break
;;
*)
- wd_warp $wd_o $2
+ wd_warp "$wd_o" "$2"
break
;;
--)
@@ -502,7 +493,7 @@ unset args
unset points
unset val &> /dev/null # fixes issue #1
-if [[ ! -z $wd_debug_mode ]]
+if [[ -n $wd_debug_mode ]]
then
exit $WD_EXIT_CODE
else
diff --git a/plugins/z/README b/plugins/z/README
index 56261cff4..47e54c57a 100644
--- a/plugins/z/README
+++ b/plugins/z/README
@@ -23,6 +23,8 @@ DESCRIPTION
OPTIONS
-c restrict matches to subdirectories of the current directory
+ -e echo the best match, don't cd
+
-h show a brief help message
-l list only
@@ -57,6 +59,8 @@ NOTES
Optionally:
Set $_Z_CMD to change the command name (default z).
Set $_Z_DATA to change the datafile (default $HOME/.z).
+ Set $_Z_MAX_SCORE lower to age entries out faster (default
+ 9000).
Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
self.
@@ -64,8 +68,8 @@ NOTES
Set $_Z_OWNER to allow usage when in 'sudo -s' mode.
(These settings should go in .bashrc/.zshrc before the line
added above.)
- Install the provided man page z.1 somewhere like
- /usr/local/man/man1.
+ Install the provided man page z.1 somewhere in your MANPATH,
+ like /usr/local/man/man1.
Aging:
The rank of directories maintained by z undergoes aging based on a sim-
diff --git a/plugins/z/z.1 b/plugins/z/z.1
index d4cac1ac2..182f98176 100644
--- a/plugins/z/z.1
+++ b/plugins/z/z.1
@@ -78,6 +78,9 @@ Set \fB$_Z_CMD\fR to change the command name (default \fBz\fR).
Set \fB$_Z_DATA\fR to change the datafile (default \fB$HOME/.z\fR).
.RE
.RS
+Set \fB$_Z_MAX_SCORE\fR lower to age entries out faster (default \fB9000\fR).
+.RE
+.RS
Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution.
.RE
.RS
diff --git a/plugins/z/z.sh b/plugins/z/z.sh
index 5c5771d62..13008a60e 100644
--- a/plugins/z/z.sh
+++ b/plugins/z/z.sh
@@ -10,6 +10,7 @@
# * optionally:
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
+# set $_Z_MAX_SCORE lower to age entries out faster (default 9000).
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
@@ -23,6 +24,8 @@
# * z -l foo # list matches instead of cd
# * z -e foo # echo the best match, don't cd
# * z -c foo # restrict matches to subdirs of $PWD
+# * z -x # remove the current directory from the datafile
+# * z -h # show a brief help message
[ -d "${_Z_DATA:-$HOME/.z}" ] && {
echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory."
@@ -62,7 +65,8 @@ _z() {
# maintain the data file
local tempfile="$datafile.$RANDOM"
- _z_dirs | awk -v path="$*" -v now="$(date +%s)" -F"|" '
+ local score=${_Z_MAX_SCORE:-9000}
+ _z_dirs | awk -v path="$*" -v now="$(date +%s)" -v score=$score -F"|" '
BEGIN {
rank[path] = 1
time[path] = now
@@ -79,7 +83,7 @@ _z() {
count += $2
}
END {
- if( count > 9000 ) {
+ if( count > score ) {
# aging
for( x in rank ) print x "|" 0.99*rank[x] "|" time[x]
} else for( x in rank ) print x "|" rank[x] "|" time[x]
@@ -138,27 +142,24 @@ _z() {
local cd
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
function frecent(rank, time) {
- # relate frequency and time
- dx = t - time
- if( dx < 3600 ) return rank * 4
- if( dx < 86400 ) return rank * 2
- if( dx < 604800 ) return rank / 2
- return rank / 4
+ # relate frequency and time
+ dx = t - time
+ return int(10000 * rank * (3.75/((0.0001 * dx + 1) + 0.25)))
}
function output(matches, best_match, common) {
# list or return the desired directory
if( list ) {
- cmd = "sort -g >&2"
+ if( common ) {
+ printf "%-10s %s\n", "common:", common > "/dev/stderr"
+ }
+ cmd = "sort -n >&2"
for( x in matches ) {
if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd
}
}
- if( common ) {
- printf "%-10s %s\n", "common:", common > "/dev/stderr"
- }
} else {
- if( common ) best_match = common
+ if( common && !typ ) best_match = common
print best_match
}
}
@@ -200,15 +201,22 @@ _z() {
# prefer case sensitive
if( best_match ) {
output(matches, best_match, common(matches))
+ exit
} else if( ibest_match ) {
output(imatches, ibest_match, common(imatches))
+ exit
}
+ exit(1)
}
')"
- [ $? -eq 0 ] && [ "$cd" ] && {
- if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
- }
+ if [ "$?" -eq 0 ]; then
+ if [ "$cd" ]; then
+ if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
+ fi
+ else
+ return $?
+ fi
fi
}
@@ -223,15 +231,11 @@ if type compctl >/dev/null 2>&1; then
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
_z_precmd() {
(_z --add "${PWD:a}" &)
- # Reference $RANDOM to refresh its value inside the subshell
- # Otherwise, multiple runs get the same value
: $RANDOM
}
else
_z_precmd() {
(_z --add "${PWD:A}" &)
- # Reference $RANDOM to refresh its value inside the subshell
- # Otherwise, multiple runs get the same value
: $RANDOM
}
fi
diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh
index 83f8da733..0d29a7ce3 100644
--- a/plugins/zsh_reload/zsh_reload.plugin.zsh
+++ b/plugins/zsh_reload/zsh_reload.plugin.zsh
@@ -7,6 +7,16 @@ src() {
zrecompile -p $f && command rm -f $f.zwc.old
done
- # Use $SHELL if available; remove leading dash if login shell
- [[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
+ # 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
}
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index b0a3b7b3f..99707f684 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -131,7 +131,7 @@ prompt_git() {
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '✚'
- zstyle ':vcs_info:*' unstagedstr '●'
+ zstyle ':vcs_info:*' unstagedstr '±'
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
@@ -235,7 +235,7 @@ prompt_status() {
# ends in '-prod'
# - displays black on green otherwise
prompt_aws() {
- [[ -z "$AWS_PROFILE" ]] && return
+ [[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return
case "$AWS_PROFILE" in
*-prod|*production*) prompt_segment red yellow "AWS: $AWS_PROFILE" ;;
*) prompt_segment green black "AWS: $AWS_PROFILE" ;;
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index 05b3fb212..921ed99d3 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -7,9 +7,9 @@ typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
-%{%(!.%F{red}.%F{white})%}▶%{$reset_color%} '
+%{%(!.${fg[red]}.${fg[white]})%}▶%{$reset_color%} '
-PROMPT2='%{%(!.%F{red}.%F{white})%}◀%{$reset_color%} '
+PROMPT2='%{%(!.${fg[red]}.${fg[white]})%}◀%{$reset_color%} '
RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
diff --git a/themes/fino.zsh-theme b/themes/fino.zsh-theme
index 1d8bb30e1..2523c1776 100644
--- a/themes/fino.zsh-theme
+++ b/themes/fino.zsh-theme
@@ -11,26 +11,35 @@
#
# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
+function virtualenv_prompt_info {
+ [[ -n ${VIRTUAL_ENV} ]] || return
+ echo "${ZSH_THEME_VIRTUALENV_PREFIX:=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX:=]}"
+}
+
function prompt_char {
- git branch >/dev/null 2>/dev/null && echo "±" && return
- echo '○'
+ command git branch &>/dev/null && echo "±" || echo '○'
}
function box_name {
- [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
+ [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
}
-local ruby_env='using%{$FG[243]%} $(ruby_prompt_info)'
+local ruby_env='$(ruby_prompt_info)'
local git_info='$(git_prompt_info)'
+local virtualenv_info='$(virtualenv_prompt_info)'
local prompt_char='$(prompt_char)'
-
-PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}%~%{$reset_color%}${git_info} %{$FG[239]%}${ruby_env}
+PROMPT="╭─${FG[040]}%n ${FG[239]}at ${FG[033]}$(box_name) ${FG[239]}in %B${FG[226]}%~%b${git_info}${ruby_env}${virtualenv_info}
╰─${prompt_char}%{$reset_color%} "
-ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}"
+ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[239]}on%{$reset_color%} ${FG[255]}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘✘✘"
-ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%}✔"
-ZSH_THEME_RUBY_PROMPT_PREFIX="‹"
+ZSH_THEME_GIT_PROMPT_DIRTY="${FG[202]}✘✘✘"
+ZSH_THEME_GIT_PROMPT_CLEAN="${FG[040]}✔"
+
+ZSH_THEME_RUBY_PROMPT_PREFIX=" ${FG[239]}using${FG[243]} ‹"
ZSH_THEME_RUBY_PROMPT_SUFFIX="›%{$reset_color%}"
+
+export VIRTUAL_ENV_DISABLE_PROMPT=1
+ZSH_THEME_VIRTUALENV_PREFIX=" ${FG[239]}using${FG[243]} «"
+ZSH_THEME_VIRTUALENV_SUFFIX="»%{$reset_color%}"
diff --git a/themes/fishy.zsh-theme b/themes/fishy.zsh-theme
index 00a60f45b..2b8d559e5 100644
--- a/themes/fishy.zsh-theme
+++ b/themes/fishy.zsh-theme
@@ -1,12 +1,18 @@
# ZSH Theme emulating the Fish shell's default prompt.
_fishy_collapsed_wd() {
- echo $(pwd | perl -pe '
- BEGIN {
- binmode STDIN, ":encoding(UTF-8)";
- binmode STDOUT, ":encoding(UTF-8)";
- }; s|^$ENV{HOME}|~|g; s|/([^/.])[^/]*(?=/)|/$1|g; s|/\.([^/])[^/]*(?=/)|/.$1|g
-')
+ local i pwd
+ pwd=("${(s:/:)PWD/#$HOME/~}")
+ if (( $#pwd > 1 )); then
+ for i in {1..$(($#pwd-1))}; do
+ if [[ "$pwd[$i]" = .* ]]; then
+ pwd[$i]="${${pwd[$i]}[1,2]}"
+ else
+ pwd[$i]="${${pwd[$i]}[1]}"
+ fi
+ done
+ fi
+ echo "${(j:/:)pwd}"
}
local user_color='green'; [ $UID -eq 0 ] && user_color='red'
diff --git a/themes/pygmalion-virtualenv.zsh-theme b/themes/pygmalion-virtualenv.zsh-theme
index 605e3d10c..47b0b4fb1 100644
--- a/themes/pygmalion-virtualenv.zsh-theme
+++ b/themes/pygmalion-virtualenv.zsh-theme
@@ -17,6 +17,8 @@ function _virtualenv_prompt_info {
}
prompt_setup_pygmalion(){
+ setopt localoptions extendedglob
+
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
@@ -25,16 +27,18 @@ prompt_setup_pygmalion(){
base_prompt='$(_virtualenv_prompt_info)%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
- base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
- post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
+ base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
+ post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
autoload -U add-zsh-hook
add-zsh-hook precmd prompt_pygmalion_precmd
}
prompt_pygmalion_precmd(){
+ setopt localoptions extendedglob
+
local gitinfo=$(git_prompt_info)
- local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
+ local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
local prompt_length=${#exp_nocolor}
diff --git a/themes/pygmalion.zsh-theme b/themes/pygmalion.zsh-theme
index bd58db5f6..b13adfd5f 100644
--- a/themes/pygmalion.zsh-theme
+++ b/themes/pygmalion.zsh-theme
@@ -1,6 +1,8 @@
# Yay! High voltage and arrows!
prompt_setup_pygmalion(){
+ setopt localoptions extendedglob
+
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
@@ -9,16 +11,18 @@ prompt_setup_pygmalion(){
base_prompt='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
- base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
- post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
+ base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
+ post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
autoload -U add-zsh-hook
add-zsh-hook precmd prompt_pygmalion_precmd
}
prompt_pygmalion_precmd(){
+ setopt localoptions extendedglob
+
local gitinfo=$(git_prompt_info)
- local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
+ local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
local prompt_length=${#exp_nocolor}
diff --git a/themes/random.zsh-theme b/themes/random.zsh-theme
index 6cb7cc579..f0b8e5c18 100644
--- a/themes/random.zsh-theme
+++ b/themes/random.zsh-theme
@@ -1,3 +1,10 @@
+# Deprecate ZSH_THEME_RANDOM_BLACKLIST
+if [[ -n "$ZSH_THEME_RANDOM_BLACKLIST" ]]; then
+ echo '[oh-my-zsh] ZSH_THEME_RANDOM_BLACKLIST is deprecated. Use `ZSH_THEME_RANDOM_IGNORED` instead.'
+ ZSH_THEME_RANDOM_IGNORED=($ZSH_THEME_RANDOM_BLACKLIST)
+ unset ZSH_THEME_RANDOM_BLACKLIST
+fi
+
# Make themes a unique array
typeset -Ua themes
@@ -11,8 +18,8 @@ else
"$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r)
"$ZSH"/themes/*.zsh-theme(N:t:r)
)
- # Remove blacklisted themes from the list
- for theme in random ${ZSH_THEME_RANDOM_BLACKLIST[@]}; do
+ # Remove ignored themes from the list
+ for theme in random ${ZSH_THEME_RANDOM_IGNORED[@]}; do
themes=("${(@)themes:#$theme}")
done
fi
@@ -35,4 +42,6 @@ else
return 1
fi
-echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"
+if [[ -z "$ZSH_THEME_RANDOM_QUIET" ]]; then
+ echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"
+fi
diff --git a/themes/trapd00r.zsh-theme b/themes/trapd00r.zsh-theme
index 7a589a699..4e3238393 100644
--- a/themes/trapd00r.zsh-theme
+++ b/themes/trapd00r.zsh-theme
@@ -2,7 +2,7 @@
#
# This theme needs a terminal supporting 256 colors as well as unicode.
# In order to avoid external dependencies, it also has a zsh version of
-# the perl script at https://github.com/trapd00r/utils/blob/master/zsh_path,
+# the previously used perl script https://github.com/trapd00r/utils/blob/master/zsh_path,
# which splits up the current path and makes it fancy.
#
# By default it spans over two lines like so:
diff --git a/tools/install.sh b/tools/install.sh
index 8a93708ca..61b21cb9e 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -2,8 +2,10 @@
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
-# or wget:
+# or via wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
+# or via fetch:
+# sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#
# As an alternative, you can first download the install script and run it afterwards:
# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
@@ -30,6 +32,8 @@
# --keep-zshrc: sets KEEP_ZSHRC to 'yes'
# For example:
# sh install.sh --unattended
+# or:
+# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
#
set -e
@@ -53,6 +57,10 @@ error() {
echo ${RED}"Error: $@"${RESET} >&2
}
+underline() {
+ echo "$(printf '\033[4m')$@$(printf '\033[24m')"
+}
+
setup_color() {
# Only use colors if connected to a terminal
if [ -t 1 ]; then
@@ -269,11 +277,13 @@ main() {
/____/ ....is now installed!
+ EOF
+ cat <<-EOF
Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.
- • Follow us on Twitter: https://twitter.com/ohmyzsh
- • Join our Discord server: https://discord.gg/ohmyzsh
- • Get stickers, shirts, coffee mugs and other swag: https://shop.planetargon.com/collections/oh-my-zsh
+ • Follow us on Twitter: $(underline https://twitter.com/ohmyzsh)
+ • Join our Discord server: $(underline https://discord.gg/ohmyzsh)
+ • Get stickers, shirts, coffee mugs and other swag: $(underline https://shop.planetargon.com/collections/oh-my-zsh)
EOF
printf "$RESET"
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index de7a8419b..e005519d6 100644
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -14,6 +14,7 @@ if [ -t 1 ]; then
YELLOW=$(printf '\033[33m')
BLUE=$(printf '\033[34m')
BOLD=$(printf '\033[1m')
+ UNDER=$(printf '\033[4m')
RESET=$(printf '\033[m')
else
RB_RED=""
@@ -28,6 +29,7 @@ else
GREEN=""
YELLOW=""
BLUE=""
+ UNDER=""
BOLD=""
RESET=""
fi
@@ -62,10 +64,11 @@ then
printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
printf '%s %s %s %s /____/ %s %s %s %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
- printf "${BLUE}${BOLD}%s${RESET}\n" "To keep up on the latest news and updates, follow us on Twitter: https://twitter.com/ohmyzsh"
- printf "${BLUE}${BOLD}%s${RESET}\n" "Want to get involved in the community? Join our Discord: https://discord.gg/ohmyzsh"
- printf "${BLUE}${BOLD}%s${RESET}\n" "Get your Oh My Zsh swag at: https://shop.planetargon.com/collections/oh-my-zsh"
+ printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "To keep up on 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"
else
+ status=$?
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
fi
@@ -74,3 +77,6 @@ case "$resetAutoStash" in
"") git config --unset rebase.autoStash ;;
*) git config rebase.autoStash "$resetAutoStash" ;;
esac
+
+# Exit with `1` if the update failed
+exit $status