summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2020-02-12 18:07:38 -0700
committerTuowen Zhao <ztuowen@gmail.com>2020-02-12 18:07:38 -0700
commit93a2003db7738e2255a4589ef2073df1be34fe02 (patch)
treec2f6b378ffae6d4f433acf2a1931d1cc1f3f0574
parent891ef3d57b6d5e38e10c0894c3d956416adc95e2 (diff)
parenta6df94d2c677c6d28c5ee339975b7a56a2f67e21 (diff)
downloadzsh-93a2003db7738e2255a4589ef2073df1be34fe02.tar.gz
zsh-93a2003db7738e2255a4589ef2073df1be34fe02.tar.bz2
zsh-93a2003db7738e2255a4589ef2073df1be34fe02.zip
Merge branch 'master' of https://github.com/ohmyzsh/ohmyzsh
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md32
-rw-r--r--.github/ISSUE_TEMPLATE/feature_request.md10
-rw-r--r--.github/ISSUE_TEMPLATE/support.md2
-rw-r--r--.github/PULL_REQUEST_TEMPLATE.md17
-rw-r--r--.github/workflows/main.yml36
-rw-r--r--README.md1
-rw-r--r--lib/clipboard.zsh4
-rw-r--r--lib/completion.zsh3
-rw-r--r--lib/git.zsh9
-rw-r--r--oh-my-zsh.sh4
-rw-r--r--plugins/aws/aws.plugin.zsh3
-rw-r--r--plugins/battery/battery.plugin.zsh165
-rw-r--r--plugins/colored-man-pages/colored-man-pages.plugin.zsh2
-rw-r--r--plugins/common-aliases/common-aliases.plugin.zsh1
-rw-r--r--plugins/dotenv/dotenv.plugin.zsh7
-rw-r--r--plugins/dotnet/README.md20
-rw-r--r--plugins/dotnet/dotnet.plugin.zsh2
-rw-r--r--plugins/gradle/gradle.plugin.zsh2
-rw-r--r--plugins/jump/README.md12
-rw-r--r--plugins/jump/jump.plugin.zsh31
-rw-r--r--plugins/kube-ps1/README.md2
-rw-r--r--plugins/lol/README.md4
-rw-r--r--plugins/systemadmin/systemadmin.plugin.zsh4
-rw-r--r--plugins/systemd/systemd.plugin.zsh65
-rw-r--r--plugins/vagrant/_vagrant4
-rw-r--r--plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh57
-rw-r--r--plugins/vscode/README.md12
-rw-r--r--plugins/vscode/vscode.plugin.zsh14
-rw-r--r--plugins/yarn/_yarn8
-rw-r--r--plugins/zsh-interactive-cd/README.md23
-rw-r--r--plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh147
-rw-r--r--themes/af-magic.zsh-theme4
-rw-r--r--themes/candy-kingdom.zsh-theme24
-rw-r--r--themes/kiwi.zsh-theme4
34 files changed, 518 insertions, 217 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 076c35544..7c1cb8967 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,6 +1,7 @@
---
name: Bug report
-about: Create a report to help us improve
+about: Create a report to help us improve Oh My Zsh
+labels: 'Type: support'
---
@@ -10,29 +11,26 @@ an issue where no sections have been filled will be deleted without comment.
-->
**Describe the bug**
-<!-- A clear and concise description of what the bug is. -->
+A clear description of what the bug is.
**To Reproduce**
-<!--
-Steps to reproduce the behavior:
-1. Enable plugin '...'
-2. Run command '...', _or_ try to complete command '...', _etc._
+Steps to reproduce the behavior, for example:
+1. Enable this plugin '...'
+2. Run command '...' or try the autocomplete command '...'
3. See error
--->
**Expected behavior**
-<!-- A clear and concise description of what you expected to happen. -->
+A brief description of what should happen.
-**Screenshots or recordings**
-<!--
-If applicable, add screenshots or record an asciinema session (https://asciinema.org/)
-to help explain your problem.
--->
+**Screenshots and/or Recordings**
+If applicable, add screenshots to help explain your problem.
+You can also record an asciinema session: https://asciinema.org/
-**System:**
- - OS: [e.g. macOS]
- - Zsh version [e.g. 5.6]
+**Desktop (please complete the following information):**
+ - OS / Distro: [e.g. Arch Linux, macOS]
+ - Latest ohmyzsh Update?: [e.g. Yes/No]
+ - ZSH Version: [e.g. 5.6]
- Terminal emulator [e.g. iTerm2]
**Additional context**
-<!-- Add any other context about the problem here. -->
+Add any other context about the problem here. This can be themes, plugins, custom configs.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index d9c324a55..346eabaea 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -11,16 +11,16 @@ an issue where no sections have been filled will be deleted without comment.
-->
**Is your feature request related to a particular plugin or theme? If so, specify it.**
-<!-- The name of the plugin or theme you'd like us to improve. -->
+The name of the plugin or theme that you would like us to improve. [...]
**Is your feature request related to a problem? Please describe.**
-<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
+A description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
-<!-- A clear and concise description of what you want to happen. -->
+A description of what you want to happen.
**Describe alternatives you've considered**
-<!-- A clear and concise description of any alternative solutions or features you've considered. -->
+A description of any alternative solutions or features you've considered. This can also include other plugins or aliases.
**Additional context**
-<!-- Add any other context or screenshots about the feature request here. -->
+Add any other context or screenshots about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
diff --git a/.github/ISSUE_TEMPLATE/support.md b/.github/ISSUE_TEMPLATE/support.md
index 3c69a7d5e..d2638412e 100644
--- a/.github/ISSUE_TEMPLATE/support.md
+++ b/.github/ISSUE_TEMPLATE/support.md
@@ -5,8 +5,6 @@ labels: 'Type: support'
---
-<!--
1. Look for similar issues already posted (including closed ones)
2. Include as much relevant information as possible
3. Try to make sure the issue is due to Oh My Zsh
--->
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..6bcb90efe
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,17 @@
+## Standards checklist:
+
+- [ ] The PR title is descriptive.
+- [ ] The PR doesn't replicate another PR which is already open.
+- [ ] I have read the contribution guide and followed all the instructions.
+- [ ] The code follows the code style guide detailed in the wiki.
+- [ ] The code is mine or it's from somewhere with an MIT-compatible license.
+- [ ] The code is efficient, to the best of my ability, and does not waste computer resources.
+- [ ] The code is stable and I have tested it myself, to the best of my abilities.
+
+## Changes:
+
+- [...]
+
+## Other comments:
+
+...
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 000000000..7ab7efdd6
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,36 @@
+name: CI
+on:
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ branches:
+ - master
+ push:
+ branches:
+ - master
+
+jobs:
+ tests:
+ name: Run tests
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest]
+ steps:
+ - name: Set up git repository
+ uses: actions/checkout@v2
+ - name: Install zsh
+ if: runner.os == 'Linux'
+ run: sudo apt-get update; sudo apt-get install zsh
+ - name: Test installer
+ run: sh ./tools/install.sh
+ - name: Check syntax
+ run: |
+ for file in ./oh-my-zsh.sh \
+ ./lib/*.zsh \
+ ./plugins/*/*.plugin.zsh \
+ ./plugins/*/_* \
+ ./themes/*.zsh-theme; do
+ zsh -n "$file" || return 1
+ done
diff --git a/README.md b/README.md
index 291fb512b..187cceb7d 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ Finally, you'll begin to get the sort of attention that you have always felt you
To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on Discord.
+[![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)
[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/bpXWhnN)
diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh
index 2c93d1bb5..5bba11d16 100644
--- a/lib/clipboard.zsh
+++ b/lib/clipboard.zsh
@@ -24,7 +24,7 @@ function clipcopy() {
else
cat $file | pbcopy
fi
- elif [[ $OSTYPE == cygwin* ]]; then
+ elif [[ $OSTYPE == (cygwin|msys)* ]]; then
if [[ -z $file ]]; then
cat > /dev/clipboard
else
@@ -71,7 +71,7 @@ function clippaste() {
emulate -L zsh
if [[ $OSTYPE == darwin* ]]; then
pbpaste
- elif [[ $OSTYPE == cygwin* ]]; then
+ elif [[ $OSTYPE == (cygwin|msys)* ]]; then
cat /dev/clipboard
else
if (( $+commands[xclip] )); then
diff --git a/lib/completion.zsh b/lib/completion.zsh
index c7db2eb7b..c932bc925 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -71,3 +71,6 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
fi
+
+# automatically load bash completion functions
+autoload -Uz bashcompinit && bashcompinit
diff --git a/lib/git.zsh b/lib/git.zsh
index 2054fe272..00cb00b19 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -199,3 +199,12 @@ function git_current_user_name() {
function git_current_user_email() {
command git config user.email 2>/dev/null
}
+
+# Output the name of the root directory of the git repository
+# Usage example: $(git_repo_name)
+function git_repo_name() {
+ local repo_path
+ if repo_path="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
+ echo ${repo_path:t}
+ fi
+}
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 6b2662d5e..c3fae6efb 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -32,8 +32,8 @@ fi
is_plugin() {
local base_dir=$1
local name=$2
- test -f $base_dir/plugins/$name/$name.plugin.zsh \
- || test -f $base_dir/plugins/$name/_$name
+ builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \
+ || builtin test -f $base_dir/plugins/$name/_$name
}
# Add all defined plugins to fpath. This must be done
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh
index 231ac5ad2..567311372 100644
--- a/plugins/aws/aws.plugin.zsh
+++ b/plugins/aws/aws.plugin.zsh
@@ -10,7 +10,8 @@ function asp() {
return
fi
- local available_profiles=($(aws_profiles))
+ local -a available_profiles
+ available_profiles=($(aws_profiles))
if [[ -z "${available_profiles[(r)$1]}" ]]; then
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
index 6b6684716..6fe801c9f 100644
--- a/plugins/battery/battery.plugin.zsh
+++ b/plugins/battery/battery.plugin.zsh
@@ -11,22 +11,21 @@
# Modified to add support for FreeBSD #
###########################################
-if [[ "$OSTYPE" = darwin* ]] ; then
+if [[ "$OSTYPE" = darwin* ]]; then
- function battery_pct() {
- local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
- typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
- typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
- integer i=$(((currentcapacity/maxcapacity) * 100))
- echo $i
+ function battery_is_charging() {
+ ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
}
- function plugged_in() {
- [ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ]
+ function battery_pct() {
+ local smart_battery_status="$(ioreg -rc AppleSmartBattery)"
+ local -F maxcapacity=$(command grep '^.*"MaxCapacity"\ =\ ' <<< $smart_battery_status | sed -e 's/^.*"MaxCapacity"\ =\ //')
+ local -F currentcapacity=$(command grep '^.*"CurrentCapacity"\ =\ ' <<< $smart_battery_status | sed -e 's/^.*CurrentCapacity"\ =\ //')
+ echo $(( (currentcapacity/maxcapacity) * 100 ))
}
function battery_pct_remaining() {
- if plugged_in ; then
+ if battery_is_charging; then
echo "External Power"
else
battery_pct
@@ -35,9 +34,9 @@ if [[ "$OSTYPE" = darwin* ]] ; then
function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
- if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
- timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
- if [ $timeremaining -gt 720 ] ; then
+ if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
+ timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
+ if [ $timeremaining -gt 720 ]; then
echo "::"
else
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
@@ -48,11 +47,11 @@ if [[ "$OSTYPE" = darwin* ]] ; then
}
function battery_pct_prompt () {
- if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
+ if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
b=$(battery_pct_remaining)
- if [ $b -gt 50 ] ; then
+ if [[ $b -gt 50 ]]; then
color='green'
- elif [ $b -gt 20 ] ; then
+ elif [[ $b -gt 20 ]]; then
color='yellow'
else
color='red'
@@ -63,24 +62,20 @@ if [[ "$OSTYPE" = darwin* ]] ; then
fi
}
- function battery_is_charging() {
- [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
- }
-
-elif [[ "$OSTYPE" = freebsd* ]] ; then
+elif [[ "$OSTYPE" = freebsd* ]]; then
function battery_is_charging() {
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
}
function battery_pct() {
- if (( $+commands[sysctl] )) ; then
- echo "$(sysctl -n hw.acpi.battery.life)"
+ if (( $+commands[sysctl] )); then
+ sysctl -n hw.acpi.battery.life
fi
}
function battery_pct_remaining() {
- if [ ! $(battery_is_charging) ] ; then
+ if ! battery_is_charging; then
battery_pct
else
echo "External Power"
@@ -88,45 +83,46 @@ elif [[ "$OSTYPE" = freebsd* ]] ; then
}
function battery_time_remaining() {
+ local remaining_time
remaining_time=$(sysctl -n hw.acpi.battery.time)
- if [[ $remaining_time -ge 0 ]] ; then
- # calculation from https://www.unix.com/shell-programming-and-scripting/23695-convert-minutes-hours-minutes-seconds.html
- ((hour=$remaining_time/60))
- ((minute=$remaining_time-$hour*60))
- echo $hour:$minute
+ if [[ $remaining_time -ge 0 ]]; then
+ ((hour = $remaining_time / 60 ))
+ ((minute = $remaining_time % 60 ))
+ printf %02d:%02d $hour $minute
fi
}
function battery_pct_prompt() {
+ local b color
b=$(battery_pct_remaining)
- if [ ! $(battery_is_charging) ] ; then
- if [ $b -gt 50 ] ; then
+ if battery_is_charging; then
+ echo "∞"
+ else
+ if [[ $b -gt 50 ]]; then
color='green'
- elif [ $b -gt 20 ] ; then
+ elif [[ $b -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
- else
- echo "∞"
fi
}
-elif [[ "$OSTYPE" = linux* ]] ; then
+elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
- ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
+ ! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
}
function battery_pct() {
- if (( $+commands[acpi] )) ; then
- echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')"
+ if (( $+commands[acpi] )); then
+ acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]'
fi
}
function battery_pct_remaining() {
- if [ ! $(battery_is_charging) ] ; then
+ if ! battery_is_charging; then
battery_pct
else
echo "External Power"
@@ -134,76 +130,81 @@ elif [[ "$OSTYPE" = linux* ]] ; then
}
function battery_time_remaining() {
- if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
- echo $(acpi 2>/dev/null | cut -f3 -d ',')
+ if ! battery_is_charging; then
+ acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
}
function battery_pct_prompt() {
- b=$(battery_pct_remaining)
- if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
- if [ $b -gt 50 ] ; then
+ local b color
+ b=$(battery_pct_remaining)
+ if battery_is_charging; then
+ echo "∞"
+ else
+ if [[ $b -gt 50 ]]; then
color='green'
- elif [ $b -gt 20 ] ; then
+ elif [[ $b -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
- else
- echo "∞"
fi
}
else
# Empty functions so we don't cause errors in prompts
- function battery_pct_remaining() {
- }
-
- function battery_time_remaining() {
- }
-
- function battery_pct_prompt() {
- }
+ function battery_is_charging { false }
+ function battery_pct \
+ battery_pct_remaining \
+ battery_time_remaining \
+ battery_pct_prompt { }
fi
function battery_level_gauge() {
- local gauge_slots=${BATTERY_GAUGE_SLOTS:-10};
- local green_threshold=${BATTERY_GREEN_THRESHOLD:-6};
- local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4};
- local color_green=${BATTERY_COLOR_GREEN:-%F{green}};
- local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}};
- local color_red=${BATTERY_COLOR_RED:-%F{red}};
- local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}};
- local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['};
- local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'};
- local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'};
- local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'};
- local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow};
- local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'};
-
- local battery_remaining_percentage=$(battery_pct);
+ local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}
+ local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}
+ local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}
+ local color_green=${BATTERY_COLOR_GREEN:-%F{green}}
+ local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}
+ local color_red=${BATTERY_COLOR_RED:-%F{red}}
+ local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}
+ local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}
+ local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}
+ local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}
+ local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}
+ local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
+ local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
+
+ local battery_remaining_percentage=$(battery_pct)
+ local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
- local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots)));
- local empty=$(($gauge_slots - $filled));
+ filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 ))
+ empty=$(( $gauge_slots - $filled ))
- if [[ $filled -gt $green_threshold ]]; then local gauge_color=$color_green;
- elif [[ $filled -gt $yellow_threshold ]]; then local gauge_color=$color_yellow;
- else local gauge_color=$color_red;
+ if [[ $filled -gt $green_threshold ]]; then
+ gauge_color=$color_green
+ elif [[ $filled -gt $yellow_threshold ]]; then
+ gauge_color=$color_yellow
+ else
+ gauge_color=$color_red
fi
else
- local filled=$gauge_slots;
- local empty=0;
- filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'};
+ filled=$gauge_slots
+ empty=0
+ filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}
fi
- local charging=' ' && battery_is_charging && charging=$charging_symbol;
+ local charging=' '
+ battery_is_charging && charging=$charging_symbol
+ # Charging status and prefix
printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%}
- printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
+ # Filled slots
+ [[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
+ # Empty slots
[[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty}
+ # Suffix
printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%}
}
-
-
diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
index ac6a94654..f74105d40 100644
--- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh
+++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
@@ -17,7 +17,7 @@ EOF
fi
function colored() {
- env \
+ command env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
index 785a09c63..ce1995c03 100644
--- a/plugins/common-aliases/common-aliases.plugin.zsh
+++ b/plugins/common-aliases/common-aliases.plugin.zsh
@@ -50,6 +50,7 @@ alias mv='mv -i'
# zsh is able to auto-do some kungfoo
# depends on the SUFFIX :)
+autoload -Uz is-at-least
if is-at-least 4.2.0; then
# open browser on urls
if [[ -n "$BROWSER" ]]; then
diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
index 89763d0ee..d4a6db8f8 100644
--- a/plugins/dotenv/dotenv.plugin.zsh
+++ b/plugins/dotenv/dotenv.plugin.zsh
@@ -1,5 +1,12 @@
source_env() {
if [[ -f $ZSH_DOTENV_FILE ]]; then
+ # confirm before sourcing .env file
+ local confirmation
+ echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) "
+ if read -k 1 confirmation && [[ $confirmation = [nN] ]]; then
+ return
+ fi
+
# test .env syntax
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
diff --git a/plugins/dotnet/README.md b/plugins/dotnet/README.md
index 7a6d6a995..a663fc88d 100644
--- a/plugins/dotnet/README.md
+++ b/plugins/dotnet/README.md
@@ -10,12 +10,14 @@ plugins=(... dotnet)
## Aliases
-| Alias | Command | Description |
-|-------|--------------|-------------------------------------------------------------------|
-| dn | dotnet new | Create a new .NET project or file. |
-| dr | dotnet run | Build and run a .NET project output. |
-| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. |
-| ds | dotnet sln | Modify Visual Studio solution files. |
-| da | dotnet add | Add a package or reference to a .NET project. |
-| dp | dotnet pack | Create a NuGet package. |
-| dng | dotnet nuget | Provides additional NuGet commands. | \ No newline at end of file
+| Alias | Command | Description |
+|-------|------------------|-------------------------------------------------------------------|
+| dn | dotnet new | Create a new .NET project or file. |
+| dr | dotnet run | Build and run a .NET project output. |
+| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. |
+| dw | dotnet watch | Watch for source file changes and restart the dotnet command. |
+| dwr | dotnet watch run | Watch for source file changes and restart the `run` command. |
+| ds | dotnet sln | Modify Visual Studio solution files. |
+| da | dotnet add | Add a package or reference to a .NET project. |
+| dp | dotnet pack | Create a NuGet package. |
+| dng | dotnet nuget | Provides additional NuGet commands. | \ No newline at end of file
diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh
index 8b9a45a97..ed6c68e5d 100644
--- a/plugins/dotnet/dotnet.plugin.zsh
+++ b/plugins/dotnet/dotnet.plugin.zsh
@@ -111,6 +111,8 @@ compdef _dotnet dotnet
# --------------------------------------------------------------------- #
alias dr='dotnet run'
alias dt='dotnet test'
+alias dw='dotnet watch'
+alias dwr='dotnet watch run'
alias ds='dotnet sln'
alias da='dotnet add'
alias dp='dotnet pack'
diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh
index 6be583179..c651b91ca 100644
--- a/plugins/gradle/gradle.plugin.zsh
+++ b/plugins/gradle/gradle.plugin.zsh
@@ -7,7 +7,7 @@ gradle-or-gradlew() {
echo "executing gradlew instead of gradle";
./gradlew "$@";
else
- gradle "$@";
+ command gradle "$@";
fi
}
diff --git a/plugins/jump/README.md b/plugins/jump/README.md
index ed6415289..1b0ce68c0 100644
--- a/plugins/jump/README.md
+++ b/plugins/jump/README.md
@@ -17,3 +17,15 @@ plugins=(... jump)
| `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided |
| `unmark <mark-name>` | Remove the given mark |
| `marks` | List the existing marks and the directories they point to |
+
+## Key bindings
+
+Pressing `CTRL`+`G` substitutes the written mark name for the full path of the mark.
+For example, with a mark named `mymark` pointing to `/path/to/my/mark`:
+```zsh
+$ cp /tmp/file mymark<C-g>
+```
+will become:
+```zsh
+$ cp /tmp/file /path/to/my/mark
+```
diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh
index d161a6da0..c2da1144e 100644
--- a/plugins/jump/jump.plugin.zsh
+++ b/plugins/jump/jump.plugin.zsh
@@ -9,33 +9,34 @@
export MARKPATH=$HOME/.marks
jump() {
- cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
+ builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
}
mark() {
- if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then
- MARK=$(basename "$PWD")
+ if [[ $# -eq 0 || "$1" = "." ]]; then
+ MARK=${PWD:t}
else
MARK="$1"
fi
- if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
- mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK"
+ if read -q "?Mark $PWD as ${MARK}? (y/n) "; then
+ command mkdir -p "$MARKPATH"
+ command ln -sfn "$PWD" "$MARKPATH/$MARK"
fi
}
unmark() {
- rm -i "$MARKPATH/$1"
+ LANG= command rm -i "$MARKPATH/$1"
}
marks() {
- local max=0
- for link in $MARKPATH/*(@); do
+ local link max=0
+ for link in $MARKPATH/{,.}*(@N); do
if [[ ${#link:t} -gt $max ]]; then
max=${#link:t}
fi
done
local printf_markname_template="$(printf -- "%%%us " "$max")"
- for link in $MARKPATH/*(@); do
+ for link in $MARKPATH/{,.}*(@N); do
local markname="$fg[cyan]${link:t}$reset_color"
local markpath="$fg[blue]$(readlink $link)$reset_color"
printf -- "$printf_markname_template" "$markname"
@@ -44,21 +45,15 @@ marks() {
}
_completemarks() {
- if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then
- reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g'))
- else
- if readlink -e "${MARKPATH}"/* &>/dev/null; then
- reply=($(ls "${MARKPATH}"))
- fi
- fi
+ reply=("${MARKPATH}"/{,.}*(@N:t))
}
compctl -K _completemarks jump
compctl -K _completemarks unmark
_mark_expansion() {
- setopt extendedglob
+ setopt localoptions extendedglob
autoload -U modify-current-argument
- modify-current-argument '$(readlink "$MARKPATH/$ARG")'
+ modify-current-argument '$(readlink "$MARKPATH/$ARG" || echo "$ARG")'
}
zle -N _mark_expansion
bindkey "^g" _mark_expansion
diff --git a/plugins/kube-ps1/README.md b/plugins/kube-ps1/README.md
index 82c0a77e6..fdc1a94e8 100644
--- a/plugins/kube-ps1/README.md
+++ b/plugins/kube-ps1/README.md
@@ -55,6 +55,8 @@ plugins=(
# After the "source Oh My Zsh" line
PROMPT=$PROMPT'$(kube_ps1) '
+# Or in double quotes, don't forget to escape
+PROMPT=$PROMPT"\$(kube_ps1) "
```
Note: The `PROMPT` example above was tested with the theme `robbyrussell`.
diff --git a/plugins/lol/README.md b/plugins/lol/README.md
index 8fba7b713..1791de493 100644
--- a/plugins/lol/README.md
+++ b/plugins/lol/README.md
@@ -61,7 +61,7 @@ Plugin for adding catspeak aliases, because why not
| `violenz` | `git rebase` |
| `visible` | `echo` |
| `wtf` | `dmesg` |
-| `yolo` | `git commit -m "$(curl -s https://whatthecommit.com/index.txt)"` |
+| `yolo` | `git commit -m "$(curl -s http://whatthecommit.com/index.txt)"` |
## Usage Examples
@@ -78,6 +78,6 @@ nowai u=r,go= some.file
# ssh root@catserver.org
pwned root@catserver.org
-# git commit -m "$(curl -s https://whatthecommit.com/index.txt)"
+# git commit -m "$(curl -s http://whatthecommit.com/index.txt)"
yolo
```
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
index bdc2219fa..ded25c3a9 100644
--- a/plugins/systemadmin/systemadmin.plugin.zsh
+++ b/plugins/systemadmin/systemadmin.plugin.zsh
@@ -28,8 +28,8 @@ alias mkdir='mkdir -pv'
alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10'
# get top process eating cpu if not work try excute : export LC_ALL='C'
-alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr'
-alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr | head -10'
+alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr'
+alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -10'
# top10 of the history
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh
index 7cd27d450..201ffd998 100644
--- a/plugins/systemd/systemd.plugin.zsh
+++ b/plugins/systemd/systemd.plugin.zsh
@@ -1,12 +1,65 @@
user_commands=(
- list-units is-active status show help list-unit-files
- is-enabled list-jobs show-environment cat list-timers)
+ cat
+ get-default
+ help
+ is-active
+ is-enabled
+ is-failed
+ is-system-running
+ list-dependencies
+ list-jobs
+ list-sockets
+ list-timers
+ list-unit-files
+ list-units
+ show
+ show-environment
+ status)
sudo_commands=(
- start stop reload restart try-restart isolate kill
- reset-failed enable disable reenable preset mask unmask
- link load cancel set-environment unset-environment
- edit)
+ add-requires
+ add-wants
+ cancel
+ daemon-reexec
+ daemon-reload
+ default
+ disable
+ edit
+ emergency
+ enable
+ halt
+ hibernate
+ hybrid-sleep
+ import-environment
+ isolate
+ kexec
+ kill
+ link
+ list-machines
+ load
+ mask
+ poweroff
+ preset
+ preset-all
+ reboot
+ reenable
+ reload
+ reload-or-restart
+ reset-failed
+ rescue
+ restart
+ revert
+ set-default
+ set-environment
+ set-property
+ start
+ stop
+ suspend
+ switch-root
+ try-reload-or-restart
+ try-restart
+ unmask
+ unset-environment)
for c in $user_commands; do; alias sc-$c="systemctl $c"; done
for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done
diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant
index 2efb4473d..79c4c6fe6 100644
--- a/plugins/vagrant/_vagrant
+++ b/plugins/vagrant/_vagrant
@@ -69,8 +69,8 @@ __box_list ()
__vm_list ()
{
- _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
- _wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null)
+ _wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
+ _wanted application expl 'command' compadd $(command ls "${VAGRANT_CWD:-.}/.vagrant/machines/" 2>/dev/null)
}
__vagrant-box ()
diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
index b07b2a306..267bcaeb5 100644
--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
@@ -1,48 +1,29 @@
-virtualenvwrapper='virtualenvwrapper.sh'
-virtualenvwrapper_lazy='virtualenvwrapper_lazy.sh'
+function {
+ # search in these locations for the init script:
+ for f in $commands[virtualenvwrapper_lazy.sh] \
+ $commands[virtualenvwrapper.sh] \
+ /usr/share/virtualenvwrapper/virtualenvwrapper{_lazy,}.sh \
+ /usr/local/bin/virtualenvwrapper{_lazy,}.sh \
+ /etc/bash_completion.d/virtualenvwrapper \
+ /usr/share/bash-completion/completions/virtualenvwrapper
+ do
+ if [[ -f $f ]]; then
+ source $f
+ return
+ fi
+ done
+ print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh.\n"\
+ "Please install with \`pip install virtualenvwrapper\`" >&2
+}
-if (( $+commands[$virtualenvwrapper_lazy] )); then
- function {
- setopt local_options
- unsetopt equals
- virtualenvwrapper=${${virtualenvwrapper_lazy}:c}
- source ${${virtualenvwrapper_lazy}:c}
- [[ -z "$WORKON_HOME" ]] && WORKON_HOME="$HOME/.virtualenvs"
- }
-elif (( $+commands[$virtualenvwrapper] )); then
- function {
- setopt local_options
- unsetopt equals
- source ${${virtualenvwrapper}:c}
- }
-elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then
- function {
- setopt local_options
- unsetopt equals
- virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh"
- source "/usr/local/bin/virtualenvwrapper.sh"
- }
-elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
- function {
- setopt local_options
- unsetopt equals
- virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper"
- source "/etc/bash_completion.d/virtualenvwrapper"
- }
-else
- print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\
- "Please install with \`pip install virtualenvwrapper\`" >&2
- return
-fi
if ! type workon &>/dev/null; then
print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
"Please check ${virtualenvwrapper}" >&2
return
fi
-if [[ "$WORKON_HOME" == "" ]]; then
- print "[oh-my-zsh] \$WORKON_HOME is not defined so plugin virtualenvwrapper will not work" >&2
- return
+if [[ -z "$WORKON_HOME" ]]; then
+ WORKON_HOME="$HOME/.virtualenvs"
fi
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md
index 74b5a45aa..2c6530650 100644
--- a/plugins/vscode/README.md
+++ b/plugins/vscode/README.md
@@ -1,6 +1,6 @@
-# VS code
+# VS Code
-This plugin makes interaction between the command line and the code editor easier.
+This plugin makes interaction between the command line and the VS Code editor easier.
To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`:
@@ -8,9 +8,11 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`
plugins=(... vscode)
```
-If you are using [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/),
-add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and
-the `plugins=()` line). This will make the plugin use the Insiders version instead.
+## VS Code Insiders
+
+🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.**
+
+But, if you have both Stable and Insiders versions and want to configure the plugin to just use the Insiders version, add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and the `plugins=()` line). This will make the plugin use the Insiders version instead.
```zsh
ZSH_THEME=...
diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh
index 4c15df2b0..0144e0baa 100644
--- a/plugins/vscode/vscode.plugin.zsh
+++ b/plugins/vscode/vscode.plugin.zsh
@@ -1,9 +1,17 @@
# VScode zsh plugin
-# author: https://github.com/MarsiBarsi
+# Authors:
+# https://github.com/MarsiBarsi (original author)
+# https://github.com/babakks
-# Use main Visual Studio Code version by default
-: ${VSCODE:=code}
+# Use the stable VS Code release, unless the Insiders version is the only
+# available installation
+if ! which code > /dev/null && which code-insiders > /dev/null; then
+ : ${VSCODE:=code-insiders}
+else
+ : ${VSCODE:=code}
+fi
+# Define aliases
alias vsc="$VSCODE ."
alias vsca="$VSCODE --add"
alias vscd="$VSCODE --diff"
diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn
index 3689ae960..70e783b86 100644
--- a/plugins/yarn/_yarn
+++ b/plugins/yarn/_yarn
@@ -86,9 +86,11 @@ _yarn_scripts() {
local i runJSON
runJSON=$(yarn run --json 2>/dev/null)
- binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\n/g' <<< "$runJSON"))
- scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\n/g' <<< "$runJSON"))
- scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{([^}]+)\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\n/g;s/(^"|"$)//g' <<< "$runJSON")}")
+ # Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement
+ # pattern as a newline. See https://superuser.com/q/307165
+ binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
+ scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
+ scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{(.+")\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\'$'\n/g;s/(^"|"$)//g' <<< "$runJSON")}")
for (( i=1; i <= $#scriptNames; i++ )); do
scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
diff --git a/plugins/zsh-interactive-cd/README.md b/plugins/zsh-interactive-cd/README.md
new file mode 100644
index 000000000..c8337fbc8
--- /dev/null
+++ b/plugins/zsh-interactive-cd/README.md
@@ -0,0 +1,23 @@
+# zsh-interactive-cd
+
+This plugin adds a fish-like interactive tab completion for the `cd` command.
+
+To use it, add `zsh-interactive-cd` to the plugins array of your zshrc file:
+```zsh
+plugins=(... zsh-interactive-cd)
+```
+
+![demo](https://user-images.githubusercontent.com/1441704/74360670-cb202900-4dc5-11ea-9734-f60caf726e85.gif)
+
+## Usage
+
+Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage.
+
+## Requirements
+
+This plugin requires [fzf](https://github.com/junegunn/fzf). Install it by following
+its [installation instructions](https://github.com/junegunn/fzf#installation).
+
+## Author
+
+[Henry Chang](https://github.com/changyuheng)
diff --git a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh
new file mode 100644
index 000000000..0f15aeef0
--- /dev/null
+++ b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh
@@ -0,0 +1,147 @@
+# Copyright (c) 2017 Henry Chang
+
+__zic_fzf_prog() {
+ [ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \
+ && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"
+}
+
+__zic_matched_subdir_list() {
+ local dir length seg starts_with_dir
+ if [[ "$1" == */ ]]; then
+ dir="$1"
+ if [[ "$dir" != / ]]; then
+ dir="${dir: : -1}"
+ fi
+ length=$(echo -n "$dir" | wc -c)
+ if [ "$dir" = "/" ]; then
+ length=0
+ fi
+ find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \
+ | cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do
+ if [[ "${line[1]}" == "." ]]; then
+ continue
+ fi
+ echo "$line"
+ done
+ else
+ dir=$(dirname -- "$1")
+ length=$(echo -n "$dir" | wc -c)
+ if [ "$dir" = "/" ]; then
+ length=0
+ fi
+ seg=$(basename -- "$1")
+ starts_with_dir=$( \
+ find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
+ 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
+ | while read -r line; do
+ if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
+ continue
+ fi
+ if [[ "$line" == "$seg"* ]]; then
+ echo "$line"
+ fi
+ done
+ )
+ if [ -n "$starts_with_dir" ]; then
+ echo "$starts_with_dir"
+ else
+ find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
+ 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
+ | while read -r line; do
+ if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
+ continue
+ fi
+ if [[ "$line" == *"$seg"* ]]; then
+ echo "$line"
+ fi
+ done
+ fi
+ fi
+}
+
+_zic_list_generator() {
+ __zic_matched_subdir_list "${(Q)@[-1]}" | sort
+}
+
+_zic_complete() {
+ setopt localoptions nonomatch
+ local l matches fzf tokens base
+
+ l=$(_zic_list_generator $@)
+
+ if [ -z "$l" ]; then
+ zle ${__zic_default_completion:-expand-or-complete}
+ return
+ fi
+
+ fzf=$(__zic_fzf_prog)
+
+ if [ $(echo $l | wc -l) -eq 1 ]; then
+ matches=${(q)l}
+ else
+ matches=$(echo $l \
+ | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \
+ --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \
+ --bind 'shift-tab:up,tab:down'" ${=fzf} \
+ | while read -r item; do
+ echo -n "${(q)item} "
+ done)
+ fi
+
+ matches=${matches% }
+ if [ -n "$matches" ]; then
+ tokens=(${(z)LBUFFER})
+ base="${(Q)@[-1]}"
+ if [[ "$base" != */ ]]; then
+ if [[ "$base" == */* ]]; then
+ base="$(dirname -- "$base")"
+ if [[ ${base[-1]} != / ]]; then
+ base="$base/"
+ fi
+ else
+ base=""
+ fi
+ fi
+ LBUFFER="${tokens[1]} "
+ if [ -n "$base" ]; then
+ base="${(q)base}"
+ if [ "${tokens[2][1]}" = "~" ]; then
+ base="${base/#$HOME/~}"
+ fi
+ LBUFFER="${LBUFFER}${base}"
+ fi
+ LBUFFER="${LBUFFER}${matches}/"
+ fi
+ zle redisplay
+ typeset -f zle-line-init >/dev/null && zle zle-line-init
+}
+
+zic-completion() {
+ setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
+ local tokens cmd
+
+ tokens=(${(z)LBUFFER})
+ cmd=${tokens[1]}
+
+ if [[ "$LBUFFER" =~ "^\ *cd$" ]]; then
+ zle ${__zic_default_completion:-expand-or-complete}
+ elif [ "$cmd" = cd ]; then
+ _zic_complete ${tokens[2,${#tokens}]/#\~/$HOME}
+ else
+ zle ${__zic_default_completion:-expand-or-complete}
+ fi
+}
+
+[ -z "$__zic_default_completion" ] && {
+ binding=$(bindkey '^I')
+ # $binding[(s: :w)2]
+ # The command substitution and following word splitting to determine the
+ # default zle widget for ^I formerly only works if the IFS parameter contains
+ # a space via $binding[(w)2]. Now it specifically splits at spaces, regardless
+ # of IFS.
+ [[ $binding =~ 'undefined-key' ]] || __zic_default_completion=$binding[(s: :w)2]
+ unset binding
+}
+
+zle -N zic-completion
+bindkey '^I' zic-completion
diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme
index d185fa1ab..30e997f8c 100644
--- a/themes/af-magic.zsh-theme
+++ b/themes/af-magic.zsh-theme
@@ -21,9 +21,9 @@ eval my_orange='$FG[214]'
# right prompt
if type "virtualenv_prompt_info" > /dev/null
then
- RPROMPT='$FG[078]$(virtualenv_prompt_info)%{$reset_color%} $my_gray%n@%m%{$reset_color%}%'
+ RPROMPT="${RPROMPT}"'$FG[078]$(virtualenv_prompt_info)%{$reset_color%} $my_gray%n@%m%{$reset_color%}%'
else
- RPROMPT='$my_gray%n@%m%{$reset_color%}%'
+ RPROMPT="${RPROMPT}"'$my_gray%n@%m%{$reset_color%}%'
fi
# git settings
diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme
index 30ce785c0..ad03cc320 100644
--- a/themes/candy-kingdom.zsh-theme
+++ b/themes/candy-kingdom.zsh-theme
@@ -1,16 +1,14 @@
-# neuralsanwich.zsh-theme
-
-if [ "x$OH_MY_ZSH_HG" = "x" ]; then
- OH_MY_ZSH_HG="hg"
-fi
-
-function hg_prompt_info {
- $OH_MY_ZSH_HG prompt --angle-brackets "\
+if ! hg prompt 2>/dev/null; then
+ function hg_prompt_info { }
+else
+ function hg_prompt_info {
+ hg prompt --angle-brackets "\
< on %{$fg[magenta]%}<branch>%{$reset_color%}>\
< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
-}
+ }
+fi
function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
@@ -26,5 +24,9 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
-local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}"
-RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
+RPROMPT='%{$fg[red]%}%(?..✘)%{$reset_color%}'
+
+# Add battery status if the battery plugin is enabled
+if (( $+functions[battery_pct_prompt] )); then
+ RPROMPT+='$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
+fi
diff --git a/themes/kiwi.zsh-theme b/themes/kiwi.zsh-theme
index f93de2b75..94f0ffcbf 100644
--- a/themes/kiwi.zsh-theme
+++ b/themes/kiwi.zsh-theme
@@ -1,6 +1,4 @@
-#
-# Kiwi ZSH Theme
-#
+(( $+functions[battery_pct_prompt] )) || function battery_pct_prompt { }
PROMPT='%{$fg_bold[green]%}┌[%{$fg_bold[cyan]%}kiwish-4.2%{$fg_bold[green]%}]-(%{$fg_bold[white]%}%2~%{$fg_bold[green]%})-$(git_prompt_info)$(svn_prompt_info)$(battery_pct_prompt)
└> % %{$reset_color%}'