Add upstream oh_my_zsh repo
This commit is contained in:
@@ -4,7 +4,7 @@ alias-finder() {
|
||||
case $i in
|
||||
-e|--exact) exact=true;;
|
||||
-l|--longer) longer=true;;
|
||||
*)
|
||||
*)
|
||||
if [[ -z $cmd ]]; then
|
||||
cmd=$i
|
||||
else
|
||||
@@ -14,7 +14,7 @@ alias-finder() {
|
||||
esac
|
||||
done
|
||||
cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep
|
||||
if [[ $(wc -l <<< $cmd) == 1 ]]; then
|
||||
if (( $(wc -l <<< $cmd) == 1 )); then
|
||||
while [[ $cmd != "" ]]; do
|
||||
if [[ $longer = true ]]; then
|
||||
wordStart="'{0,1}"
|
||||
@@ -43,4 +43,5 @@ preexec_alias-finder() {
|
||||
fi
|
||||
}
|
||||
|
||||
preexec_functions+=(preexec_alias-finder)
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook preexec preexec_alias-finder
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
## APACHE2 MACPORTS PLUGIN
|
||||
# apache2-macports plugin
|
||||
|
||||
Enables aliases to control a local Apache2 installed via [MacPorts](https://www.macports.org/).
|
||||
|
||||
---
|
||||
To use it, add `apache2-macports` to the plugins array in your zshrc file:
|
||||
|
||||
### FEATURES
|
||||
```zsh
|
||||
plugins=(... apache2-macports)
|
||||
```
|
||||
|
||||
| Alias | Function | Description |
|
||||
|:--------------:|:-------------------------------------------------------------------------------|----------------------:|
|
||||
| apache2restart | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart | Restart apache daemon |
|
||||
| apache2start | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start | Start apache daemon |
|
||||
| apache2stop | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop | Stop apache daemon |
|
||||
## Aliases
|
||||
|
||||
---
|
||||
| Alias | Function | Description |
|
||||
|----------------|-----------------------------------------|-----------------------|
|
||||
| apache2restart | `sudo /path/to/apache2.wrapper restart` | Restart apache daemon |
|
||||
| apache2start | `sudo /path/to/apache2.wrapper start` | Start apache daemon |
|
||||
| apache2stop | `sudo /path/to/apache2.wrapper stop` | Stop apache daemon |
|
||||
|
||||
### CONTRIBUTORS
|
||||
- Alexander Rinass (alex@rinass.net)
|
||||
## Contributors
|
||||
|
||||
---
|
||||
- Alexander Rinass (alex@rinass.net)
|
||||
|
||||
@@ -1,5 +1,41 @@
|
||||
## arcanist
|
||||
|
||||
**Maintainer:** [@emzar](https://github.com/emzar)
|
||||
This plugin adds many useful aliases for [arcanist](https://github.com/phacility/arcanist).
|
||||
|
||||
This plugin adds many useful aliases.
|
||||
To use it, add `arcanist` to the plugins array of your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... arcanist)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
| ------- | ---------------------------------- |
|
||||
| ara | `arc amend` |
|
||||
| arb | `arc branch` |
|
||||
| arco | `arc cover` |
|
||||
| arci | `arc commit` |
|
||||
| ard | `arc diff` |
|
||||
| ardc | `arc diff --create` |
|
||||
| ardp | `arc diff --preview` |
|
||||
| ardnu | `arc diff --nounit` |
|
||||
| ardnupc | `arc diff --nounit --plan-changes` |
|
||||
| ardpc | `arc diff --plan-changes` |
|
||||
| are | `arc export` |
|
||||
| arh | `arc help` |
|
||||
| arl | `arc land` |
|
||||
| arli | `arc lint` |
|
||||
| arls | `arc list` |
|
||||
| arpa | `arc patch` |
|
||||
|
||||
## Functions
|
||||
|
||||
The following functions make copy pasting revision ids from the URL bar of your browser
|
||||
easier, as they allow for copy pasting the whole URL. For example: `ardu` accepts
|
||||
both `https://arcanist-url.com/<REVISION>` as well as `<REVISION>`.
|
||||
|
||||
| Function | Command |
|
||||
| ------------------------- | --------------------------------- |
|
||||
| ardu [URL or revision_id] | `arc diff --update` [revision_id] |
|
||||
| arpa [URL or revision_id] | `arc patch` [revision_id] |
|
||||
|
||||
@@ -9,13 +9,29 @@ alias arco='arc cover'
|
||||
alias arci='arc commit'
|
||||
|
||||
alias ard='arc diff'
|
||||
alias ardc='arc diff --create'
|
||||
alias ardnu='arc diff --nounit'
|
||||
alias ardnupc='arc diff --nounit --plan-changes'
|
||||
alias ardpc='arc diff --plan-changes'
|
||||
alias ardp='arc diff --preview' # creates a new diff in the phab interface
|
||||
|
||||
alias are='arc export'
|
||||
alias arh='arc help'
|
||||
alias arl='arc land'
|
||||
alias arli='arc lint'
|
||||
alias arls='arc list'
|
||||
alias arpa='arc patch'
|
||||
|
||||
#
|
||||
# Functions
|
||||
# (sorted alphabetically)
|
||||
#
|
||||
|
||||
ardu() {
|
||||
# Both `ardu https://arcanist-url.com/<REVISION>`, and `ardu <REVISION>` work.
|
||||
arc diff --update "${1:t}"
|
||||
}
|
||||
|
||||
arpa() {
|
||||
# Both `arpa https://arcanist-url.com/<REVISION>`, and `arpa <REVISION>` work.
|
||||
arc patch "${1:t}"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# Archlinux plugin
|
||||
|
||||
This plugin adds some aliases and functions to work with Arch Linux.
|
||||
|
||||
To use it, add `archlinux` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... archlinux)
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
#### YAY
|
||||
@@ -119,7 +127,7 @@
|
||||
| pacupg | sudo pacman -Syu | Sync with repositories before upgrading packages |
|
||||
| upgrade | sudo pacman -Syu | Sync with repositories before upgrading packages |
|
||||
| pacfileupg | sudo pacman -Fy | Download fresh package databases from the server |
|
||||
| pacfiles | pacman -Fs | Search package file names for matching strings |
|
||||
| pacfiles | pacman -F | Search package file names for matching strings |
|
||||
| pacls | pacman -Ql | List files in a package |
|
||||
| pacown | pacman -Qo | Show which package owns a file |
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ alias pacmir='sudo pacman -Syy'
|
||||
alias paclsorphans='sudo pacman -Qdt'
|
||||
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
|
||||
alias pacfileupg='sudo pacman -Fy'
|
||||
alias pacfiles='pacman -Fs'
|
||||
alias pacfiles='pacman -F'
|
||||
alias pacls='pacman -Ql'
|
||||
alias pacown='pacman -Qo'
|
||||
|
||||
@@ -208,12 +208,12 @@ function pacmansignkeys() {
|
||||
if (( $+commands[xdg-open] )); then
|
||||
function pacweb() {
|
||||
pkg="$1"
|
||||
infos="$(pacman -Si "$pkg")"
|
||||
infos="$(LANG=C pacman -Si "$pkg")"
|
||||
if [[ -z "$infos" ]]; then
|
||||
return
|
||||
fi
|
||||
repo="$(grep '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
|
||||
arch="$(grep '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
|
||||
repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
|
||||
arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
|
||||
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
|
||||
}
|
||||
fi
|
||||
|
||||
@@ -3,7 +3,7 @@ ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/completions"
|
||||
|
||||
# If not found, check for Homebrew package
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" ]] && (( $+commands[brew] )); then
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
|
||||
ASDF_DIR="$(brew --prefix asdf)"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d"
|
||||
fi
|
||||
|
||||
20
zsh/plugins/autoenv/README.md
Normal file
20
zsh/plugins/autoenv/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Autoenv plugin
|
||||
|
||||
This plugin loads the [Autoenv](https://github.com/inishchith/autoenv).
|
||||
|
||||
To use it, add `autoenv` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... autoenv)
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
* `use_env()`: creates and/or activates a virtualenv. For use in `.env` files.
|
||||
See the source code for details.
|
||||
|
||||
## Requirements
|
||||
|
||||
In order to make this work, you will need to have the autoenv installed.
|
||||
|
||||
More info on the usage and install at [the project's homepage](https://github.com/inishchith/autoenv).
|
||||
@@ -1,12 +1,39 @@
|
||||
# Activates autoenv or reports its failure
|
||||
# Initialization: activate autoenv or report its absence
|
||||
() {
|
||||
local d autoenv_dir install_locations
|
||||
if ! type autoenv_init >/dev/null; then
|
||||
for d (~/.autoenv ~/.local/bin /usr/local/opt/autoenv /usr/local/bin); do
|
||||
# Check if activate.sh is in $PATH
|
||||
if (( $+commands[activate.sh] )); then
|
||||
autoenv_dir="${commands[activate.sh]:h}"
|
||||
fi
|
||||
|
||||
# Locate autoenv installation
|
||||
if [[ -z $autoenv_dir ]]; then
|
||||
install_locations=(
|
||||
~/.autoenv
|
||||
~/.local/bin
|
||||
/usr/local/opt/autoenv
|
||||
/usr/local/bin
|
||||
/usr/share/autoenv-git
|
||||
~/Library/Python/bin
|
||||
)
|
||||
for d ( $install_locations ); do
|
||||
if [[ -e $d/activate.sh ]]; then
|
||||
autoenv_dir=$d
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Look for Homebrew path as a last resort
|
||||
if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then
|
||||
d=$(brew --prefix)/opt/autoenv
|
||||
if [[ -e $d/activate.sh ]]; then
|
||||
autoenv_dir=$d
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Complain if autoenv is not installed
|
||||
if [[ -z $autoenv_dir ]]; then
|
||||
cat <<END >&2
|
||||
-------- AUTOENV ---------
|
||||
@@ -17,6 +44,7 @@ In the meantime the autoenv plugin is DISABLED.
|
||||
END
|
||||
return 1
|
||||
fi
|
||||
# Load autoenv
|
||||
source $autoenv_dir/activate.sh
|
||||
fi
|
||||
}
|
||||
@@ -27,17 +55,17 @@ fi
|
||||
# It only performs an action if the requested virtualenv is not the current one.
|
||||
|
||||
use_env() {
|
||||
typeset venv
|
||||
venv="$1"
|
||||
if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
|
||||
if workon | grep -q "$venv"; then
|
||||
workon "$venv"
|
||||
else
|
||||
echo -n "Create virtualenv $venv now? (Yn) "
|
||||
read answer
|
||||
if [[ "$answer" == "Y" ]]; then
|
||||
mkvirtualenv "$venv"
|
||||
fi
|
||||
fi
|
||||
local venv
|
||||
venv="$1"
|
||||
if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
|
||||
if workon | grep -q "$venv"; then
|
||||
workon "$venv"
|
||||
else
|
||||
echo -n "Create virtualenv $venv now? (Yn) "
|
||||
read answer
|
||||
if [[ "$answer" == "Y" ]]; then
|
||||
mkvirtualenv "$venv"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ To use it, add `autojump` to the plugins array in your zshrc file:
|
||||
plugins=(... autojump)
|
||||
```
|
||||
|
||||
More info on the usage: https://github.com/wting/autojump
|
||||
**Note:** you have to [install autojump](https://github.com/wting/autojump#installation) first.
|
||||
|
||||
@@ -29,6 +29,6 @@ if (( ! found && $+commands[brew] )); then
|
||||
fi
|
||||
fi
|
||||
|
||||
(( ! found )) && echo '[oh-my-zsh] autojump script not found'
|
||||
(( ! found )) && echo '[oh-my-zsh] autojump not found. Please install it first.'
|
||||
|
||||
unset autojump_paths file found
|
||||
|
||||
@@ -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
|
||||
@@ -30,17 +31,17 @@ function aws_change_access_key() {
|
||||
|
||||
echo Insert the credentials when asked.
|
||||
asp "$1" || return 1
|
||||
aws iam create-access-key
|
||||
aws configure --profile "$1"
|
||||
AWS_PAGER="" aws iam create-access-key
|
||||
AWS_PAGER="" aws configure --profile "$1"
|
||||
|
||||
echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`
|
||||
echo Your current keys are:
|
||||
aws iam list-access-keys
|
||||
AWS_PAGER="" aws iam list-access-keys
|
||||
}
|
||||
|
||||
function aws_profiles() {
|
||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
||||
grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/'
|
||||
grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9@_\.-]*\).*/\1/'
|
||||
}
|
||||
|
||||
function _aws_profiles() {
|
||||
@@ -61,36 +62,45 @@ fi
|
||||
|
||||
# Load awscli completions
|
||||
|
||||
function _awscli-homebrew-installed() {
|
||||
# check if Homebrew is installed
|
||||
(( $+commands[brew] )) || return 1
|
||||
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
||||
if command -v aws_completer &> /dev/null; then
|
||||
autoload -Uz bashcompinit && bashcompinit
|
||||
complete -C aws_completer aws
|
||||
else
|
||||
function _awscli-homebrew-installed() {
|
||||
# check if Homebrew is installed
|
||||
(( $+commands[brew] )) || return 1
|
||||
|
||||
# speculatively check default brew prefix
|
||||
if [ -h /usr/local/opt/awscli ]; then
|
||||
_brew_prefix=/usr/local/opt/awscli
|
||||
else
|
||||
# ok, it is not in the default prefix
|
||||
# this call to brew is expensive (about 400 ms), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix awscli)
|
||||
# speculatively check default brew prefix
|
||||
if [ -h /usr/local/opt/awscli ]; then
|
||||
_brew_prefix=/usr/local/opt/awscli
|
||||
else
|
||||
# ok, it is not in the default prefix
|
||||
# this call to brew is expensive (about 400 ms), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix awscli)
|
||||
fi
|
||||
}
|
||||
|
||||
# get aws_zsh_completer.sh location from $PATH
|
||||
_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]"
|
||||
|
||||
# otherwise check common locations
|
||||
if [[ -z $_aws_zsh_completer_path ]]; then
|
||||
# Homebrew
|
||||
if _awscli-homebrew-installed; then
|
||||
_aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
|
||||
# Ubuntu
|
||||
elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then
|
||||
_aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli
|
||||
# NixOS
|
||||
elif [[ -e "${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh" ]]; then
|
||||
_aws_zsh_completer_path="${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh"
|
||||
# RPM
|
||||
else
|
||||
_aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# get aws_zsh_completer.sh location from $PATH
|
||||
_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]"
|
||||
|
||||
# otherwise check common locations
|
||||
if [[ -z $_aws_zsh_completer_path ]]; then
|
||||
# Homebrew
|
||||
if _awscli-homebrew-installed; then
|
||||
_aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
|
||||
# Ubuntu
|
||||
elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then
|
||||
_aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli
|
||||
# RPM
|
||||
else
|
||||
_aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh
|
||||
fi
|
||||
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
|
||||
unset _aws_zsh_completer_path _brew_prefix
|
||||
fi
|
||||
|
||||
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
|
||||
unset _aws_zsh_completer_path _brew_prefix
|
||||
|
||||
@@ -9,5 +9,14 @@ To use, add `battery` to the list of plugins in your `.zshrc` file:
|
||||
Then, add the `battery_pct_prompt` function to your custom theme. For example:
|
||||
|
||||
```
|
||||
RPROMPT='$(battery_pct_prompt)'
|
||||
RPROMPT='$(battery_pct_prompt) ...'
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
On Linux, you must have the `acpi` tool installed on your operating system.
|
||||
|
||||
Here's an example of how to install with apt:
|
||||
```
|
||||
sudo apt-get install acpi
|
||||
```
|
||||
|
||||
@@ -7,23 +7,25 @@
|
||||
# Email: neuralsandwich@gmail.com #
|
||||
# Modified to add support for Apple Mac #
|
||||
###########################################
|
||||
# Author: J (927589452) #
|
||||
# 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 battery_status="$(ioreg -rc AppleSmartBattery)"
|
||||
local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status)
|
||||
local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status)
|
||||
echo $(( current * 100 / capacity ))
|
||||
}
|
||||
|
||||
function battery_pct_remaining() {
|
||||
if plugged_in ; then
|
||||
if battery_is_charging; then
|
||||
echo "External Power"
|
||||
else
|
||||
battery_pct
|
||||
@@ -32,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))"
|
||||
@@ -45,39 +47,36 @@ if [[ "$OSTYPE" = darwin* ]] ; then
|
||||
}
|
||||
|
||||
function battery_pct_prompt () {
|
||||
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
|
||||
b=$(battery_pct_remaining)
|
||||
if [ $b -gt 50 ] ; then
|
||||
local battery_pct color
|
||||
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
|
||||
battery_pct=$(battery_pct_remaining)
|
||||
if [[ $battery_pct -gt 50 ]]; then
|
||||
color='green'
|
||||
elif [ $b -gt 20 ] ; then
|
||||
elif [[ $battery_pct -gt 20 ]]; then
|
||||
color='yellow'
|
||||
else
|
||||
color='red'
|
||||
fi
|
||||
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
|
||||
echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
|
||||
else
|
||||
echo "∞"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_is_charging() {
|
||||
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
|
||||
}
|
||||
|
||||
elif [[ "$OSTYPE" = linux* ]] ; then
|
||||
elif [[ "$OSTYPE" = freebsd* ]]; then
|
||||
|
||||
function battery_is_charging() {
|
||||
! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
|
||||
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
|
||||
}
|
||||
|
||||
function battery_pct() {
|
||||
if (( $+commands[acpi] )) ; then
|
||||
echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')"
|
||||
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"
|
||||
@@ -85,76 +84,128 @@ 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 ',')
|
||||
local remaining_time
|
||||
remaining_time=$(sysctl -n hw.acpi.battery.time)
|
||||
if [[ $remaining_time -ge 0 ]]; then
|
||||
((hour = $remaining_time / 60 ))
|
||||
((minute = $remaining_time % 60 ))
|
||||
printf %02d:%02d $hour $minute
|
||||
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 battery_pct color
|
||||
battery_pct=$(battery_pct_remaining)
|
||||
if battery_is_charging; then
|
||||
echo "∞"
|
||||
else
|
||||
if [[ $battery_pct -gt 50 ]]; then
|
||||
color='green'
|
||||
elif [ $b -gt 20 ] ; then
|
||||
elif [[ $battery_pct -gt 20 ]]; then
|
||||
color='yellow'
|
||||
else
|
||||
color='red'
|
||||
fi
|
||||
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
|
||||
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||
fi
|
||||
}
|
||||
|
||||
elif [[ "$OSTYPE" = linux* ]]; then
|
||||
|
||||
function battery_is_charging() {
|
||||
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
|
||||
}
|
||||
|
||||
function battery_pct() {
|
||||
if (( $+commands[acpi] )); then
|
||||
acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]'
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_pct_remaining() {
|
||||
if ! battery_is_charging; then
|
||||
battery_pct
|
||||
else
|
||||
echo "External Power"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_time_remaining() {
|
||||
if ! battery_is_charging; then
|
||||
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_pct_prompt() {
|
||||
local battery_pct color
|
||||
battery_pct=$(battery_pct_remaining)
|
||||
if battery_is_charging; then
|
||||
echo "∞"
|
||||
else
|
||||
if [[ $battery_pct -gt 50 ]]; then
|
||||
color='green'
|
||||
elif [[ $battery_pct -gt 20 ]]; then
|
||||
color='yellow'
|
||||
else
|
||||
color='red'
|
||||
fi
|
||||
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||
fi
|
||||
}
|
||||
|
||||
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 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 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
|
||||
|
||||
printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%}
|
||||
printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
|
||||
# Charging status and prefix
|
||||
print -n ${charging_color}${charging}${color_reset}${battery_prefix}${gauge_color}
|
||||
# Filled slots
|
||||
[[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
|
||||
# Empty slots
|
||||
[[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty}
|
||||
printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%}
|
||||
# Suffix
|
||||
print -n ${color_reset}${battery_suffix}${color_reset}
|
||||
}
|
||||
|
||||
|
||||
|
||||
5
zsh/plugins/bazel/README.md
Normal file
5
zsh/plugins/bazel/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
## Bazel autocomplete plugin
|
||||
|
||||
A copy of the completion script from the
|
||||
[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel)
|
||||
git repo.
|
||||
341
zsh/plugins/bazel/_bazel
Normal file
341
zsh/plugins/bazel/_bazel
Normal file
@@ -0,0 +1,341 @@
|
||||
#compdef bazel
|
||||
|
||||
# Copyright 2015 The Bazel Authors. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Installation
|
||||
# ------------
|
||||
#
|
||||
# 1. Add this script to a directory on your $fpath:
|
||||
# fpath[1,0]=~/.zsh/completion/
|
||||
# mkdir -p ~/.zsh/completion/
|
||||
# cp scripts/zsh_completion/_bazel ~/.zsh/completion
|
||||
#
|
||||
# 2. Optionally, add the following to your .zshrc.
|
||||
# zstyle ':completion:*' use-cache on
|
||||
# zstyle ':completion:*' cache-path ~/.zsh/cache
|
||||
#
|
||||
# This way, the completion script does not have to parse Bazel's options
|
||||
# repeatedly. The directory in cache-path must be created manually.
|
||||
#
|
||||
# 3. Restart the shell
|
||||
#
|
||||
# Options
|
||||
# -------
|
||||
# completion:init:bazel:* cache-lifetime
|
||||
# Lifetime for the completion cache (if turned on, default: 1 week)
|
||||
|
||||
local curcontext="$curcontext" state line
|
||||
|
||||
: ${BAZEL_COMPLETION_PACKAGE_PATH:=%workspace%}
|
||||
: ${BAZEL:=bazel}
|
||||
_bazel_b() { ${BAZEL} --noblock_for_lock "$@" 2>/dev/null; }
|
||||
|
||||
# Default cache lifetime is 1 week
|
||||
zstyle -s ":completion:${curcontext}:" cache-lifetime lifetime
|
||||
if [[ -z "${lifetime}" ]]; then
|
||||
lifetime=$((60*60*24*7))
|
||||
fi
|
||||
|
||||
_bazel_cache_policy() {
|
||||
local -a oldp
|
||||
oldp=( "$1"(Nms+${lifetime}) )
|
||||
(( $#oldp ))
|
||||
}
|
||||
|
||||
_set_cache_policy() {
|
||||
zstyle -s ":completion:*:$curcontext*" cache-policy update_policy
|
||||
|
||||
if [[ -z "$update_policy" ]]; then
|
||||
zstyle ":completion:$curcontext*" cache-policy _bazel_cache_policy
|
||||
fi
|
||||
}
|
||||
|
||||
# Skips over all global arguments. After invocation, OFFSET contains the
|
||||
# position of the bazel command in $words.
|
||||
_adapt_subcommand_offset() {
|
||||
OFFSET=2
|
||||
for w in ${words[2,-1]}; do
|
||||
if [[ $w == (#b)-* ]]; then
|
||||
(( OFFSET++ ))
|
||||
else
|
||||
return
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Retrieve the cache but also check that the value is not empty.
|
||||
_bazel_safe_retrieve_cache() {
|
||||
_retrieve_cache $1 && [[ ${(P)#2} -gt 0 ]]
|
||||
}
|
||||
|
||||
# Puts the name of the variable that contains the options for the bazel
|
||||
# subcommand handed in as the first argument into the global variable
|
||||
# _bazel_cmd_options.
|
||||
_bazel_get_options() {
|
||||
local lcmd=$1
|
||||
_bazel_cmd_options=_bazel_${lcmd}_options
|
||||
_bazel_cmd_args=_bazel_${lcmd}_args
|
||||
if [[ ${(P)#_bazel_cmd_options} != 0 ]]; then
|
||||
return
|
||||
fi
|
||||
if _cache_invalid BAZEL_${lcmd}_options || _cache_invalid BAZEL_${lcmd}_args \
|
||||
|| ! _bazel_safe_retrieve_cache BAZEL_${lcmd}_options ${_bazel_cmd_options} \
|
||||
|| ! _retrieve_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}; then
|
||||
if ! eval "$(_bazel_b help completion)"; then
|
||||
return
|
||||
fi
|
||||
local opts_var
|
||||
if [[ $lcmd == "startup_options" ]]; then
|
||||
opts_var="BAZEL_STARTUP_OPTIONS"
|
||||
else
|
||||
opts_var="BAZEL_COMMAND_${lcmd:u}_FLAGS"
|
||||
fi
|
||||
local -a raw_options
|
||||
if ! eval "raw_options=(\${(@f)$opts_var})"; then
|
||||
return
|
||||
fi
|
||||
|
||||
local -a option_list
|
||||
for opt in $raw_options; do
|
||||
case $opt in
|
||||
--*"={"*)
|
||||
local lst="${${opt##*"={"}%"}"}"
|
||||
local opt="${opt%%=*}="
|
||||
option_list+=("${opt}:string:_values '' ${lst//,/ }") ;;
|
||||
--*=path)
|
||||
option_list+=("${opt%path}:path:_files") ;;
|
||||
--*=label)
|
||||
option_list+=("${opt%label}:target:_bazel_complete_target") ;;
|
||||
--*=*)
|
||||
option_list+=("${opt}:string:") ;;
|
||||
*)
|
||||
option_list+=("$opt") ;;
|
||||
esac
|
||||
done
|
||||
|
||||
local -a cmd_args
|
||||
local cmd_type
|
||||
if eval "cmd_type=\${BAZEL_COMMAND_${lcmd:u}_ARGUMENT}" && [[ -n $cmd_type ]]; then
|
||||
case $cmd_type in
|
||||
label|label-*)
|
||||
cmd_args+=("*::${cmd_type}:_bazel_complete_target_${cmd_type//-/_}") ;;
|
||||
info-key)
|
||||
cmd_args+=('1::key:_bazel_info_key') ;;
|
||||
path)
|
||||
cmd_args+=('1::profile:_path_files') ;;
|
||||
"command|{"*"}")
|
||||
local lst=${${cmd_type#"command|{"}%"}"}
|
||||
cmd_args+=("1::topic:_bazel_help_topic -- ${lst//,/ }") ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
typeset -g "${_bazel_cmd_options}"="${(pj:|:)option_list[*]}"
|
||||
_store_cache BAZEL_${lcmd}_options ${_bazel_cmd_options}
|
||||
typeset -g "${_bazel_cmd_args}"="${(pj:|:)cmd_args[*]}"
|
||||
_store_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}
|
||||
fi
|
||||
}
|
||||
|
||||
_get_build_targets() {
|
||||
local pkg=$1
|
||||
local rule_re
|
||||
typeset -a completions
|
||||
case $target_type in
|
||||
test)
|
||||
rule_re=".*_test"
|
||||
;;
|
||||
build)
|
||||
rule_re=".*"
|
||||
;;
|
||||
bin)
|
||||
rule_re=".*_test|.*_binary"
|
||||
;;
|
||||
esac
|
||||
completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
|
||||
if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then
|
||||
completions+=(all)
|
||||
fi
|
||||
echo ${completions[*]}
|
||||
}
|
||||
|
||||
# Returns all packages that match $PREFIX. PREFIX may start with //, in which
|
||||
# case the workspace roots are searched. Otherwise, they are completed based on
|
||||
# PWD.
|
||||
_get_build_packages() {
|
||||
local workspace pfx
|
||||
typeset -a package_roots paths final_paths
|
||||
workspace=$PWD
|
||||
package_roots=(${(ps.:.)BAZEL_COMPLETION_PACKAGE_PATH})
|
||||
package_roots=(${^package_roots//\%workspace\%/$workspace})
|
||||
if [[ "${(e)PREFIX}" == //* ]]; then
|
||||
pfx=${(e)PREFIX[2,-1]}
|
||||
else
|
||||
pfx=${(e)PREFIX}
|
||||
fi
|
||||
paths=(${^package_roots}/${pfx}*(/))
|
||||
for p in ${paths[*]}; do
|
||||
if [[ -f ${p}/BUILD || -f ${p}/BUILD.bazel ]]; then
|
||||
final_paths+=(${p##*/}:)
|
||||
fi
|
||||
final_paths+=(${p##*/}/)
|
||||
done
|
||||
echo ${final_paths[*]}
|
||||
}
|
||||
|
||||
_package_remove_slash() {
|
||||
if [[ $KEYS == ':' && $LBUFFER == */ ]]; then
|
||||
LBUFFER=${LBUFFER[1,-2]}
|
||||
fi
|
||||
}
|
||||
|
||||
# Completion function for BUILD targets, called by the completion system.
|
||||
_bazel_complete_target() {
|
||||
local expl
|
||||
typeset -a packages targets
|
||||
if [[ "${(e)PREFIX}" != *:* ]]; then
|
||||
# There is no : in the prefix, completion can be either
|
||||
# a package or a target, if the cwd is a package itself.
|
||||
if [[ -f $PWD/BUILD || -f $PWD/BUILD.bazel ]]; then
|
||||
targets=($(_get_build_targets ""))
|
||||
_description build_target expl "BUILD target"
|
||||
compadd "${expl[@]}" -a targets
|
||||
fi
|
||||
packages=($(_get_build_packages))
|
||||
_description build_package expl "BUILD package"
|
||||
# Chop of the leading path segments from the prefix for display.
|
||||
compset -P '*/'
|
||||
compadd -R _package_remove_slash -S '' "${expl[@]}" -a packages
|
||||
else
|
||||
targets=($(_get_build_targets "${${(e)PREFIX}%:*}"))
|
||||
_description build_target expl "BUILD target"
|
||||
# Ignore the current prefix for the upcoming completion, since we only list
|
||||
# the names of the targets, not the full path.
|
||||
compset -P '*:'
|
||||
compadd "${expl[@]}" -a targets
|
||||
fi
|
||||
}
|
||||
|
||||
_bazel_complete_target_label() {
|
||||
typeset -g target_type=build
|
||||
_bazel_complete_target
|
||||
}
|
||||
|
||||
_bazel_complete_target_label_test() {
|
||||
typeset -g target_type=test
|
||||
_bazel_complete_target
|
||||
}
|
||||
|
||||
_bazel_complete_target_label_bin() {
|
||||
typeset -g target_type=bin
|
||||
_bazel_complete_target
|
||||
}
|
||||
|
||||
### Actual completion commands
|
||||
|
||||
_bazel() {
|
||||
_adapt_subcommand_offset
|
||||
if (( CURRENT - OFFSET > 0 )); then
|
||||
# Remember the subcommand name, stored globally so we can access it
|
||||
# from any subsequent function
|
||||
cmd=${words[OFFSET]//-/_}
|
||||
|
||||
# Set the context for the subcommand.
|
||||
curcontext="${curcontext%:*:*}:bazel-$cmd:"
|
||||
_set_cache_policy
|
||||
|
||||
# Narrow the range of words we are looking at to exclude cmd
|
||||
# name and any leading options
|
||||
(( CURRENT = CURRENT - OFFSET + 1 ))
|
||||
shift $((OFFSET - 1)) words
|
||||
# Run the completion for the subcommand
|
||||
_bazel_get_options $cmd
|
||||
_arguments : \
|
||||
${(Pps:|:)_bazel_cmd_options} \
|
||||
${(Pps:|:)_bazel_cmd_args}
|
||||
else
|
||||
_set_cache_policy
|
||||
# Start special handling for global options,
|
||||
# which can be retrieved by calling
|
||||
# $ bazel help startup_options
|
||||
_bazel_get_options startup_options
|
||||
_arguments : \
|
||||
${(Pps:|:)_bazel_cmd_options} \
|
||||
"*:commands:_bazel_commands"
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
_get_commands() {
|
||||
# bazel_cmd_list is a global (g) array (a)
|
||||
typeset -ga _bazel_cmd_list
|
||||
# Use `bazel help` instead of `bazel help completion` to get command
|
||||
# descriptions.
|
||||
if _bazel_cmd_list=("${(@f)$(_bazel_b help | awk '
|
||||
/Available commands/ { command=1; }
|
||||
/ [-a-z]+[ \t]+.+/ { if (command) { printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" } }
|
||||
/^$/ { command=0; }')}"); then
|
||||
_store_cache BAZEL_commands _bazel_cmd_list
|
||||
fi
|
||||
}
|
||||
|
||||
# Completion function for bazel subcommands, called by the completion system.
|
||||
_bazel_commands() {
|
||||
if [[ ${#_bazel_cmd_list} == 0 ]]; then
|
||||
if _cache_invalid BAZEL_commands \
|
||||
|| ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
|
||||
_get_commands
|
||||
fi
|
||||
fi
|
||||
|
||||
_describe -t bazel-commands 'Bazel command' _bazel_cmd_list
|
||||
}
|
||||
|
||||
# Completion function for bazel help options, called by the completion system.
|
||||
_bazel_help_topic() {
|
||||
if [[ ${#_bazel_cmd_list} == 0 ]]; then
|
||||
if _cache_invalid BAZEL_commands \
|
||||
|| ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
|
||||
_get_commands
|
||||
fi
|
||||
fi
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == -- ]]; then
|
||||
shift
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
_bazel_help_list=($@)
|
||||
_bazel_help_list+=($_bazel_cmd_list)
|
||||
_describe -t bazel-help 'Help topic' _bazel_help_list
|
||||
}
|
||||
|
||||
# Completion function for bazel info keys, called by the completion system.
|
||||
_bazel_info_key() {
|
||||
if [[ ${#_bazel_info_keys_list} == 0 ]]; then
|
||||
if _cache_invalid BAZEL_info_keys \
|
||||
|| ! _bazel_safe_retrieve_cache BAZEL_info_keys _bazel_info_keys_list; then
|
||||
typeset -ga _bazel_info_keys_list
|
||||
# Use `bazel help` instead of `bazel help completion` to get info-key
|
||||
# descriptions.
|
||||
if _bazel_info_keys_list=("${(@f)$(_bazel_b help info-keys | awk '
|
||||
{ printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" }')}"); then
|
||||
_store_cache BAZEL_info_keys _bazel_info_keys_list
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
_describe -t bazel-info 'Key' _bazel_info_keys_list
|
||||
}
|
||||
@@ -53,7 +53,7 @@ bgnotify () { ## args: (title, subtitle)
|
||||
|
||||
bgnotify_begin() {
|
||||
bgnotify_timestamp=$EPOCHSECONDS
|
||||
bgnotify_lastcmd="$1"
|
||||
bgnotify_lastcmd="${1:-$2}"
|
||||
bgnotify_windowid=$(currentWindowId)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ This plugin adds completion for [Bower](https://bower.io/) and a few useful alia
|
||||
|
||||
To use it, add `bower` to the plugins array in your zshrc file:
|
||||
|
||||
```
|
||||
```zsh
|
||||
plugins=(... bower)
|
||||
```
|
||||
|
||||
@@ -15,4 +15,3 @@ plugins=(... bower)
|
||||
| bi | `bower install` | Installs the project dependencies listed in bower.json |
|
||||
| bl | `bower list` | List local packages and possible updates |
|
||||
| bs | `bower search` | Finds all packages or a specific package. |
|
||||
|
||||
|
||||
@@ -3,19 +3,28 @@
|
||||
The plugin adds several aliases for common [brew](https://brew.sh) commands.
|
||||
|
||||
To use it, add `brew` to the plugins array of your zshrc file:
|
||||
```
|
||||
|
||||
```zsh
|
||||
plugins=(... brew)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|--------|----------------------|---------------|
|
||||
| brewp | `brew pin` | Pin a specified formulae, preventing them from being upgraded when issuing the brew upgrade <formulae> command. |
|
||||
| brews | `brew list -1` | List installed formulae, one entry per line, or the installed files for a given formulae. |
|
||||
| brewsp | `brew list --pinned` | Show the versions of pinned formulae, or only the specified (pinned) formulae if formulae are given. |
|
||||
| bubo | `brew update && brew outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated formulae. |
|
||||
| bubc | `brew upgrade && brew cleanup` | Upgrade outdated, unpinned brews (with existing install options), then removes stale lock files and outdated downloads for formulae and casks, and removes old versions of installed formulae. |
|
||||
| bubu | `bubo && bubc` | Updates Homebrew, lists outdated formulae, upgrades oudated and unpinned formulae, and removes stale and outdated downloads and versions. |
|
||||
| bcubo | `brew update && brew cask outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated casks. |
|
||||
| bcubc | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Updates outdated casks, then runs 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
|
||||
|
||||
With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the
|
||||
brew installation, so we no longer ship it with the brew plugin; now it only has brew
|
||||
aliases. If you find that brew completion no longer works, make sure you have your Homebrew
|
||||
installation fully up to date.
|
||||
|
||||
@@ -4,21 +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'
|
||||
|
||||
if command mkdir "$ZSH_CACHE_DIR/.brew-completion-message" 2>/dev/null; then
|
||||
print -P '%F{yellow}'Oh My Zsh brew plugin:
|
||||
cat <<-'EOF'
|
||||
|
||||
With the advent of their 1.0 release, Homebrew has decided to bundle
|
||||
the zsh completion as part of the brew installation, so we no longer
|
||||
ship it with the brew plugin; now it only has brew aliases.
|
||||
|
||||
If you find that brew completion no longer works, make sure you have
|
||||
your Homebrew installation fully up to date.
|
||||
|
||||
You will only see this message once.
|
||||
EOF
|
||||
print -P '%f'
|
||||
fi
|
||||
alias buf='brew upgrade --formula'
|
||||
alias bcubo='brew update && brew outdated --cask'
|
||||
alias bcubc='brew cask reinstall $(brew outdated --cask) && brew cleanup'
|
||||
|
||||
@@ -1,52 +1,74 @@
|
||||
# Bundler
|
||||
|
||||
- adds completion for basic bundler commands
|
||||
- adds short aliases for common bundler commands
|
||||
- `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`)
|
||||
- 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`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
|
||||
|
||||
## Configuration
|
||||
`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`.
|
||||
|
||||
Please use the exact name of the executable and not the gem name.
|
||||
### Settings
|
||||
|
||||
### Add additional gems to be wrapped
|
||||
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.
|
||||
|
||||
#### 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)
|
||||
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)
|
||||
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/robbyrussell/oh-my-zsh/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`
|
||||
|
||||
@@ -1,11 +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"
|
||||
|
||||
## 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
|
||||
@@ -27,6 +65,7 @@ bundled_commands=(
|
||||
rainbows
|
||||
rake
|
||||
rspec
|
||||
rubocop
|
||||
shotgun
|
||||
sidekiq
|
||||
spec
|
||||
@@ -51,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" ] && 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
|
||||
|
||||
@@ -10,6 +10,6 @@ plugins=(... cake)
|
||||
|
||||
## Note
|
||||
|
||||
This plugin generates a cache file of the cake tasks found, named `.cake_task_cache`, in the current working directory.
|
||||
This plugin generates a cache file of the cake tasks found, named `.cake_task_cache`, in the current working directory.
|
||||
It is regenerated when the Cakefile is newer than the cache file. It is advised that you add the cake file to your
|
||||
`.gitignore` files.
|
||||
|
||||
16
zsh/plugins/cakephp3/README.md
Normal file
16
zsh/plugins/cakephp3/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# cakephp3 plugin
|
||||
|
||||
The plugin adds aliases and autocompletion for [cakephp3](https://book.cakephp.org/3.0/en/index.html).
|
||||
|
||||
To use it, add `cakephp3` to the plugins array of your zshrc file:
|
||||
```
|
||||
plugins=(... cakephp3)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
|-----------|-------------------------------|
|
||||
| c3 | `bin/cake` |
|
||||
| c3cache | `bin/cake orm_cache clear` |
|
||||
| c3migrate | `bin/cake migrations migrate` |
|
||||
@@ -2,489 +2,367 @@
|
||||
|
||||
autoload -U regexp-replace
|
||||
|
||||
zstyle -T ':completion:*:*:cargo:*' tag-order && \
|
||||
zstyle ':completion:*:*:cargo:*' tag-order 'common-commands'
|
||||
|
||||
_cargo() {
|
||||
local context state state_descr line
|
||||
typeset -A opt_args
|
||||
local curcontext="$curcontext" ret=1
|
||||
local -a command_scope_spec common parallel features msgfmt triple target registry
|
||||
local -a state line state_descr # These are set by _arguments
|
||||
typeset -A opt_args
|
||||
|
||||
# leading items in parentheses are an exclusion list for the arguments following that arg
|
||||
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
|
||||
# - => exclude all other options
|
||||
# 1 => exclude positional arg 1
|
||||
# * => exclude all other args
|
||||
# +blah => exclude +blah
|
||||
_arguments \
|
||||
'(- 1 *)'{-h,--help}'[show help message]' \
|
||||
'(- 1 *)--list[list installed commands]' \
|
||||
'(- 1 *)'{-V,--version}'[show version information]' \
|
||||
{-v,--verbose}'[use verbose output]' \
|
||||
--color'[colorization option]' \
|
||||
'(+beta +nightly)+stable[use the stable toolchain]' \
|
||||
'(+stable +nightly)+beta[use the beta toolchain]' \
|
||||
'(+stable +beta)+nightly[use the nightly toolchain]' \
|
||||
'1: :->command' \
|
||||
'*:: :->args'
|
||||
common=(
|
||||
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
|
||||
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
|
||||
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
|
||||
'--frozen[require that Cargo.lock and cache are up-to-date]'
|
||||
'--locked[require that Cargo.lock is up-to-date]'
|
||||
'--color=[specify colorization option]:coloring:(auto always never)'
|
||||
'(- 1 *)'{-h,--help}'[show help message]'
|
||||
)
|
||||
|
||||
case $state in
|
||||
command)
|
||||
_alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds'
|
||||
;;
|
||||
# leading items in parentheses are an exclusion list for the arguments following that arg
|
||||
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
|
||||
# - => exclude all other options
|
||||
# 1 => exclude positional arg 1
|
||||
# * => exclude all other args
|
||||
# +blah => exclude +blah
|
||||
_arguments -s -S -C $common \
|
||||
'(- 1 *)--list[list installed commands]' \
|
||||
'(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \
|
||||
'(- 1 *)'{-V,--version}'[show version information]' \
|
||||
'(+beta +nightly)+stable[use the stable toolchain]' \
|
||||
'(+stable +nightly)+beta[use the beta toolchain]' \
|
||||
'(+stable +beta)+nightly[use the nightly toolchain]' \
|
||||
'1: :_cargo_cmds' \
|
||||
'*:: :->args'
|
||||
|
||||
args)
|
||||
case $words[1] in
|
||||
bench)
|
||||
_arguments \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'--no-run[compile but do not run]' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
|
||||
'--target=[target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
# These flags are mutually exclusive specifiers for the scope of a command; as
|
||||
# they are used in multiple places without change, they are expanded into the
|
||||
# appropriate command's `_arguments` where appropriate.
|
||||
command_scope_spec=(
|
||||
'(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names'
|
||||
'(--bench --bin --test --lib)--example=[specify example name]:example name'
|
||||
'(--bench --example --test --lib)--bin=[specify binary name]:binary name'
|
||||
'(--bench --bin --example --test)--lib=[specify library name]:library name'
|
||||
'(--bench --bin --example --lib)--test=[specify test name]:test name'
|
||||
)
|
||||
|
||||
build)
|
||||
_arguments \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \
|
||||
'--release=[build in release mode]' \
|
||||
'--target=[target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
parallel=(
|
||||
'(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
|
||||
)
|
||||
|
||||
check)
|
||||
_arguments \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-default-features[do not check the default features]' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to check]:packages:_get_package_names' \
|
||||
'--release=[check in release mode]' \
|
||||
'--target=[target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
features=(
|
||||
'(--all-features)--features=[specify features to activate]:feature'
|
||||
'(--features)--all-features[activate all available features]'
|
||||
"--no-default-features[don't build the default features]"
|
||||
)
|
||||
|
||||
clean)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--release[whether or not to clean release artifacts]' \
|
||||
'--target=[target triple(default:all)]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
msgfmt='--message-format=[specify error format]:error format [human]:(human json short)'
|
||||
triple='--target=[specify target triple]:target triple'
|
||||
target='--target-dir=[specify directory for all generated artifacts]:directory:_directories'
|
||||
manifest='--manifest-path=[specify path to manifest]:path:_directories'
|
||||
registry='--registry=[specify registry to use]:registry'
|
||||
|
||||
doc)
|
||||
_arguments \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-deps[do not build docs for dependencies]' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'--open[open docs in browser after the build]' \
|
||||
'(-p, --package)'{-p,--package}'=[package to document]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
'--target=[build for the target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
case $state in
|
||||
args)
|
||||
curcontext="${curcontext%:*}-${words[1]}:"
|
||||
case ${words[1]} in
|
||||
bench)
|
||||
_arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--all-targets[benchmark all targets]' \
|
||||
"--no-run[compile but don't run]" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
|
||||
'--exclude=[exclude packages from the benchmark]:spec' \
|
||||
'--no-fail-fast[run all benchmarks regardless of failure]' \
|
||||
'1: :_guard "^-*" "bench name"' \
|
||||
'*:args:_default'
|
||||
;;
|
||||
|
||||
fetch)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
build)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
|
||||
'--release[build in release mode]' \
|
||||
'--build-plan[output the build plan in JSON]' \
|
||||
;;
|
||||
|
||||
generate-lockfile)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
check)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
|
||||
'--release[check in release mode]' \
|
||||
;;
|
||||
|
||||
git-checkout)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--reference=[REF]' \
|
||||
'--url=[URL]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
clean)
|
||||
_arguments -s -S $common $triple $target $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \
|
||||
'--release[clean release artifacts]' \
|
||||
'--doc[clean just the documentation directory]'
|
||||
;;
|
||||
|
||||
help)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'*: :_cargo_cmds' \
|
||||
;;
|
||||
doc)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--no-deps[do not build docs for dependencies]' \
|
||||
'--document-private-items[include non-public items in the documentation]' \
|
||||
'--open[open docs in browser after the build]' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
;;
|
||||
|
||||
init)
|
||||
_arguments \
|
||||
'--bin[use binary template]' \
|
||||
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--name=[set the resulting package name]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
fetch)
|
||||
_arguments -s -S $common $triple $manifest
|
||||
;;
|
||||
|
||||
install)
|
||||
_arguments \
|
||||
'--bin=[only install the specified binary]' \
|
||||
'--branch=[branch to use when installing from git]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--debug[build in debug mode instead of release mode]' \
|
||||
'--example[install the specified example instead of binaries]' \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'--git=[URL from which to install the crate]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'--path=[local filesystem path to crate to install]: :_files -/' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--rev=[specific commit to use when installing from git]' \
|
||||
'--root=[directory to install packages into]: :_files -/' \
|
||||
'--tag=[tag to use when installing from git]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--vers=[version to install from crates.io]' \
|
||||
;;
|
||||
fix)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--broken-code[fix code even if it already has compiler errors]' \
|
||||
'--edition[fix in preparation for the next edition]' \
|
||||
'--edition-idioms[fix warnings to migrate to the idioms of an edition]' \
|
||||
'--allow-no-vcs[fix code even if a VCS was not detected]' \
|
||||
'--allow-dirty[fix code even if the working directory is dirty]' \
|
||||
'--allow-staged[fix code even if the working directory has staged changes]'
|
||||
;;
|
||||
|
||||
locate-project)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
;;
|
||||
generate-lockfile)
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
login)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--host=[Host to set the token for]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
git-checkout)
|
||||
_arguments -s -S $common \
|
||||
'--reference=:reference' \
|
||||
'--url=:url:_urls'
|
||||
;;
|
||||
|
||||
metadata)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
"--no-deps[output information only about the root package and don't fetch dependencies]" \
|
||||
'--no-default-features[do not include the default feature]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'--format-version=[format version(default: 1)]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
help)
|
||||
_cargo_cmds
|
||||
;;
|
||||
|
||||
new)
|
||||
_arguments \
|
||||
'--bin[use binary template]' \
|
||||
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--name=[set the resulting package name]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
init)
|
||||
_arguments -s -S $common $registry \
|
||||
'--lib[use library template]' \
|
||||
'--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \
|
||||
'--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \
|
||||
'--name=[set the resulting package name]:name' \
|
||||
'1:path:_directories'
|
||||
;;
|
||||
|
||||
owner)
|
||||
_arguments \
|
||||
'(-a, --add)'{-a,--add}'[add owner LOGIN]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--index[registry index]' \
|
||||
'(-l, --list)'{-l,--list}'[list owners of a crate]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \
|
||||
'--token[API token to use when authenticating]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
install)
|
||||
_arguments -s -S $common $parallel $features $triple $registry \
|
||||
'(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \
|
||||
'--bin=[only install the specified binary]:binary' \
|
||||
'--branch=[branch to use when installing from git]:branch' \
|
||||
'--debug[build in debug mode instead of release mode]' \
|
||||
'--example=[install the specified example instead of binaries]:example' \
|
||||
'--git=[specify URL from which to install the crate]:url:_urls' \
|
||||
'--path=[local filesystem path to crate to install]: :_directories' \
|
||||
'--rev=[specific commit to use when installing from git]:commit' \
|
||||
'--root=[directory to install packages into]: :_directories' \
|
||||
'--tag=[tag to use when installing from git]:tag' \
|
||||
'--vers=[version to install from crates.io]:version' \
|
||||
'--list[list all installed packages and their versions]' \
|
||||
'*: :_guard "^-*" "crate"'
|
||||
;;
|
||||
|
||||
package)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-l, --list)'{-l,--list}'[print files included in a package without making one]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
|
||||
'--no-verify[do not build to verify contents]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
locate-project)
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
pkgid)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
login)
|
||||
_arguments -s -S $common $registry \
|
||||
'*: :_guard "^-*" "token"'
|
||||
;;
|
||||
|
||||
publish)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--host=[Host to set the token for]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-verify[Do not verify tarball until before publish]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--token[token to use when uploading]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
metadata)
|
||||
_arguments -s -S $common $features $manifest \
|
||||
"--no-deps[output information only about the root package and don't fetch dependencies]" \
|
||||
'--format-version=[specify format version]:version [1]:(1)'
|
||||
;;
|
||||
|
||||
read-manifest)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
new)
|
||||
_arguments -s -S $common $registry \
|
||||
'--lib[use library template]' \
|
||||
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
|
||||
'--name=[set the resulting package name]'
|
||||
;;
|
||||
|
||||
run)
|
||||
_arguments \
|
||||
'--example=[name of the bin target]' \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--bin=[name of the bin target]' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--release=[build in release mode]' \
|
||||
'--target=[target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'*: :_normal' \
|
||||
;;
|
||||
owner)
|
||||
_arguments -s -S $common $registry \
|
||||
'(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
|
||||
'--index=[specify registry index]:index' \
|
||||
'(-l --list)'{-l,--list}'[list owners of a crate]' \
|
||||
'(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \
|
||||
'--token=[specify API token to use when authenticating]:token' \
|
||||
'*: :_guard "^-*" "crate"'
|
||||
;;
|
||||
|
||||
rustc)
|
||||
_arguments \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--features=[features to compile for the package]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
|
||||
'--manifest-path=[path to the manifest to fetch dependencies for]: :_files -/' \
|
||||
'--no-default-features[do not compile default features for the package]' \
|
||||
'(-p, --package)'{-p,--package}'=[profile to compile for]' \
|
||||
'--profile=[profile to build the selected target for]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
'--target=[target triple which compiles will be for]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
;;
|
||||
package)
|
||||
_arguments -s -S $common $parallel $features $triple $target $manifest \
|
||||
'(-l --list)'{-l,--list}'[print files included in a package without making one]' \
|
||||
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
|
||||
'--allow-dirty[allow dirty working directories to be packaged]' \
|
||||
"--no-verify[don't build to verify contents]"
|
||||
;;
|
||||
|
||||
rustdoc)
|
||||
_arguments \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--features=[space-separated list of features to also build]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
|
||||
'--manifest-path=[path to the manifest to document]: :_files -/' \
|
||||
'--no-default-features[do not build the `default` feature]' \
|
||||
'--open[open the docs in a browser after the operation]' \
|
||||
'(-p, --package)'{-p,--package}'=[package to document]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
'--target=[build for the target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
;;
|
||||
pkgid)
|
||||
_arguments -s -S $common $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
|
||||
'*: :_guard "^-*" "spec"'
|
||||
;;
|
||||
|
||||
search)
|
||||
_arguments \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--host=[host of a registry to search in]' \
|
||||
'--limit=[limit the number of results]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
;;
|
||||
publish)
|
||||
_arguments -s -S $common $parallel $features $triple $target $manifest $registry \
|
||||
'--index=[specify registry index]:index' \
|
||||
'--allow-dirty[allow dirty working directories to be packaged]' \
|
||||
"--no-verify[don't verify the contents by building them]" \
|
||||
'--token=[specify token to use when uploading]:token' \
|
||||
'--dry-run[perform all checks without uploading]'
|
||||
;;
|
||||
|
||||
test)
|
||||
_arguments \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--test=[test name]: :_test_names' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'--no-fail-fast[run all tests regardless of failure]' \
|
||||
'--no-run[compile but do not run]' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
'--target=[target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'1: :_test_names' \
|
||||
'(--doc --bin --example --test --bench)--lib[only test library]' \
|
||||
'(--lib --bin --example --test --bench)--doc[only test documentation]' \
|
||||
'(--lib --doc --example --test --bench)--bin=[binary name]' \
|
||||
'(--lib --doc --bin --test --bench)--example=[example name]' \
|
||||
'(--lib --doc --bin --example --bench)--test=[test name]' \
|
||||
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
|
||||
'--message-format:error format:(human json short)' \
|
||||
'--frozen[require lock and cache up to date]' \
|
||||
'--locked[require lock up to date]'
|
||||
;;
|
||||
read-manifest)
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
uninstall)
|
||||
_arguments \
|
||||
'--bin=[only uninstall the binary NAME]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
|
||||
'--root=[directory to uninstall packages from]: :_files -/' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
;;
|
||||
run)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--example=[name of the bin target]:name' \
|
||||
'--bin=[name of the bin target]:name' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
|
||||
'--release[build in release mode]' \
|
||||
'*: :_default'
|
||||
;;
|
||||
|
||||
update)
|
||||
_arguments \
|
||||
'--aggressive=[force dependency update]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \
|
||||
'--precise=[update single dependency to PRECISE]: :' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
rustc)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
|
||||
'--profile=[specify profile to build the selected target for]:profile' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'*: : _dispatch rustc rustc -default-'
|
||||
;;
|
||||
|
||||
verify-project)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
rustdoc)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--document-private-items[include non-public items in the documentation]' \
|
||||
'--open[open the docs in a browser after the operation]' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'*: : _dispatch rustdoc rustdoc -default-'
|
||||
;;
|
||||
|
||||
version)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
;;
|
||||
search)
|
||||
_arguments -s -S $common $registry \
|
||||
'--index=[specify registry index]:index' \
|
||||
'--limit=[limit the number of results]:results [10]' \
|
||||
'*: :_guard "^-*" "query"'
|
||||
;;
|
||||
|
||||
yank)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--index[registry index]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--token[API token to use when authenticating]' \
|
||||
'--undo[undo a yank, putting a version back into the index]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--vers[yank version]' \
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
test)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--test=[test name]: :_cargo_test_names' \
|
||||
'--no-fail-fast[run all tests regardless of failure]' \
|
||||
'--no-run[compile but do not run]' \
|
||||
'(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \
|
||||
'--all[test all packages in the workspace]' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
'1: :_cargo_test_names' \
|
||||
'(--doc --bin --example --test --bench)--lib[only test library]' \
|
||||
'(--lib --bin --example --test --bench)--doc[only test documentation]' \
|
||||
'(--lib --doc --example --test --bench)--bin=[binary name]' \
|
||||
'(--lib --doc --bin --test --bench)--example=[example name]' \
|
||||
'(--lib --doc --bin --example --bench)--test=[test name]' \
|
||||
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
|
||||
'*: :_default'
|
||||
;;
|
||||
|
||||
uninstall)
|
||||
_arguments -s -S $common \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \
|
||||
'--bin=[only uninstall the specified binary]:name' \
|
||||
'--root=[directory to uninstall packages from]: :_files -/' \
|
||||
'*:crate:_cargo_installed_crates -F line'
|
||||
;;
|
||||
|
||||
update)
|
||||
_arguments -s -S $common $manifest \
|
||||
'--aggressive=[force dependency update]' \
|
||||
"--dry-run[don't actually write the lockfile]" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
|
||||
'--precise=[update single dependency to precise release]:release'
|
||||
;;
|
||||
|
||||
verify-project)
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
version)
|
||||
_arguments -s -S $common
|
||||
;;
|
||||
|
||||
yank)
|
||||
_arguments -s -S $common $registry \
|
||||
'--vers=[specify yank version]:version' \
|
||||
'--undo[undo a yank, putting a version back into the index]' \
|
||||
'--index=[specify registry index to yank from]:registry index' \
|
||||
'--token=[specify API token to use when authenticating]:token' \
|
||||
'*: :_guard "^-*" "crate"'
|
||||
;;
|
||||
*)
|
||||
# allow plugins to define their own functions
|
||||
if ! _call_function ret _cargo-${words[1]}; then
|
||||
# fallback on default completion for unknown commands
|
||||
_default && ret=0
|
||||
fi
|
||||
(( ! ret ))
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_cargo_cmds(){
|
||||
local -a commands;commands=(
|
||||
'bench:execute all benchmarks of a local package'
|
||||
'build:compile the current package'
|
||||
'check:check the current package without compiling'
|
||||
'clean:remove generated artifacts'
|
||||
'doc:build package documentation'
|
||||
'fetch:fetch package dependencies'
|
||||
'generate-lockfile:create lockfile'
|
||||
'git-checkout:git checkout'
|
||||
'help:get help for commands'
|
||||
'init:create new package in current directory'
|
||||
'install:install a Rust binary'
|
||||
'locate-project:print "Cargo.toml" location'
|
||||
'login:login to remote server'
|
||||
'metadata:the metadata for a package in json'
|
||||
'new:create a new package'
|
||||
'owner:manage the owners of a crate on the registry'
|
||||
'package:assemble local package into a distributable tarball'
|
||||
'pkgid:print a fully qualified package specification'
|
||||
'publish:upload package to the registry'
|
||||
'read-manifest:print manifest in JSON format'
|
||||
'run:run the main binary of the local package'
|
||||
'rustc:compile a package and all of its dependencies'
|
||||
'rustdoc:build documentation for a package'
|
||||
'search:search packages on crates.io'
|
||||
'test:execute all unit and tests of a local package'
|
||||
'uninstall:remove a Rust binary'
|
||||
'update:update dependencies'
|
||||
'verify-project:check Cargo.toml'
|
||||
'version:show version information'
|
||||
'yank:remove pushed file from index'
|
||||
)
|
||||
_describe -t common-commands 'common commands' commands
|
||||
_cargo_unstable_flags() {
|
||||
local flags
|
||||
flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
|
||||
_describe -t flags 'unstable flag' flags
|
||||
}
|
||||
|
||||
_cargo_all_cmds(){
|
||||
local -a commands;commands=($(cargo --list))
|
||||
_describe -t all-commands 'all commands' commands
|
||||
_cargo_installed_crates() {
|
||||
local expl
|
||||
_description crates expl 'crate'
|
||||
compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
|
||||
}
|
||||
|
||||
_cargo_cmds() {
|
||||
local -a commands
|
||||
# This uses Parameter Expansion Flags, which are a built-in Zsh feature.
|
||||
# See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
|
||||
# and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
|
||||
#
|
||||
# # How this work?
|
||||
#
|
||||
# First it splits the result of `cargo --list` at newline, then it removes the first line.
|
||||
# Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
|
||||
# Then it replaces those spaces between item and description with a `:`
|
||||
#
|
||||
# [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
|
||||
commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} )
|
||||
_describe -t commands 'command' commands
|
||||
}
|
||||
|
||||
|
||||
#FIXME: Disabled until fixed
|
||||
#gets package names from the manifest file
|
||||
_get_package_names()
|
||||
{
|
||||
}
|
||||
|
||||
#TODO:see if it makes sense to have 'locate-project' to have non-json output.
|
||||
#strips package name from json stuff
|
||||
_locate_manifest(){
|
||||
local manifest=`cargo locate-project 2>/dev/null`
|
||||
regexp-replace manifest '\{"root":"|"\}' ''
|
||||
echo $manifest
|
||||
_cargo_package_names() {
|
||||
_message -e packages package
|
||||
}
|
||||
|
||||
# Extracts the values of "name" from the array given in $1 and shows them as
|
||||
# command line options for completion
|
||||
_get_names_from_array()
|
||||
{
|
||||
local -a filelist;
|
||||
local manifest=$(_locate_manifest)
|
||||
_cargo_names_from_array() {
|
||||
# strip json from the path
|
||||
local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
|
||||
if [[ -z $manifest ]]; then
|
||||
return 0
|
||||
fi
|
||||
@@ -494,51 +372,36 @@ _get_names_from_array()
|
||||
local in_block=false
|
||||
local block_name=$1
|
||||
names=()
|
||||
while read line
|
||||
do
|
||||
while read -r line; do
|
||||
if [[ $last_line == "[[$block_name]]" ]]; then
|
||||
in_block=true
|
||||
else
|
||||
if [[ $last_line =~ '.*\[\[.*' ]]; then
|
||||
if [[ $last_line =~ '\s*\[\[.*' ]]; then
|
||||
in_block=false
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $in_block == true ]]; then
|
||||
if [[ $line =~ '.*name.*=' ]]; then
|
||||
regexp-replace line '^.*name *= *|"' ""
|
||||
names+=$line
|
||||
if [[ $line =~ '\s*name\s*=' ]]; then
|
||||
regexp-replace line '^\s*name\s*=\s*|"' ''
|
||||
names+=( "$line" )
|
||||
fi
|
||||
fi
|
||||
|
||||
last_line=$line
|
||||
done < $manifest
|
||||
_describe $block_name names
|
||||
done < "$manifest"
|
||||
_describe "$block_name" names
|
||||
|
||||
}
|
||||
|
||||
#Gets the test names from the manifest file
|
||||
_test_names()
|
||||
{
|
||||
_get_names_from_array "test"
|
||||
_cargo_test_names() {
|
||||
_cargo_names_from_array "test"
|
||||
}
|
||||
|
||||
#Gets the bench names from the manifest file
|
||||
_benchmark_names()
|
||||
{
|
||||
_get_names_from_array "bench"
|
||||
_cargo_benchmark_names() {
|
||||
_cargo_names_from_array "bench"
|
||||
}
|
||||
|
||||
# These flags are mutually exclusive specifiers for the scope of a command; as
|
||||
# they are used in multiple places without change, they are expanded into the
|
||||
# appropriate command's `_arguments` where appropriate.
|
||||
set command_scope_spec
|
||||
command_scope_spec=(
|
||||
'(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names'
|
||||
'(--bench --bin --test --lib)--example=[example name]'
|
||||
'(--bench --example --test --lib)--bin=[binary name]'
|
||||
'(--bench --bin --example --test)--lib=[library name]'
|
||||
'(--bench --bin --example --lib)--test=[test name]'
|
||||
)
|
||||
|
||||
_cargo
|
||||
|
||||
@@ -2,28 +2,16 @@
|
||||
|
||||
Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
||||
|
||||
To use it, add `catimg` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... catimg)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- `convert` (ImageMagick)
|
||||
|
||||
## Enabling the plugin
|
||||
|
||||
1. Open your `.zshrc` file and add `catimg` in the plugins section:
|
||||
|
||||
```zsh
|
||||
plugins=(
|
||||
# all your enabled plugins
|
||||
catimg
|
||||
)
|
||||
```
|
||||
|
||||
2. Reload the source file or restart your Terminal session:
|
||||
|
||||
```console
|
||||
$ source ~/.zshrc
|
||||
$
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
| Function | Description |
|
||||
|
||||
20
zsh/plugins/chruby/README.md
Normal file
20
zsh/plugins/chruby/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# chruby plugin
|
||||
|
||||
This plugin loads [chruby](https://github.com/postmodern/chruby), a tool that changes the
|
||||
current Ruby version, and completion and a prompt function to display the Ruby version.
|
||||
Supports brew and manual installation of chruby.
|
||||
|
||||
To use it, add `chruby` to the plugins array in your zshrc file:
|
||||
```zsh
|
||||
plugins=(... chruby)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
If you'd prefer to specify an explicit path to load chruby from
|
||||
you can set variables like so:
|
||||
|
||||
```
|
||||
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
|
||||
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
|
||||
```
|
||||
@@ -1,6 +1,6 @@
|
||||
# chucknorris
|
||||
|
||||
Chuck Norris fortunes plugin for oh-my-zsh
|
||||
Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
|
||||
|
||||
**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
|
||||
|
||||
@@ -10,11 +10,31 @@ To use it add `chucknorris` to the plugins array in you zshrc file.
|
||||
plugins=(... chucknorris)
|
||||
```
|
||||
|
||||
|
||||
Depends on fortune (and cowsay if using chuck_cow) being installed (available via homebrew, apt, ...). Perfectly suitable as MOTD.
|
||||
|
||||
## Usage
|
||||
|
||||
| Command | Description |
|
||||
| ----------- | ------------------------------- |
|
||||
| `chuck` | Print random Chuck Norris quote |
|
||||
| `chuck_cow` | Print quote in cowthink |
|
||||
|
||||
Example: output of `chuck_cow`:
|
||||
|
||||
```
|
||||
Last login: Fri Jan 30 23:12:26 on ttys001
|
||||
______________________________________
|
||||
( When Chuck Norris plays Monopoly, it )
|
||||
( affects the actual world economy. )
|
||||
--------------------------------------
|
||||
o ^__^
|
||||
o (oo)\_______
|
||||
(__)\ )\/\
|
||||
||----w |
|
||||
|| ||
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- `fortune`
|
||||
- `cowsay` if using `chuck_cow`
|
||||
|
||||
Available via homebrew, apt, ...
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
26
zsh/plugins/cloudapp/README.md
Normal file
26
zsh/plugins/cloudapp/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# CloudApp plugin
|
||||
|
||||
## The CloudApp API is deprecated, so the plugin will be removed shortly
|
||||
|
||||
[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line.
|
||||
|
||||
To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... cloudapp)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation)
|
||||
|
||||
2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below:
|
||||
```
|
||||
email
|
||||
password
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
- `cloudapp <filename>`: uploads `<filename>` to your CloudApp account, and if you're using
|
||||
macOS, copies the URL to your clipboard.
|
||||
@@ -1,6 +1,4 @@
|
||||
alias cloudapp="${0:a:h}/cloudapp.rb"
|
||||
|
||||
# Ensure only the owner can access the credentials file
|
||||
if [[ -f ~/.cloudapp ]]; then
|
||||
chmod 600 ~/.cloudapp
|
||||
fi
|
||||
print -Pn "%F{yellow}"
|
||||
print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will"
|
||||
print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list."
|
||||
print -Pn "%f"
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
#
|
||||
# cloudapp
|
||||
# Zach Holman / @holman
|
||||
#
|
||||
# Uploads a file from the command line to CloudApp, drops it into your
|
||||
# clipboard (on a Mac, at least).
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# cloudapp drunk-blake.png
|
||||
#
|
||||
# This requires Aaron Russell's cloudapp_api gem:
|
||||
#
|
||||
# gem install cloudapp_api
|
||||
#
|
||||
# Requires you set your CloudApp credentials in ~/.cloudapp as a simple file of:
|
||||
#
|
||||
# email
|
||||
# password
|
||||
|
||||
require 'rubygems'
|
||||
begin
|
||||
require 'cloudapp_api'
|
||||
rescue LoadError
|
||||
puts "You need to install cloudapp_api: gem install cloudapp_api"
|
||||
exit!(1)
|
||||
end
|
||||
|
||||
config_file = "#{ENV['HOME']}/.cloudapp"
|
||||
unless File.exist?(config_file)
|
||||
puts "You need to type your email and password (one per line) into "+
|
||||
"`~/.cloudapp`"
|
||||
exit!(1)
|
||||
end
|
||||
|
||||
email,password = File.read(config_file).split("\n")
|
||||
|
||||
class HTTParty::Response
|
||||
# Apparently HTTPOK.ok? IS NOT OKAY WTFFFFFFFFFFUUUUUUUUUUUUUU
|
||||
# LETS MONKEY PATCH IT I FEEL OKAY ABOUT IT
|
||||
def ok? ; true end
|
||||
end
|
||||
|
||||
if ARGV[0].nil?
|
||||
puts "You need to specify a file to upload."
|
||||
exit!(1)
|
||||
end
|
||||
|
||||
CloudApp.authenticate(email,password)
|
||||
url = CloudApp::Item.create(:upload, {:file => ARGV[0]}).url
|
||||
|
||||
# Say it for good measure.
|
||||
puts "Uploaded to #{url}."
|
||||
|
||||
# Get the embed link.
|
||||
url = "#{url}/#{ARGV[0].split('/').last}"
|
||||
|
||||
# Copy it to your (Mac's) clipboard.
|
||||
`echo '#{url}' | tr -d "\n" | pbcopy`
|
||||
8
zsh/plugins/codeclimate/README.md
Normal file
8
zsh/plugins/codeclimate/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# codeclimate plugin
|
||||
|
||||
This plugin adds autocompletion for the [`codeclimate` CLI](https://github.com/codeclimate/codeclimate).
|
||||
|
||||
To use it, add `codeclimate` to the plugins array in your zshrc file:
|
||||
```zsh
|
||||
plugins=(... codeclimate)
|
||||
```
|
||||
@@ -1,4 +1,4 @@
|
||||
## Coffeescript Plugin
|
||||
# Coffeescript Plugin
|
||||
|
||||
This plugin provides aliases for quickly compiling and previewing your
|
||||
coffeescript code.
|
||||
|
||||
48
zsh/plugins/colemak/README.md
Normal file
48
zsh/plugins/colemak/README.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# Colemak plugin
|
||||
|
||||
This plugin remaps keys in `zsh`'s [`vi`-style navigation mode](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Keymaps)
|
||||
for a [Colemak](https://colemak.com/) keyboard layout, to match the QWERTY position:
|
||||
|
||||

|
||||
|
||||
To use it, add it to the plugins array in your `~/.zshrc` file:
|
||||
|
||||
```
|
||||
plugins=(... colemak)
|
||||
```
|
||||
|
||||
You will also need to enable `vi` mode, so add another line to `~/.zshrc`:
|
||||
```
|
||||
bindkey -v
|
||||
```
|
||||
|
||||
Restart your shell and hit the `<ESC>` key to activate `vicmd` (navigation) mode,
|
||||
and start navigating `zsh` with your new keybindings!
|
||||
|
||||
## Key bindings for vicmd
|
||||
|
||||
| Old | New | Binding | Description |
|
||||
|------------|------------|---------------------------|----------------------------------------------------|
|
||||
| `CTRL`+`j` | `CTRL`+`n` | accept-line | Insert new line |
|
||||
| `j` | `n` | down-line-or-history | Move one line down or command history forwards |
|
||||
| `k` | `e` | up-line-or-history | Move one line up or command history backwards |
|
||||
| `l` | `i` | vi-forward-char | Move one character to the right |
|
||||
| `n` | `k` | vi-repeat-search | Repeat command search forwards |
|
||||
| `N` | `K` | vi-rev-repeat-search | Repeat command search backwards |
|
||||
| `i` | `u` | vi-insert | Enter insert mode |
|
||||
| `I` | `U` | vi-insert-bol | Move to first non-blank char and enter insert mode |
|
||||
| `<none>` | `l` | vi-undo-change | Undo change |
|
||||
| `J` | `N` | vi-join | Join the current line with the next one |
|
||||
| `e` | `j` | vi-forward-word-end | Move to the end of the next word |
|
||||
| `E` | `J` | vi-forward-blank-word-end | Move to end of the current or next word |
|
||||
|
||||
## Key bindings for less
|
||||
|
||||
| Keyboard shortcut | `less` key binding |
|
||||
|-------------------|--------------------|
|
||||
| `n` | forw-line |
|
||||
| `e` | back-line |
|
||||
| `k` | repeat-search |
|
||||
| `ESC`+`k` | repeat-search-all |
|
||||
| `K` | reverse-search |
|
||||
| `ESC`+`K` | reverse-search-all |
|
||||
@@ -8,6 +8,9 @@ To use it, add `colored-man-pages` to the plugins array in your zshrc file:
|
||||
plugins=(... colored-man-pages)
|
||||
```
|
||||
|
||||
It will also automatically colorize man pages displayed by `dman` or `debman`,
|
||||
from [`debian-goodies`](https://packages.debian.org/stable/debian-goodies).
|
||||
|
||||
You can also try to color other pages by prefixing the respective command with `colored`:
|
||||
|
||||
```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") \
|
||||
@@ -31,6 +31,9 @@ function colored() {
|
||||
"$@"
|
||||
}
|
||||
|
||||
function man() {
|
||||
colored man "$@"
|
||||
# Colorize man and dman/debman (from debian-goodies)
|
||||
function man \
|
||||
dman \
|
||||
debman {
|
||||
colored $0 "$@"
|
||||
}
|
||||
|
||||
@@ -6,30 +6,51 @@ Colorize will highlight the content based on the filename extension. If it can't
|
||||
method for a given extension, it will try to find one by looking at the file contents. If no highlight method
|
||||
is found it will just cat the file normally, without syntax highlighting.
|
||||
|
||||
To use it, add colorize to the plugins array of your zshrc file:
|
||||
## Setup
|
||||
|
||||
To use it, add colorize to the plugins array of your `~/.zshrc` file:
|
||||
```
|
||||
plugins=(... colorize)
|
||||
```
|
||||
|
||||
## Styles
|
||||
## Configuration
|
||||
|
||||
### Requirements
|
||||
|
||||
This plugin requires that at least one of the following tools is installed:
|
||||
|
||||
* [Chroma](https://github.com/alecthomas/chroma)
|
||||
* [Pygments](https://pygments.org/download/)
|
||||
|
||||
### Colorize tool
|
||||
|
||||
Colorize supports `pygmentize` and `chroma` as syntax highlighter. By default colorize uses `pygmentize` unless it's not installed and `chroma` is. This can be overridden by the `ZSH_COLORIZE_TOOL` environment variable:
|
||||
|
||||
```
|
||||
ZSH_COLORIZE_TOOL=chroma
|
||||
```
|
||||
|
||||
### Styles
|
||||
|
||||
Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable:
|
||||
|
||||
`ZSH_COLORIZE_STYLE="colorful"`
|
||||
```
|
||||
ZSH_COLORIZE_STYLE="colorful"
|
||||
```
|
||||
|
||||
### Chroma Formatter Settings
|
||||
|
||||
Chroma supports terminal output in 8 color, 256 color, and true-color. If you need to change the default terminal output style from the standard 8 color output, set the `ZSH_COLORIZE_CHROMA_FORMATTER` environment variable:
|
||||
|
||||
```
|
||||
ZSH_COLORIZE_CHROMA_FORMATTER=terminal256
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
|
||||
If no arguments are passed it will colorize the standard input or stdin.
|
||||
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
|
||||
If no files are passed it will colorize the standard input.
|
||||
|
||||
* `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and
|
||||
open less. If no arguments are passed it will colorize the standard input or stdin.
|
||||
|
||||
Note that `cless` will behave as less when provided more than one file: you have to navigate files with
|
||||
the commands `:n` for next and `:p` for previous. The downside is that less options are not supported.
|
||||
But you can circumvent this by either using the LESS environment variable, or by running `ccat file1 file2|less --opts`.
|
||||
In the latter form, the file contents will be concatenated and presented by less as a single file.
|
||||
|
||||
## Requirements
|
||||
|
||||
You have to install Pygments first: [pygments.org](http://pygments.org/download/)
|
||||
* `cless [less-options] <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and open less.
|
||||
If no files are passed it will colorize the standard input.
|
||||
The LESSOPEN and LESSCLOSE will be overwritten for this to work, but only in a local scope.
|
||||
|
||||
@@ -1,57 +1,113 @@
|
||||
# easier alias to use the plugin
|
||||
alias ccat='colorize_via_pygmentize'
|
||||
alias cless='colorize_via_pygmentize_less'
|
||||
# Easier alias to use the plugin
|
||||
alias ccat="colorize_cat"
|
||||
alias cless="colorize_less"
|
||||
|
||||
colorize_via_pygmentize() {
|
||||
if ! (( $+commands[pygmentize] )); then
|
||||
echo "package 'Pygments' is not installed!"
|
||||
# '$0:A' gets the absolute path of this file
|
||||
ZSH_COLORIZE_PLUGIN_PATH=$0:A
|
||||
|
||||
colorize_check_requirements() {
|
||||
local available_tools=("chroma" "pygmentize")
|
||||
|
||||
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
|
||||
if (( $+commands[pygmentize] )); then
|
||||
ZSH_COLORIZE_TOOL="pygmentize"
|
||||
elif (( $+commands[chroma] )); then
|
||||
ZSH_COLORIZE_TOOL="chroma"
|
||||
else
|
||||
echo "Neither 'pygments' nor 'chroma' is installed!" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then
|
||||
echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2
|
||||
return 1
|
||||
elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then
|
||||
echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
colorize_cat() {
|
||||
if ! colorize_check_requirements; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If the environment varianle ZSH_COLORIZE_STYLE
|
||||
# If the environment variable ZSH_COLORIZE_STYLE
|
||||
# is set, use that theme instead. Otherwise,
|
||||
# use the default.
|
||||
if [ -z $ZSH_COLORIZE_STYLE ]; then
|
||||
ZSH_COLORIZE_STYLE="default"
|
||||
if [ -z "$ZSH_COLORIZE_STYLE" ]; then
|
||||
# Both pygmentize & chroma support 'emacs'
|
||||
ZSH_COLORIZE_STYLE="emacs"
|
||||
fi
|
||||
|
||||
# pygmentize stdin if no arguments passed
|
||||
# Use stdin if no arguments have been passed.
|
||||
if [ $# -eq 0 ]; then
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
|
||||
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
|
||||
else
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
|
||||
# guess lexer from file extension, or
|
||||
# guess it from file contents if unsuccessful
|
||||
|
||||
# Guess lexer from file extension, or guess it from file contents if unsuccessful.
|
||||
local FNAME lexer
|
||||
for FNAME in "$@"
|
||||
do
|
||||
lexer=$(pygmentize -N "$FNAME")
|
||||
if [[ $lexer != text ]]; then
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
|
||||
for FNAME in "$@"; do
|
||||
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
|
||||
lexer=$(pygmentize -N "$FNAME")
|
||||
if [[ $lexer != text ]]; then
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
|
||||
else
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
|
||||
fi
|
||||
else
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
colorize_via_pygmentize_less() (
|
||||
# this function is a subshell so tmp_files can be shared to cleanup function
|
||||
declare -a tmp_files
|
||||
# The less option 'F - Forward forever; like "tail -f".' will not work in this implementation
|
||||
# caused by the lack of the ability to follow the file within pygmentize.
|
||||
colorize_less() {
|
||||
if ! colorize_check_requirements; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
cleanup () {
|
||||
[[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}"
|
||||
exit
|
||||
_cless() {
|
||||
# LESS="-R $LESS" enables raw ANSI colors, while maintain already set options.
|
||||
local LESS="-R $LESS"
|
||||
|
||||
# This variable tells less to pipe every file through the specified command
|
||||
# (see the man page of less INPUT PREPROCESSOR).
|
||||
# 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
|
||||
# the ~/.zsh_history. For such files the tty of the preprocessor will be supended.
|
||||
# Therefore we must source this file to make colorize_cat available in the
|
||||
# preprocessor without the interactive mode.
|
||||
# `2>/dev/null` will suppress the error for large files 'broken pipe' of the python
|
||||
# script pygmentize, which will show up if less has not fully "loaded the file"
|
||||
# (e.g. when not scrolled to the bottom) while already the next file will be displayed.
|
||||
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
|
||||
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
|
||||
colorize_cat %s 2> /dev/null'"
|
||||
|
||||
# LESSCLOSE will be set to prevent any errors by executing a user script
|
||||
# which assumes that his LESSOPEN has been executed.
|
||||
local LESSCLOSE=""
|
||||
|
||||
LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" less "$@"
|
||||
}
|
||||
trap 'cleanup' EXIT HUP TERM INT
|
||||
|
||||
while (( $# != 0 )); do #TODO: filter out less opts
|
||||
tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")"
|
||||
tmp_files+=("$tmp_file")
|
||||
colorize_via_pygmentize "$1" > "$tmp_file"
|
||||
shift 1
|
||||
done
|
||||
|
||||
less -f "${tmp_files[@]}"
|
||||
)
|
||||
if [ -t 0 ]; then
|
||||
_cless "$@"
|
||||
else
|
||||
# The input is not associated with a terminal, therefore colorize_cat will
|
||||
# colorize this input and pass it to less.
|
||||
# Less has now to decide what to use. If any files have been provided, less
|
||||
# will ignore the input by default, otherwise the colorized input will be used.
|
||||
# If files have been supplied and the input has been redirected, this will
|
||||
# lead to unnecessary overhead, but retains the ability to use the less options
|
||||
# without checking for them inside this script.
|
||||
colorize_cat | _cless "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -26,10 +26,8 @@ fi
|
||||
|
||||
# OSX command-not-found support
|
||||
# https://github.com/Homebrew/homebrew-command-not-found
|
||||
if type brew &> /dev/null; then
|
||||
if brew command command-not-found-init > /dev/null 2>&1; then
|
||||
eval "$(brew command-not-found-init)";
|
||||
fi
|
||||
if [[ -s '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' ]]; then
|
||||
source '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh'
|
||||
fi
|
||||
|
||||
# NixOS command-not-found support
|
||||
|
||||
@@ -13,7 +13,7 @@ alias lS='ls -1FSsh'
|
||||
alias lart='ls -1Fcart'
|
||||
alias lrt='ls -1Fcrt'
|
||||
|
||||
alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file
|
||||
alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc' # Quick access to the .zshrc file
|
||||
|
||||
alias grep='grep --color'
|
||||
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
|
||||
@@ -50,19 +50,20 @@ 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
|
||||
_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)
|
||||
|
||||
9
zsh/plugins/compleat/README.md
Normal file
9
zsh/plugins/compleat/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# compleat plugin
|
||||
|
||||
This plugin looks for [compleat](https://github.com/mbrubeck/compleat) and loads its completion.
|
||||
|
||||
To use it, add compleat to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... compleat)
|
||||
```
|
||||
@@ -12,18 +12,20 @@ plugins=(... composer)
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| ------ | -------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| `c` | composer | Starts composer |
|
||||
| `csu` | composer self-update | Updates composer to the latest version |
|
||||
| `cu` | composer update | Updates composer dependencies and `composer.lock` file |
|
||||
| `cr` | composer require | Adds new packages to `composer.json` |
|
||||
| `crm` | composer remove | Removes packages from `composer.json` |
|
||||
| `ci` | composer install | Resolves and installs dependencies from `composer.json` |
|
||||
| `ccp` | composer create-project | Create new project from an existing package |
|
||||
| `cdu` | composer dump-autoload | Updates the autoloader |
|
||||
| `cdo` | composer dump-autoload --optimize-autoloader | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) |
|
||||
| `cgu` | composer global update | Allows update command to run on COMPOSER_HOME directory |
|
||||
| `cgr` | composer global require | Allows require command to run on COMPOSER_HOME directory |
|
||||
| `cgrm` | composer global remove | Allows remove command to run on COMPOSER_HOME directory |
|
||||
| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory |
|
||||
| Alias | Command | Description |
|
||||
| ------ | ------------------------------------------- | --------------------------------------------------------------------------------------- |
|
||||
| `c` | `composer` | Starts composer |
|
||||
| `csu` | `composer self-update` | Updates composer to the latest version |
|
||||
| `cu` | `composer update` | Updates composer dependencies and `composer.lock` file |
|
||||
| `cr` | `composer require` | Adds new packages to `composer.json` |
|
||||
| `crm` | `composer remove` | Removes packages from `composer.json` |
|
||||
| `ci` | `composer install` | Resolves and installs dependencies from `composer.json` |
|
||||
| `ccp` | `composer create-project` | Create new project from an existing package |
|
||||
| `cdu` | `composer dump-autoload` | Updates the autoloader |
|
||||
| `cdo` | `composer dump-autoload -o` | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) |
|
||||
| `cgu` | `composer global update` | Allows update command to run on COMPOSER_HOME directory |
|
||||
| `cgr` | `composer global require` | Allows require command to run on COMPOSER_HOME directory |
|
||||
| `cgrm` | `composer global remove` | Allows remove command to run on COMPOSER_HOME directory |
|
||||
| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory |
|
||||
| `co` | `composer outdated` | Shows a list of installed packages with available updates |
|
||||
| `cod` | `composer outdated --direct` | Shows a list of installed packages with available updates which are direct dependencies |
|
||||
|
||||
@@ -15,20 +15,16 @@ _composer_get_required_list () {
|
||||
}
|
||||
|
||||
_composer () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
_arguments \
|
||||
'1: :->command'\
|
||||
'*: :->args'
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
_arguments \
|
||||
'*:: :->subcmds'
|
||||
|
||||
case $state in
|
||||
command)
|
||||
compadd $(_composer_get_command_list)
|
||||
;;
|
||||
*)
|
||||
compadd $(_composer_get_required_list)
|
||||
;;
|
||||
esac
|
||||
if (( CURRENT == 1 )) || ( ((CURRENT == 2)) && [ "$words[1]" = "global" ] ) ; then
|
||||
compadd $(_composer_get_command_list)
|
||||
else
|
||||
compadd $(_composer_get_required_list)
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _composer composer
|
||||
@@ -43,17 +39,31 @@ alias crm='composer remove'
|
||||
alias ci='composer install'
|
||||
alias ccp='composer create-project'
|
||||
alias cdu='composer dump-autoload'
|
||||
alias cdo='composer dump-autoload --optimize-autoloader'
|
||||
alias cdo='composer dump-autoload -o'
|
||||
alias cgu='composer global update'
|
||||
alias cgr='composer global require'
|
||||
alias cgrm='composer global remove'
|
||||
alias co='composer outdated'
|
||||
alias cod='composer outdated --direct'
|
||||
|
||||
# install composer in the current directory
|
||||
alias cget='curl -s https://getcomposer.org/installer | php'
|
||||
|
||||
# Add Composer's global binaries to PATH, using Composer if available.
|
||||
if (( $+commands[composer] )); then
|
||||
export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null)
|
||||
autoload -Uz _store_cache _retrieve_cache
|
||||
|
||||
_retrieve_cache composer
|
||||
|
||||
if [[ -z $__composer_bin_dir ]]; then
|
||||
__composer_bin_dir=$(composer global config bin-dir --absolute 2>/dev/null)
|
||||
_store_cache composer __composer_bin_dir
|
||||
fi
|
||||
|
||||
# Add Composer's global binaries to PATH
|
||||
export PATH="$PATH:$__composer_bin_dir"
|
||||
|
||||
unset __composer_bin_dir
|
||||
else
|
||||
[ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin
|
||||
[ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# copy the active line from the command line buffer
|
||||
# onto the system clipboard (requires clipcopy plugin)
|
||||
# onto the system clipboard
|
||||
|
||||
copybuffer () {
|
||||
if which clipcopy &>/dev/null; then
|
||||
echo $BUFFER | clipcopy
|
||||
printf "%s" "$BUFFER" | clipcopy
|
||||
else
|
||||
echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
|
||||
fi
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
Puts the contents of a file in your system clipboard so you can paste it anywhere.
|
||||
|
||||
To use, add `copyfile` to your plugins array:
|
||||
```
|
||||
|
||||
```zsh
|
||||
plugins=(... copyfile)
|
||||
```
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# Cpanm
|
||||
|
||||
This plugin provides completion for [Cpanm](https://github.com/miyagawa/cpanminus) ([docs](https://metacpan.org/pod/App::cpanminus)).
|
||||
|
||||
|
||||
To use it add cpanm to the plugins array in your zshrc file.
|
||||
|
||||
```bash
|
||||
|
||||
```zsh
|
||||
plugins=(... cpanm)
|
||||
```
|
||||
|
||||
28
zsh/plugins/dash/README.md
Normal file
28
zsh/plugins/dash/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Dash plugin
|
||||
|
||||
This plugin adds command line functionality for [Dash](https://kapeli.com/dash),
|
||||
an API Documentation Browser for macOS. This plugin requires Dash to be installed
|
||||
to work.
|
||||
|
||||
To use it, add `dash` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... dash)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
- Open and switch to the dash application.
|
||||
```
|
||||
dash
|
||||
```
|
||||
|
||||
- Query for something in dash app: `dash query`
|
||||
```
|
||||
dash golang
|
||||
```
|
||||
|
||||
- You can optionally provide a keyword: `dash [keyword:]query`
|
||||
```
|
||||
dash python:tuple
|
||||
```
|
||||
@@ -35,36 +35,30 @@ _dash() {
|
||||
if [[ "$locator" == "platform" ]]; then
|
||||
# Since these are the only special cases right now, let's not do the
|
||||
# expensive processing unless we have to
|
||||
if [[ "$keyword" == "python" || "$keyword" == "java" || \
|
||||
"$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then
|
||||
if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then
|
||||
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
|
||||
if [[ "$keyword" == "python" ]]; then
|
||||
if [[ "$docsetName" == "Python 2" ]]; then
|
||||
keyword="python2"
|
||||
elif [[ "$docsetName" == "Python 3" ]]; then
|
||||
keyword="python3"
|
||||
fi
|
||||
elif [[ "$keyword" == "java" ]]; then
|
||||
if [[ "$docsetName" == "Java SE7" ]]; then
|
||||
keyword="java7"
|
||||
elif [[ "$docsetName" == "Java SE6" ]]; then
|
||||
keyword="java6"
|
||||
elif [[ "$docsetName" == "Java SE8" ]]; then
|
||||
keyword="java8"
|
||||
fi
|
||||
elif [[ "$keyword" == "qt" ]]; then
|
||||
if [[ "$docsetName" == "Qt 5" ]]; then
|
||||
keyword="qt5"
|
||||
elif [[ "$docsetName" == "Qt 4" ]]; then
|
||||
keyword="qt4"
|
||||
elif [[ "$docsetName" == "Qt" ]]; then
|
||||
keyword="qt4"
|
||||
fi
|
||||
elif [[ "$keyword" == "cocos2d" ]]; then
|
||||
if [[ "$docsetName" == "Cocos3D" ]]; then
|
||||
keyword="cocos3d"
|
||||
fi
|
||||
fi
|
||||
case "$keyword" in
|
||||
python)
|
||||
case "$docsetName" in
|
||||
"Python 2") keyword="python2" ;;
|
||||
"Python 3") keyword="python3" ;;
|
||||
esac ;;
|
||||
java)
|
||||
case "$docsetName" in
|
||||
"Java SE7") keyword="java7" ;;
|
||||
"Java SE6") keyword="java6" ;;
|
||||
"Java SE8") keyword="java8" ;;
|
||||
esac ;;
|
||||
qt)
|
||||
case "$docsetName" in
|
||||
"Qt 5") keyword="qt5" ;;
|
||||
"Qt 4"|Qt) keyword="qt4" ;;
|
||||
esac ;;
|
||||
cocos2d)
|
||||
case "$docsetName" in
|
||||
Cocos3D) keyword="cocos3d" ;;
|
||||
esac ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ This plugin enables directory navigation similar to using back and forward on br
|
||||
)
|
||||
```
|
||||
|
||||
2. Reload the source file or restart your Terminal session:
|
||||
2. Restart the shell or restart your Terminal session:
|
||||
|
||||
```console
|
||||
$ source ~/.zshrc
|
||||
$ exec zsh
|
||||
$
|
||||
```
|
||||
|
||||
|
||||
15
zsh/plugins/direnv/README.md
Normal file
15
zsh/plugins/direnv/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# direnv plugin
|
||||
|
||||
This plugin creates the [Direnv](https://direnv.net/) hook.
|
||||
|
||||
To use it, add `direnv` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... direnv)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
In order to make this work, you will need to have the direnv installed.
|
||||
|
||||
More info on the usage and install: https://github.com/direnv/direnv
|
||||
16
zsh/plugins/direnv/direnv.plugin.zsh
Normal file
16
zsh/plugins/direnv/direnv.plugin.zsh
Normal file
@@ -0,0 +1,16 @@
|
||||
# Don't continue if direnv is not found
|
||||
command -v direnv &>/dev/null || return
|
||||
|
||||
_direnv_hook() {
|
||||
trap -- '' SIGINT;
|
||||
eval "$(direnv export zsh)";
|
||||
trap - SIGINT;
|
||||
}
|
||||
typeset -ag precmd_functions;
|
||||
if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then
|
||||
precmd_functions=( _direnv_hook ${precmd_functions[@]} )
|
||||
fi
|
||||
typeset -ag chpwd_functions;
|
||||
if [[ -z ${chpwd_functions[(r)_direnv_hook]} ]]; then
|
||||
chpwd_functions=( _direnv_hook ${chpwd_functions[@]} )
|
||||
fi
|
||||
@@ -7,6 +7,7 @@ To use it, add `dirhistory` to the plugins array in your zshrc file:
|
||||
```zsh
|
||||
plugins=(... dirhistory)
|
||||
```
|
||||
|
||||
## Keyboard Shortcuts
|
||||
|
||||
| Shortcut | Description |
|
||||
@@ -15,3 +16,24 @@ plugins=(... dirhistory)
|
||||
| <kbd>alt</kbd> + <kbd>right</kbd> | Undo <kbd>alt</kbd> + <kbd>left</kbd> |
|
||||
| <kbd>alt</kbd> + <kbd>up</kbd> | Move into the parent directory |
|
||||
| <kbd>alt</kbd> + <kbd>down</kbd> | Move into the first child directory by alphabetical order |
|
||||
|
||||
## Usage
|
||||
|
||||
This plugin allows you to navigate the history of previous current-working-directories using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. MAC users may alternately use OPT-LEFT and OPT-RIGHT.
|
||||
|
||||
Also, navigate directory **hierarchy** using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented). ALT-UP moves to higher hierarchy (shortcut for 'cd ..'). ALT-DOWN moves into the first directory found in alphabetical order (useful to navigate long empty directories e.g. java packages)
|
||||
|
||||
For example, if the shell was started, and the following commands were entered:
|
||||
|
||||
```shell
|
||||
cd ~
|
||||
cd /usr
|
||||
cd share
|
||||
cd doc
|
||||
```
|
||||
|
||||
Then entering ALT-LEFT at the prompt would change directory from /usr/share/doc to /usr/share, then if pressed again to /usr/, then ~. If ALT-RIGHT were pressed the directory would be changed to /usr/ again.
|
||||
|
||||
After that, ALT-DOWN will probably go to /usr/bin (depends on your /usr structure), ALT-UP will return to /usr, then ALT-UP will get you to /
|
||||
|
||||
**Currently the max history size is 30**. The navigation should work for xterm, PuTTY xterm mode, GNU screen, and on MAC with alternate keys as mentioned above.
|
||||
|
||||
@@ -53,7 +53,8 @@ function push_future() {
|
||||
}
|
||||
|
||||
# Called by zsh when directory changes
|
||||
chpwd_functions+=(chpwd_dirhistory)
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd chpwd_dirhistory
|
||||
function chpwd_dirhistory() {
|
||||
push_past $PWD
|
||||
# If DIRHISTORY_CD is not set...
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Dirpersist plugin
|
||||
|
||||
This plugin keeps a running tally of the previous 20 unique directories in the $HOME/.zdirs file. When you cd to a new directory, it is prepended to the beginning of the file.
|
||||
This plugin keeps a running tally of the previous 20 unique directories in the `$HOME/.zdirs` file.
|
||||
When you cd to a new directory, it is prepended to the beginning of the file.
|
||||
|
||||
To use it, add `dirpersist` to the plugins array in your zshrc file:
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
|
||||
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
|
||||
fi
|
||||
|
||||
chpwd_functions+=(chpwd_dirpersist)
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd chpwd_dirpersist
|
||||
chpwd_dirpersist() {
|
||||
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
|
||||
local -ax my_stack
|
||||
|
||||
@@ -34,23 +34,3 @@ runfcgi -- run this project as a fastcgi
|
||||
runserver -- start a lightweight web server for development
|
||||
...
|
||||
```
|
||||
|
||||
If you want to see the options available for a specific command, try:
|
||||
|
||||
```zsh
|
||||
$> python manage.py makemessages (press <TAB> here)
|
||||
```
|
||||
|
||||
And that would result in:
|
||||
|
||||
```zsh
|
||||
--all -a -- re-examine all code and templates
|
||||
--domain -d -- domain of the message files (default: "django")
|
||||
--extensions -e -- file extension(s) to examine (default: ".html")
|
||||
--help -- display help information
|
||||
--locale -l -- locale to process (default: all)
|
||||
--pythonpath -- directory to add to the Python path
|
||||
--settings -- python path to settings module
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
@@ -374,7 +374,8 @@ _managepy-commands() {
|
||||
_applist() {
|
||||
local line
|
||||
local -a apps
|
||||
_call_program help-command "python -c \"import os.path as op, re, django.conf, sys;\\
|
||||
_call_program help-command "python -c \"import sys; del sys.path[0];\\
|
||||
import os.path as op, re, django.conf;\\
|
||||
bn=op.basename(op.abspath(op.curdir));[sys\\
|
||||
.stdout.write(str(re.sub(r'^%s\.(.*?)$' %
|
||||
bn, r'\1', i)) + '\n') for i in django.conf.settings.\\
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
## Description
|
||||
# dnf plugin
|
||||
|
||||
This plugin makes `dnf` usage easier by adding aliases for the most
|
||||
common commands.
|
||||
This plugin makes `dnf` usage easier by adding aliases for the most common commands.
|
||||
|
||||
`dnf` is the new package manager for RPM-based distributions, which
|
||||
replaces `yum`.
|
||||
`dnf` is the new package manager for RPM-based distributions, which replaces `yum`.
|
||||
|
||||
To use it, add `dnf` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... dnf)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ This plugin provides completion for [docker-compose](https://docs.docker.com/com
|
||||
aliases for frequent docker-compose commands.
|
||||
|
||||
To use it, add docker-compose to the plugins array of your zshrc file:
|
||||
```
|
||||
|
||||
```zsh
|
||||
plugins=(... docker-compose)
|
||||
```
|
||||
|
||||
@@ -27,3 +28,4 @@ plugins=(... docker-compose)
|
||||
| dclf | `docker-compose logs -f` | Show logs and follow output |
|
||||
| dcpull | `docker-compose pull` | Pull image of a service |
|
||||
| dcstart | `docker-compose start` | Start a container |
|
||||
| dck | `docker-compose kill` | Kills containers |
|
||||
|
||||
@@ -24,3 +24,4 @@ alias dcl='docker-compose logs'
|
||||
alias dclf='docker-compose logs -f'
|
||||
alias dcpull='docker-compose pull'
|
||||
alias dcstart='docker-compose start'
|
||||
alias dck='docker-compose kill'
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
## Docker autocomplete plugin
|
||||
# Docker plugin
|
||||
|
||||
A copy of the completion script from the
|
||||
[docker/cli](https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker)
|
||||
git repo.
|
||||
This plugin adds auto-completion for [docker](https://www.docker.com/).
|
||||
|
||||
To use it add `docker` to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
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
|
||||
> ```
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
# - Felix Riedel
|
||||
# - Steve Durrheimer
|
||||
# - Vincent Bernat
|
||||
# - Rohan Verma
|
||||
#
|
||||
# license:
|
||||
#
|
||||
@@ -604,6 +605,7 @@ __docker_container_subcommand() {
|
||||
"($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: "
|
||||
"($help)*--cap-add=[Add Linux capabilities]:capability: "
|
||||
"($help)*--cap-drop=[Drop Linux capabilities]:capability: "
|
||||
"($help)--cgroupns=[Cgroup namespace mode to use]:cgroup namespace mode: "
|
||||
"($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: "
|
||||
"($help)--cidfile=[Write the container ID to the file]:CID file:_files"
|
||||
"($help)--cpus=[Number of CPUs (default 0.000)]:cpus: "
|
||||
@@ -676,6 +678,7 @@ __docker_container_subcommand() {
|
||||
"($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: "
|
||||
"($help)--memory-reservation=[Memory soft limit]:Memory limit: "
|
||||
"($help)--memory-swap=[Total memory limit with swap]:Memory limit: "
|
||||
"($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]"
|
||||
"($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)"
|
||||
)
|
||||
opts_help=("(: -)--help[Print usage]")
|
||||
@@ -801,7 +804,7 @@ __docker_container_subcommand() {
|
||||
"($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \
|
||||
"($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \
|
||||
"($help)--no-trunc[Do not truncate output]" \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only show container IDs]" \
|
||||
"($help -s --size)"{-s,--size}"[Display total file sizes]" \
|
||||
"($help)--since=[Show only containers created since...]:containers:__docker_complete_containers" && ret=0
|
||||
;;
|
||||
@@ -832,7 +835,7 @@ __docker_container_subcommand() {
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \
|
||||
"($help -)*:containers:__docker_complete_containers_ids" && ret=0
|
||||
"($help -)*:containers:__docker_complete_containers" && ret=0
|
||||
;;
|
||||
(rm)
|
||||
local state
|
||||
@@ -1024,7 +1027,7 @@ __docker_image_subcommand() {
|
||||
$opts_help \
|
||||
"($help -H --human)"{-H,--human}"[Print sizes and dates in human readable format]" \
|
||||
"($help)--no-trunc[Do not truncate output]" \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \
|
||||
"($help -)*: :__docker_complete_images" && ret=0
|
||||
;;
|
||||
(import)
|
||||
@@ -1056,7 +1059,7 @@ __docker_image_subcommand() {
|
||||
"($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_images_filters" \
|
||||
"($help)--format=[Pretty-print images using a Go template]:template: " \
|
||||
"($help)--no-trunc[Do not truncate output]" \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \
|
||||
"($help -): :__docker_complete_repositories" && ret=0
|
||||
;;
|
||||
(prune)
|
||||
@@ -1076,6 +1079,7 @@ __docker_image_subcommand() {
|
||||
(push)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help -a --all-tags)"{-a,--all-tags}"[Push all tagged images in the repository]" \
|
||||
"($help)--disable-content-trust[Skip image signing]" \
|
||||
"($help -): :__docker_complete_images" && ret=0
|
||||
;;
|
||||
@@ -1286,7 +1290,7 @@ __docker_network_subcommand() {
|
||||
"($help)--no-trunc[Do not truncate the output]" \
|
||||
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \
|
||||
"($help)--format=[Pretty-print networks using a Go template]:template: " \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only display network IDs]" && ret=0
|
||||
;;
|
||||
(prune)
|
||||
_arguments $(__docker_arguments) \
|
||||
@@ -2214,7 +2218,6 @@ __docker_stack_subcommand() {
|
||||
(deploy|up)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help)--bundle-file=[Path to a Distributed Application Bundle file]:dab:_files -g \"*.dab\"" \
|
||||
"($help -c --compose-file)"{-c=,--compose-file=}"[Path to a Compose file, or '-' to read from stdin]:compose file:_files -g \"*.(yml|yaml)\"" \
|
||||
"($help)--with-registry-auth[Send registry authentication details to Swarm agents]" \
|
||||
"($help -):stack:__docker_complete_stacks" && ret=0
|
||||
@@ -2668,6 +2671,7 @@ __docker_subcommand() {
|
||||
"($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_complete_log_options" \
|
||||
"($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \
|
||||
"($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \
|
||||
"($help)--max-download-attempts[Set the max download attempts for each pull]" \
|
||||
"($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \
|
||||
"($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \
|
||||
"($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \
|
||||
@@ -2783,7 +2787,7 @@ __docker_subcommand() {
|
||||
$opts_help \
|
||||
"($help -p --password)"{-p=,--password=}"[Password]:password: " \
|
||||
"($help)--password-stdin[Read password from stdin]" \
|
||||
"($help -u --user)"{-u=,--user=}"[Username]:username: " \
|
||||
"($help -u --username)"{-u=,--username=}"[Username]:username: " \
|
||||
"($help -)1:server: " && ret=0
|
||||
;;
|
||||
(logout)
|
||||
|
||||
@@ -4,9 +4,7 @@ Automatically load your project ENV variables from `.env` file when you `cd` int
|
||||
|
||||
Storing configuration in the environment is one of the tenets of a [twelve-factor app](https://www.12factor.net). Anything that is likely to change between deployment environments, such as resource handles for databases or credentials for external services, should be extracted from the code into environment variables.
|
||||
|
||||
## Installation
|
||||
|
||||
Just add the plugin to your `.zshrc`:
|
||||
To use it, add `dotenv` to the plugins array in your zshrc file:
|
||||
|
||||
```sh
|
||||
plugins=(... dotenv)
|
||||
@@ -17,32 +15,69 @@ plugins=(... dotenv)
|
||||
Create `.env` file inside your project root directory and put your ENV variables there.
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
export AWS_S3_TOKEN=d84a83539134f28f412c652b09f9f98eff96c9a
|
||||
export SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f
|
||||
export MONGO_URI=mongodb://127.0.0.1:27017
|
||||
export PORT=3001
|
||||
```
|
||||
|
||||
`export` is optional. This format works as well:
|
||||
|
||||
```sh
|
||||
AWS_S3_TOKEN=d84a83539134f28f412c652b09f9f98eff96c9a
|
||||
SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f
|
||||
MONGO_URI=mongodb://127.0.0.1:27017
|
||||
PORT=3001
|
||||
```
|
||||
|
||||
You can even mix both formats, although it's probably a bad idea.
|
||||
|
||||
## Settings
|
||||
|
||||
### ZSH_DOTENV_FILE
|
||||
|
||||
You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`.
|
||||
If the variable isn't set, the plugin will default to use `.env`.
|
||||
For example, this will make the plugin look for files named `.dotenv` and load them:
|
||||
|
||||
```
|
||||
```zsh
|
||||
# in ~/.zshrc, before Oh My Zsh is sourced:
|
||||
ZSH_DOTENV_FILE=.dotenv
|
||||
```
|
||||
|
||||
### ZSH_DOTENV_PROMPT
|
||||
|
||||
Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmation message.
|
||||
You can also choose the `Always` option when prompted to always allow sourcing the .env file
|
||||
in that directory. See the next section for more details.
|
||||
|
||||
### ZSH_DOTENV_ALLOWED_LIST, ZSH_DOTENV_DISALLOWED_LIST
|
||||
|
||||
The default behavior of the plugin is to always ask whether to source a dotenv file. There's
|
||||
a **Y**es, **N**o, **A**lways and N**e**ver option. If you choose Always, the directory of the .env file
|
||||
will be added to an allowed list; if you choose Never, it will be added to a disallowed list.
|
||||
If a directory is found in either of those lists, the plugin won't ask for confirmation and will
|
||||
instead either source the .env file or proceed without action respectively.
|
||||
|
||||
The allowed and disallowed lists are saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list` and
|
||||
`$ZSH_CACHE_DIR/dotenv-disallowed.list` respectively. If you want to change that location,
|
||||
change the `$ZSH_DOTENV_ALLOWED_LIST` and `$ZSH_DOTENV_DISALLOWED_LIST` variables, like so:
|
||||
|
||||
```zsh
|
||||
# in ~/.zshrc, before Oh My Zsh is sourced:
|
||||
ZSH_DOTENV_ALLOWED_LIST=/path/to/dotenv/allowed/list
|
||||
ZSH_DOTENV_DISALLOWED_LIST=/path/to/dotenv/disallowed/list
|
||||
```
|
||||
|
||||
The file is just a list of directories, separated by a newline character. If you want
|
||||
to change your decision, just edit the file and remove the line for the directory you want to
|
||||
change.
|
||||
|
||||
NOTE: if a directory is found in both the allowed and disallowed lists, the disallowed list
|
||||
takes preference, _i.e._ the .env file will never be sourced.
|
||||
|
||||
## Version Control
|
||||
|
||||
**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only.
|
||||
@@ -52,5 +87,6 @@ ZSH_DOTENV_FILE=.dotenv
|
||||
This plugin only sources the `.env` file. Nothing less, nothing more. It doesn't do any checks. It's designed to be the fastest and simplest option. You're responsible for the `.env` file content. You can put some code (or weird symbols) there, but do it on your own risk. `dotenv` is the basic tool, yet it does the job.
|
||||
|
||||
If you need more advanced and feature-rich ENV management, check out these awesome projects:
|
||||
|
||||
* [direnv](https://github.com/direnv/direnv)
|
||||
* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv)
|
||||
|
||||
@@ -1,23 +1,54 @@
|
||||
## Settings
|
||||
|
||||
# Filename of the dotenv file to look for
|
||||
: ${ZSH_DOTENV_FILE:=.env}
|
||||
|
||||
# Path to the file containing allowed paths
|
||||
: ${ZSH_DOTENV_ALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-allowed.list"}
|
||||
: ${ZSH_DOTENV_DISALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-disallowed.list"}
|
||||
|
||||
|
||||
## Functions
|
||||
|
||||
source_env() {
|
||||
if [[ -f $ZSH_DOTENV_FILE ]]; then
|
||||
if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then
|
||||
local confirmation dirpath="${PWD:A}"
|
||||
|
||||
# make sure there is an (dis-)allowed file
|
||||
touch "$ZSH_DOTENV_ALLOWED_LIST"
|
||||
touch "$ZSH_DOTENV_DISALLOWED_LIST"
|
||||
|
||||
# early return if disallowed
|
||||
if grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then
|
||||
return;
|
||||
fi
|
||||
|
||||
# check if current directory's .env file is allowed or ask for confirmation
|
||||
if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then
|
||||
# print same-line prompt and output newline character if necessary
|
||||
echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) "
|
||||
read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo
|
||||
|
||||
# check input
|
||||
case "$confirmation" in
|
||||
[nN]) return ;;
|
||||
[aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;;
|
||||
[eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;;
|
||||
*) ;; # interpret anything else as a yes
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
# test .env syntax
|
||||
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
|
||||
|
||||
if [[ -o a ]]; then
|
||||
source $ZSH_DOTENV_FILE
|
||||
else
|
||||
set -a
|
||||
source $ZSH_DOTENV_FILE
|
||||
set +a
|
||||
fi
|
||||
setopt localoptions allexport
|
||||
source $ZSH_DOTENV_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd source_env
|
||||
|
||||
if [[ -z $ZSH_DOTENV_FILE ]]; then
|
||||
ZSH_DOTENV_FILE=.env
|
||||
fi
|
||||
|
||||
source_env
|
||||
|
||||
23
zsh/plugins/dotnet/README.md
Normal file
23
zsh/plugins/dotnet/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# .NET Core CLI plugin
|
||||
|
||||
This plugin provides completion and useful aliases for [.NET Core CLI](https://dotnet.microsoft.com/).
|
||||
|
||||
To use it, add `dotnet` to the plugins array in your zshrc file.
|
||||
|
||||
```
|
||||
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. |
|
||||
| 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. |
|
||||
32
zsh/plugins/dotnet/dotnet.plugin.zsh
Normal file
32
zsh/plugins/dotnet/dotnet.plugin.zsh
Normal file
@@ -0,0 +1,32 @@
|
||||
# This scripts is copied from (MIT License):
|
||||
# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh
|
||||
|
||||
_dotnet_zsh_complete()
|
||||
{
|
||||
local completions=("$(dotnet complete "$words")")
|
||||
|
||||
# If the completion list is empty, just continue with filename selection
|
||||
if [ -z "$completions" ]
|
||||
then
|
||||
_arguments '*::arguments: _normal'
|
||||
return
|
||||
fi
|
||||
|
||||
# This is not a variable assigment, don't remove spaces!
|
||||
_values = "${(ps:\n:)completions}"
|
||||
}
|
||||
|
||||
compdef _dotnet_zsh_complete dotnet
|
||||
|
||||
# Aliases bellow are here for backwards compatibility
|
||||
# added by Shaun Tabone (https://github.com/xontab)
|
||||
|
||||
alias dn='dotnet new'
|
||||
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'
|
||||
alias dng='dotnet nuget'
|
||||
11
zsh/plugins/eecms/README.md
Normal file
11
zsh/plugins/eecms/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# eecms plugin
|
||||
|
||||
This plugin adds auto-completion of console commands for [`eecms`](https://github.com/ExpressionEngine/ExpressionEngine).
|
||||
|
||||
To use it, add `eecms` to the plugins array of your `.zshrc` file:
|
||||
```
|
||||
plugins=(... eecms)
|
||||
```
|
||||
|
||||
It also adds the alias `eecms` which finds the eecms file in the current project
|
||||
and runs it with php.
|
||||
@@ -26,6 +26,16 @@ if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then
|
||||
# create a new X frame
|
||||
alias eframe='emacsclient --alternate-editor "" --create-frame'
|
||||
|
||||
# Emacs ANSI Term tracking
|
||||
if [[ -n "$INSIDE_EMACS" ]]; then
|
||||
chpwd_emacs() { print -P "\033AnSiTc %d"; }
|
||||
print -P "\033AnSiTc %d" # Track current working directory
|
||||
print -P "\033AnSiTu %n" # Track username
|
||||
|
||||
# add chpwd hook
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook chpwd chpwd_emacs
|
||||
fi
|
||||
|
||||
# Write to standard output the path to the file
|
||||
# opened in the current buffer.
|
||||
|
||||
@@ -20,7 +20,8 @@ _emacsfun()
|
||||
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
|
||||
if [ "$#" -ge "2" -a "$2" = "-" ]
|
||||
then
|
||||
tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)"
|
||||
tempfile="$(mktemp --tmpdir emacs-stdin-$USER.XXXXXXX 2>/dev/null \
|
||||
|| mktemp -t emacs-stdin-$USER)" # support BSD mktemp
|
||||
cat - > "$tempfile"
|
||||
_emacsfun --no-wait $tempfile
|
||||
else
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# FILE: emoji-clock.plugin.zsh
|
||||
# DESCRIPTION: The current time with half hour accuracy as an emoji symbol.
|
||||
# Inspired by Andre Torrez' "Put A Burger In Your Shell"
|
||||
# http://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html
|
||||
# https://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html
|
||||
# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
|
||||
# VERSION: 1.0.0
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
39
zsh/plugins/emotty/README.md
Normal file
39
zsh/plugins/emotty/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# emotty plugin
|
||||
|
||||
This plugin returns an emoji for the current $TTY number so it can be used
|
||||
in a prompt.
|
||||
|
||||
To use it, add emotty to the plugins array in your zshrc file:
|
||||
```
|
||||
plugins=(... emotty)
|
||||
```
|
||||
|
||||
**NOTE:** it requires the [emoji plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/emoji).
|
||||
|
||||
## Usage
|
||||
|
||||
The function `emotty` displays an emoji from the current character set (default: `emoji`), based
|
||||
on the number associated to the `$TTY`.
|
||||
|
||||
There are different sets of emoji characters available, to choose a different
|
||||
set, set `$emotty_set` to the name of the set you would like to use, e.g.:
|
||||
```
|
||||
emotty_set=nature
|
||||
```
|
||||
|
||||
### Character Sets
|
||||
|
||||
- emoji
|
||||
- loral
|
||||
- love
|
||||
- nature
|
||||
- stellar
|
||||
- zodiac
|
||||
|
||||
Use the `display_emotty` function to list the emojis in the current character set, or
|
||||
the character set passed as the first argument. For example:
|
||||
|
||||
```
|
||||
$ display_emotty zodiac
|
||||
<list of all the emojis in the zodiac character set>
|
||||
```
|
||||
@@ -1,6 +1,12 @@
|
||||
# encode64
|
||||
|
||||
Alias plugin for encoding or decoding using `base64` command
|
||||
Alias plugin for encoding or decoding using `base64` command.
|
||||
|
||||
To use it, add `encode64` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... encode64)
|
||||
```
|
||||
|
||||
## Functions and Aliases
|
||||
|
||||
@@ -9,23 +15,6 @@ Alias plugin for encoding or decoding using `base64` command
|
||||
| `encode64` | `e64` | Encodes given data to base64 |
|
||||
| `decode64` | `d64` | Decodes given data from base64 |
|
||||
|
||||
## Enabling plugin
|
||||
|
||||
1. Edit your `.zshrc` file and add `encode64` to the list of plugins:
|
||||
|
||||
```sh
|
||||
plugins=(
|
||||
# ...other enabled plugins
|
||||
encode64
|
||||
)
|
||||
```
|
||||
|
||||
2. Restart your terminal session or reload configuration by running:
|
||||
|
||||
```sh
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
## Usage and examples
|
||||
|
||||
### Encoding
|
||||
@@ -64,6 +53,6 @@ Alias plugin for encoding or decoding using `base64` command
|
||||
```console
|
||||
$ echo "b2gtbXktenNoCg==" | decode64
|
||||
oh-my-zsh
|
||||
$ echo "b2gtbXktenNoCg==" | decode64
|
||||
$ echo "b2gtbXktenNoCg==" | d64
|
||||
oh-my-zsh
|
||||
```
|
||||
|
||||
@@ -23,25 +23,35 @@ plugins=(... extract)
|
||||
| `bz2` | Bzip2 file |
|
||||
| `deb` | Debian package |
|
||||
| `gz` | Gzip file |
|
||||
| `ipa` | iOS app package |
|
||||
| `ipsw` | iOS firmware file |
|
||||
| `jar` | Java Archive |
|
||||
| `lrz` | LRZ archive |
|
||||
| `lz4` | LZ4 archive |
|
||||
| `lzma` | LZMA archive |
|
||||
| `rar` | WinRAR archive |
|
||||
| `rpm` | RPM package |
|
||||
| `sublime-package` | Sublime Text package |
|
||||
| `tar` | Tarball |
|
||||
| `tar.bz2` | Tarball with bzip2 compression |
|
||||
| `tar.gz` | Tarball with gzip compression |
|
||||
| `tar.lrz` | Tarball with lrzip compression |
|
||||
| `tar.lz` | Tarball with lzip compression |
|
||||
| `tar.lz4` | Tarball with lz4 compression |
|
||||
| `tar.xz` | Tarball with lzma2 compression |
|
||||
| `tar.zma` | Tarball with lzma compression |
|
||||
| `tar.zst` | Tarball with zstd compression |
|
||||
| `tbz` | Tarball with bzip compression |
|
||||
| `tbz2` | Tarball with bzip2 compression |
|
||||
| `tgz` | Tarball with gzip compression |
|
||||
| `tlz` | Tarball with lzma compression |
|
||||
| `txz` | Tarball with lzma2 compression |
|
||||
| `tzst` | Tarball with zstd compression |
|
||||
| `war` | Web Application archive (Java-based) |
|
||||
| `xpi` | Mozilla XPI module file |
|
||||
| `xz` | LZMA2 archive |
|
||||
| `zip` | Zip archive |
|
||||
| `zst` | Zstandard file (zstd) |
|
||||
|
||||
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
|
||||
more information regarding archive formats.
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
|
||||
_arguments \
|
||||
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
|
||||
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \
|
||||
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
|
||||
&& return 0
|
||||
|
||||
@@ -40,14 +40,24 @@ extract() {
|
||||
tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -xvf "$1" \
|
||||
|| lzcat "$1" | tar xvf - ;;
|
||||
(*.tar.zst|*.tzst)
|
||||
tar --zstd --help &> /dev/null \
|
||||
&& tar --zstd -xvf "$1" \
|
||||
|| zstdcat "$1" | tar xvf - ;;
|
||||
(*.tar) tar xvf "$1" ;;
|
||||
(*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;;
|
||||
(*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;;
|
||||
(*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;;
|
||||
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;;
|
||||
(*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;;
|
||||
(*.bz2) bunzip2 "$1" ;;
|
||||
(*.xz) unxz "$1" ;;
|
||||
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;;
|
||||
(*.lz4) lz4 -d "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.z) uncompress "$1" ;;
|
||||
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
|
||||
(*.zip|*.war|*.jar|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
|
||||
(*.rar) unrar x -ad "$1" ;;
|
||||
(*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
(*.deb)
|
||||
mkdir -p "$extract_dir/control"
|
||||
@@ -58,6 +68,7 @@ extract() {
|
||||
cd ..; rm *.tar.* debian-binary
|
||||
cd ..
|
||||
;;
|
||||
(*.zst) unzstd "$1" ;;
|
||||
(*)
|
||||
echo "extract: '$1' cannot be extracted" >&2
|
||||
success=1
|
||||
|
||||
@@ -4,6 +4,6 @@ This plugin provides completion for [Fabric](https://www.fabfile.org/).
|
||||
|
||||
To use it add fabric to the plugins array in your zshrc file.
|
||||
|
||||
```bash
|
||||
```zsh
|
||||
plugins=(... fabric)
|
||||
```
|
||||
|
||||
@@ -4,10 +4,19 @@
|
||||
local curcontext=$curcontext state line
|
||||
declare -A opt_args
|
||||
|
||||
declare target_list
|
||||
target_list=(`fab --shortlist 2>/dev/null || fab --complete 2>/dev/null`)
|
||||
declare -a target_list
|
||||
target_list=("${(@f)$(fab -l 2>/dev/null | awk '{
|
||||
if (NF == 0 || NR == 1) next
|
||||
if (NF < 2) print $1
|
||||
else {
|
||||
docstring=substr($0, index($0,$2))
|
||||
gsub(":", "\\:", docstring)
|
||||
print $1":"docstring
|
||||
}
|
||||
}')}")
|
||||
|
||||
_targets() {
|
||||
_fab_targets() {
|
||||
[[ -n "$target_list" ]] || return
|
||||
_describe -t commands "fabric targets" target_list
|
||||
}
|
||||
|
||||
@@ -28,7 +37,7 @@ _arguments -w -S -C \
|
||||
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
|
||||
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
|
||||
'(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \
|
||||
"(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \
|
||||
"(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_fab_targets" \
|
||||
'(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \
|
||||
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
|
||||
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
|
||||
@@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then
|
||||
levels)
|
||||
_describe -t commands "output levels" output_levels;;
|
||||
*)
|
||||
_targets;;
|
||||
_fab_targets;;
|
||||
esac
|
||||
|
||||
return
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
fancy-ctrl-z () {
|
||||
if [[ $#BUFFER -eq 0 ]]; then
|
||||
BUFFER="fg"
|
||||
zle accept-line
|
||||
zle accept-line -w
|
||||
else
|
||||
zle push-input
|
||||
zle clear-screen
|
||||
zle push-input -w
|
||||
zle clear-screen -w
|
||||
fi
|
||||
}
|
||||
zle -N fancy-ctrl-z
|
||||
|
||||
21
zsh/plugins/fasd/README.md
Normal file
21
zsh/plugins/fasd/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# fasd
|
||||
|
||||
[`Fasd`](https://github.com/clvv/fasd) (pronounced similar to "fast") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells.
|
||||
|
||||
To use it, add `fasd` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... fasd)
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install)
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|-------------------------------------------|-------------------------------------------------------------|
|
||||
| v | `fasd -f -e "$EDITOR"` | List frequent/recent files matching the given filename. |
|
||||
| o | `fasd -a -e xdg-open` | List frequent/recent files and directories matching. |
|
||||
| j | `fasd_cd -d -i` | cd with interactive selection |
|
||||
@@ -1,12 +1,16 @@
|
||||
if [ $commands[fasd] ]; then # check if fasd is installed
|
||||
fasd_cache="${ZSH_CACHE_DIR}/fasd-init-cache"
|
||||
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
|
||||
fasd --init auto >| "$fasd_cache"
|
||||
fi
|
||||
source "$fasd_cache"
|
||||
unset fasd_cache
|
||||
|
||||
alias v='f -e "$EDITOR"'
|
||||
alias o='a -e xdg-open'
|
||||
alias j='zz'
|
||||
# check if fasd is installed
|
||||
if (( ! ${+commands[fasd]} )); then
|
||||
return
|
||||
fi
|
||||
|
||||
fasd_cache="${ZSH_CACHE_DIR}/fasd-init-cache"
|
||||
if [[ "$commands[fasd]" -nt "$fasd_cache" || ! -s "$fasd_cache" ]]; then
|
||||
fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install \
|
||||
zsh-wcomp zsh-wcomp-install >| "$fasd_cache"
|
||||
fi
|
||||
source "$fasd_cache"
|
||||
unset fasd_cache
|
||||
|
||||
alias v='f -e "$EDITOR"'
|
||||
alias o='a -e xdg-open'
|
||||
alias j='zz'
|
||||
|
||||
84
zsh/plugins/fastfile/README.md
Normal file
84
zsh/plugins/fastfile/README.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# Fastfile plugin
|
||||
|
||||
This plugin adds a way to reference certain files or folders used frequently using
|
||||
a global alias or shortcut.
|
||||
|
||||
To use it, add `fastfile` to the plugins array in your zshrc file:
|
||||
```zsh
|
||||
plugins=(... fastfile)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Example: you access folder `/code/project/backend/database` very frequently.
|
||||
|
||||
First, generate a shortcut with the name `pjdb`:
|
||||
```zsh
|
||||
$ fastfile pjdb /code/project/backend/database
|
||||
```
|
||||
|
||||
Next time you want to access it, use `§pjdb`. For example:
|
||||
```zsh
|
||||
$ cd §pjdb
|
||||
$ subl §pjdb
|
||||
```
|
||||
where § is the fastfile prefix (see [below](#options) for how to change).
|
||||
|
||||
**Note:** shortcuts with spaces in the name are assigned a global alias
|
||||
where the spaces have been substituted with underscores (`_`). For example:
|
||||
a shortcut named `"hello world"` corresponds with `§hello_world`.
|
||||
|
||||
|
||||
## Functions
|
||||
|
||||
- `fastfile <shortcut_name> <path/to/file/or/folder>`: generate a shortcut.
|
||||
|
||||
- `fastfile_print <shortcut_name>`: prints a shortcut, with the format
|
||||
`<prefix><shortcut_name> -> <shortcut_path>`.
|
||||
|
||||
- `fastfile_ls`: lists all shortcuts.
|
||||
|
||||
- `fastfile_rm <shortcut_name> `: remove a shortcut.
|
||||
|
||||
- `fastfile_sync`: generates the global aliases for the shortcuts.
|
||||
|
||||
|
||||
### Internal functions
|
||||
|
||||
- `fastfile_resolv <shortcut_name>`: resolves the location of the shortcut
|
||||
file, i.e., the file in the fastfile directory where the shortcut path
|
||||
is stored.
|
||||
|
||||
- `fastfile_get <shortcut_name>`: get the real path of the shortcut.
|
||||
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Function |
|
||||
|--------|------------------|
|
||||
| ff | `fastfile` |
|
||||
| ffp | `fastfile_print` |
|
||||
| ffrm | `fastfile_rm` |
|
||||
| ffls | `fastfile_ls` |
|
||||
| ffsync | `fastfile_sync` |
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
These are options you can set to change certain parts of the plugin. To change
|
||||
them, add `<variable>=<value>` to your zshrc file, before Oh My Zsh is sourced.
|
||||
For example: `fastfile_var_prefix='@'`.
|
||||
|
||||
- `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the
|
||||
created global aliases.
|
||||
**Default:** `§` (section sign), easy to type in a german keyboard via the combination
|
||||
[`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg),
|
||||
or using `⌥ Option`+`6` in macOS.
|
||||
|
||||
- `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end
|
||||
with a trailing slash.
|
||||
**Default:** `$HOME/.fastfile/`.
|
||||
|
||||
## Author
|
||||
|
||||
- [Karolin Varner](https://github.com/koraa)
|
||||
@@ -1,21 +1,11 @@
|
||||
################################################################################
|
||||
# FILE: fastfile.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Michael Varner (musikmichael@web.de)
|
||||
# VERSION: 1.0.0
|
||||
#
|
||||
# This plugin adds the ability to on the fly generate and access file shortcuts.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
###########################
|
||||
# Settings
|
||||
# Settings
|
||||
|
||||
# These can be overwritten any time.
|
||||
# If they are not set yet, they will be
|
||||
# overwritten with their default values
|
||||
|
||||
default fastfile_dir "${HOME}/.fastfile/"
|
||||
default fastfile_dir "${HOME}/.fastfile"
|
||||
default fastfile_var_prefix "§"
|
||||
|
||||
###########################
|
||||
@@ -33,7 +23,7 @@ default fastfile_var_prefix "§"
|
||||
function fastfile() {
|
||||
test "$2" || 2="."
|
||||
file=$(readlink -f "$2")
|
||||
|
||||
|
||||
test "$1" || 1="$(basename "$file")"
|
||||
name=$(echo "$1" | tr " " "_")
|
||||
|
||||
@@ -51,7 +41,7 @@ function fastfile() {
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut
|
||||
# STDOUT:
|
||||
# The path
|
||||
# The path to the shortcut file
|
||||
#
|
||||
function fastfile_resolv() {
|
||||
echo "${fastfile_dir}${1}"
|
||||
@@ -88,12 +78,12 @@ function fastfile_print() {
|
||||
# (=> fastfle_print) for each shortcut
|
||||
#
|
||||
function fastfile_ls() {
|
||||
for f in "${fastfile_dir}"/*; do
|
||||
file=`basename "$f"` # To enable simpler handeling of spaces in file names
|
||||
varkey=`echo "$file" | tr " " "_"`
|
||||
for f in "${fastfile_dir}"/*(NF); do
|
||||
file=`basename "$f"` # To enable simpler handeling of spaces in file names
|
||||
varkey=`echo "$file" | tr " " "_"`
|
||||
|
||||
# Special format for colums
|
||||
echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
|
||||
# Special format for colums
|
||||
echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
|
||||
done | column -t -s "|"
|
||||
}
|
||||
|
||||
@@ -102,7 +92,6 @@ function fastfile_ls() {
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut (default: name of the file)
|
||||
# 2. file - The file or directory to make the shortcut for
|
||||
# STDOUT:
|
||||
# => fastfle_print
|
||||
#
|
||||
@@ -115,11 +104,11 @@ function fastfile_rm() {
|
||||
# Generate the aliases for the shortcuts
|
||||
#
|
||||
function fastfile_sync() {
|
||||
for f in "${fastfile_dir}"/*; do
|
||||
file=`basename "$f"` # To enable simpler handeling of spaces in file names
|
||||
varkey=`echo "$file" | tr " " "_"`
|
||||
for f in "${fastfile_dir}"/*(NF); do
|
||||
file=`basename "$f"` # To enable simpler handeling of spaces in file names
|
||||
varkey=`echo "$file" | tr " " "_"`
|
||||
|
||||
alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
|
||||
alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -133,6 +122,6 @@ alias ffls=fastfile_ls
|
||||
alias ffsync=fastfile_sync
|
||||
|
||||
##################################
|
||||
# Init
|
||||
# Init
|
||||
|
||||
fastfile_sync
|
||||
fastfile_sync
|
||||
|
||||
10
zsh/plugins/fbterm/README.md
Normal file
10
zsh/plugins/fbterm/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# fbterm
|
||||
|
||||
This plugin automatically starts [fbterm](https://github.com/zhangyuanwei/fbterm)
|
||||
if on a real TTY (`/dev/tty*`).
|
||||
|
||||
To use it, add `fbterm` to the plugins array of your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... fbterm)
|
||||
```
|
||||
@@ -1 +1 @@
|
||||
The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/dnf) instead.
|
||||
The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../dnf/dnf.plugin.zsh
|
||||
3
zsh/plugins/fedora/fedora.plugin.zsh
Normal file
3
zsh/plugins/fedora/fedora.plugin.zsh
Normal file
@@ -0,0 +1,3 @@
|
||||
print -P "%F{yellow}The 'fedora' plugin is deprecated. Use the '%Udnf%u' plugin instead.%f"
|
||||
|
||||
source "$ZSH/plugins/dnf/dnf.plugin.zsh"
|
||||
21
zsh/plugins/flutter/README.md
Normal file
21
zsh/plugins/flutter/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## Flutter plugin
|
||||
|
||||
The Flutter plugin provides completion and useful aliases
|
||||
|
||||
To use it, add flutter to the plugins array of your zshrc file:
|
||||
|
||||
```
|
||||
plugins=(... flutter)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| :--------- | :--------------------- | :------------------------------------------------------------------------- |
|
||||
| `fl` | `flutter` | Shorthand for flutter command |
|
||||
| `flr` | `flutter run` | Runs flutter app |
|
||||
| `fldoc` | `flutter doctor` | Runs flutter doctor |
|
||||
| `flb` | `flutter build` | Build flutter application |
|
||||
| `flattach` | `flutter attach` | Attaches flutter to a running flutter application with enabled observatory |
|
||||
| `flget` | `flutter packages get` | Installs dependencies |
|
||||
| `flc` | `flutter clean` | Cleans flutter porject |
|
||||
37
zsh/plugins/flutter/_flutter
Normal file
37
zsh/plugins/flutter/_flutter
Normal file
@@ -0,0 +1,37 @@
|
||||
#compdef flutter
|
||||
#autoload
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
"analyze":"Analyze the project's Dart code."
|
||||
"assemble":"Assemble and build flutter resources."
|
||||
"attach":"Attach to a running application."
|
||||
"build":"Flutter build commands."
|
||||
"channel":"List or switch flutter channels."
|
||||
"clean":"Delete the build/ and .dart_tool/ directories."
|
||||
"config":"Configure Flutter settings."
|
||||
"create":"Create a new Flutter project."
|
||||
"devices":"List all connected devices."
|
||||
"doctor":"Show information about the installed tooling."
|
||||
"drive":"Runs Flutter Driver tests for the current project."
|
||||
"emulators":"List, launch and create emulators."
|
||||
"format":" Format one or more dart files."
|
||||
"help":"Display help information for flutter."
|
||||
"install":"Install a Flutter app on an attached device."
|
||||
"logs":"Show log output for running Flutter apps."
|
||||
"make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers."
|
||||
"precache":"Populates the Flutter tool's cache of binary artifacts."
|
||||
"pub":"Commands for managing Flutter packages."
|
||||
"run":"Run your Flutter app on an attached device."
|
||||
"screenshot":"Take a screenshot from a connected device."
|
||||
"test":"Run Flutter unit tests for the current project."
|
||||
"upgrade":"Upgrade your copy of Flutter."
|
||||
"version":"List or switch flutter versions."
|
||||
)
|
||||
|
||||
_arguments -C '*:: :->subcmds'
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "flutter command" _1st_arguments
|
||||
return
|
||||
fi
|
||||
7
zsh/plugins/flutter/flutter.plugin.zsh
Normal file
7
zsh/plugins/flutter/flutter.plugin.zsh
Normal file
@@ -0,0 +1,7 @@
|
||||
alias fl="flutter"
|
||||
alias flr="flutter run"
|
||||
alias fldoc="flutter doctor"
|
||||
alias flb="flutter build"
|
||||
alias flattach="flutter attach"
|
||||
alias flget="flutter packages get"
|
||||
alias flc="flutter clean"
|
||||
@@ -1,15 +1,23 @@
|
||||
## forklift
|
||||
# forklift
|
||||
|
||||
Plugin for ForkLift, an FTP application for OS X.
|
||||
|
||||
### Requirements
|
||||
To use it, add `forklift` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... forklift)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
* [ForkLift](https://binarynights.com/)
|
||||
|
||||
### Usage
|
||||
## Usage
|
||||
|
||||
<code>fl [*file_or_folder*]</code>
|
||||
`fl [<file_or_folder>]`
|
||||
|
||||
* If `fl` is called without arguments then the current folder is opened in ForkLift. This is equivalent to `fl .`.
|
||||
|
||||
* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift. If called with a non-directory file as the argument, then the file's parent directory is opened.
|
||||
* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift
|
||||
|
||||
* If `fl` is called with a non-directory file as the argument, then the file's parent directory is opened.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Open folder in ForkLift.app or ForkLift2.app from console
|
||||
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
|
||||
# Updated to support ForkLift 2 and ForkLift 3 by Johan Kaving
|
||||
# Updated to support ForkLift from Setapp by Paul Rudkin
|
||||
#
|
||||
# Usage:
|
||||
# fl [<folder>]
|
||||
@@ -24,6 +25,13 @@ function fl {
|
||||
fi
|
||||
osascript 2>&1 1>/dev/null <<END
|
||||
|
||||
try
|
||||
tell application "Finder"
|
||||
set forkLiftSetapp to name of application file id "com.binarynights.forklift-setapp"
|
||||
end tell
|
||||
on error err_msg number err_num
|
||||
set forkLiftSetapp to null
|
||||
end try
|
||||
try
|
||||
tell application "Finder"
|
||||
set forkLift3 to name of application file id "com.binarynights.ForkLift-3"
|
||||
@@ -46,7 +54,12 @@ function fl {
|
||||
set forkLift to null
|
||||
end try
|
||||
|
||||
if forkLift3 is not null and application forkLift3 is running then
|
||||
if forkLiftSetapp is not null and application forkLiftSetapp is running then
|
||||
tell application forkLiftSetapp
|
||||
activate
|
||||
set forkLiftVersion to version
|
||||
end tell
|
||||
else if forkLift3 is not null and application forkLift3 is running then
|
||||
tell application forkLift3
|
||||
activate
|
||||
set forkLiftVersion to version
|
||||
@@ -62,7 +75,9 @@ function fl {
|
||||
set forkLiftVersion to version
|
||||
end tell
|
||||
else
|
||||
if forkLift3 is not null then
|
||||
if forkLiftSetapp is not null then
|
||||
set appName to forkLiftSetapp
|
||||
else if forkLift3 is not null then
|
||||
set appName to forkLift3
|
||||
else if forkLift2 is not null then
|
||||
set appName to forkLift2
|
||||
|
||||
@@ -52,6 +52,7 @@ Available search contexts are:
|
||||
| mdn | `https://developer.mozilla.org/search?q=` |
|
||||
| nodejs | `https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=` |
|
||||
| npmjs | `https://www.npmjs.com/search?q=` |
|
||||
| packagephobia | `https://packagephobia.now.sh/result?p=` |
|
||||
| qunit | `https://api.qunitjs.com/?s=` |
|
||||
| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` |
|
||||
| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` |
|
||||
|
||||
@@ -38,6 +38,7 @@ function _frontend() {
|
||||
'mdn: Search in MDN website'
|
||||
'nodejs: Search in NodeJS website'
|
||||
'npmjs: Search in NPMJS website'
|
||||
'packagephobia: Search in Packagephobia website'
|
||||
'qunit: Search in Qunit website'
|
||||
'reactjs: Search in React website'
|
||||
'smacss: Search in SMACSS website'
|
||||
@@ -124,6 +125,9 @@ function _frontend() {
|
||||
bundlephobia)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
packagephobia)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
flowtype)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
|
||||
@@ -19,6 +19,7 @@ alias lodash='frontend lodash'
|
||||
alias mdn='frontend mdn'
|
||||
alias nodejs='frontend nodejs'
|
||||
alias npmjs='frontend npmjs'
|
||||
alias packagephobia='frontend packagephobia'
|
||||
alias qunit='frontend qunit'
|
||||
alias reactjs='frontend reactjs'
|
||||
alias smacss='frontend smacss'
|
||||
@@ -65,6 +66,7 @@ function frontend() {
|
||||
mdn 'https://developer.mozilla.org/search?q='
|
||||
nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
|
||||
npmjs 'https://www.npmjs.com/search?q='
|
||||
packagephobia 'https://packagephobia.now.sh/result?p='
|
||||
qunit 'https://api.qunitjs.com/?s='
|
||||
reactjs $(_frontend_fallback 'reactjs.org/')
|
||||
smacss $(_frontend_fallback 'smacss.com')
|
||||
@@ -82,7 +84,7 @@ function frontend() {
|
||||
print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
|
||||
print -P "and %Ucontext%u is one of the following:"
|
||||
print -P ""
|
||||
print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
|
||||
print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
|
||||
print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
|
||||
print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
|
||||
print -P ""
|
||||
@@ -98,7 +100,7 @@ function frontend() {
|
||||
echo ""
|
||||
echo "Valid contexts are:"
|
||||
echo ""
|
||||
echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
|
||||
echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
|
||||
echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash,"
|
||||
echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
|
||||
echo ""
|
||||
|
||||
@@ -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) |
|
||||
|
||||
@@ -1,57 +1,110 @@
|
||||
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
|
||||
function setup_using_base_dir() {
|
||||
# Declare all variables local not no mess with outside env in any way
|
||||
local fzf_base
|
||||
local fzf_shell
|
||||
local fzfdirs
|
||||
local dir
|
||||
|
||||
if [[ -z "${fzf_base}" ]]; then
|
||||
fzfdirs=(
|
||||
"${HOME}/.fzf"
|
||||
"/usr/local/opt/fzf"
|
||||
"/usr/share/fzf"
|
||||
)
|
||||
for dir in ${fzfdirs}; do
|
||||
if [[ -d "${dir}" ]]; then
|
||||
fzf_base="${dir}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
|
||||
|
||||
if [[ -z "${fzf_base}" ]]; then
|
||||
if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
|
||||
if [[ -d "${dir}" ]]; then
|
||||
fzf_base="${dir}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ -z "${fzf_base}" ]]; then
|
||||
fzfdirs=(
|
||||
"${HOME}/.fzf"
|
||||
"${HOME}/.nix-profile/share/fzf"
|
||||
"/usr/local/opt/fzf"
|
||||
"/usr/share/fzf"
|
||||
"/usr/local/share/examples/fzf"
|
||||
)
|
||||
for dir in ${fzfdirs}; do
|
||||
if [[ -d "${dir}" ]]; then
|
||||
fzf_base="${dir}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "${fzf_base}" ]]; then
|
||||
if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
|
||||
if [[ -d "${dir}" ]]; then
|
||||
fzf_base="${dir}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -d "${fzf_base}" ]]; then
|
||||
# Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
|
||||
if [[ ! -d "${fzf_base}/shell" ]]; then
|
||||
fzf_shell="${fzf_base}"
|
||||
else
|
||||
fzf_shell="${fzf_base}/shell"
|
||||
fi
|
||||
|
||||
# Setup fzf binary path
|
||||
if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
|
||||
export PATH="$PATH:$fzf_base/bin"
|
||||
fi
|
||||
|
||||
# Auto-completion
|
||||
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
||||
[[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
|
||||
source "${fzf_shell}/key-bindings.zsh"
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function setup_using_debian_package() {
|
||||
(( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null
|
||||
if (( $? )); then
|
||||
# Either not a debian based distro, or no fzf installed. In any case skip ahead
|
||||
return 1
|
||||
fi
|
||||
|
||||
# NOTE: There is no need to configure PATH for debian package, all binaries
|
||||
# are installed to /usr/bin by default
|
||||
|
||||
# Determine completion file path: first bullseye/sid, then buster/stretch
|
||||
local completions="/usr/share/doc/fzf/examples/completion.zsh"
|
||||
[[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
|
||||
|
||||
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
|
||||
|
||||
# Auto-completion
|
||||
if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
||||
source $completions 2> /dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
|
||||
source $key_bindings
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function indicate_error() {
|
||||
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
|
||||
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
|
||||
}
|
||||
|
||||
# Check for debian package first, because it easy to short cut
|
||||
# Indicate to user that fzf installation not found if nothing worked
|
||||
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
|
||||
|
||||
if [[ -n "${fzf_base}" ]]; then
|
||||
|
||||
# Fix fzf shell directory for Archlinux package
|
||||
if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then
|
||||
fzf_shell="${fzf_base}"
|
||||
else
|
||||
fzf_shell="${fzf_base}/shell"
|
||||
fi
|
||||
|
||||
# Setup fzf
|
||||
# ---------
|
||||
if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
|
||||
export PATH="$PATH:$fzf_base/bin"
|
||||
fi
|
||||
|
||||
# Auto-completion
|
||||
# ---------------
|
||||
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
||||
[[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
# ------------
|
||||
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
|
||||
source "${fzf_shell}/key-bindings.zsh"
|
||||
fi
|
||||
|
||||
else
|
||||
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
|
||||
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
|
||||
fi
|
||||
|
||||
unset fzf_base fzf_shell dir fzfdirs
|
||||
|
||||
10
zsh/plugins/gas/README.md
Normal file
10
zsh/plugins/gas/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Gas plugin
|
||||
|
||||
This plugin adds autocompletion for the [gas](http://walle.github.com/gas) command,
|
||||
a utility to manage Git authors.
|
||||
|
||||
To use it, add `gas` to the plugins array of your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... gas)
|
||||
```
|
||||
24
zsh/plugins/gcloud/README.md
Normal file
24
zsh/plugins/gcloud/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# gcloud
|
||||
|
||||
This plugin provides completion support for the
|
||||
[Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/).
|
||||
|
||||
To use it, add `gcloud` to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... gcloud)
|
||||
```
|
||||
|
||||
It relies on you having installed the SDK using one of the supported options
|
||||
listed [here](https://cloud.google.com/sdk/install).
|
||||
|
||||
## Plugin Options
|
||||
|
||||
* Set `CLOUDSDK_HOME` in your `zshrc` file before you load oh-my-zsh if you have
|
||||
your GCloud SDK installed in a non-standard location. The plugin will use this
|
||||
as the base for your SDK if it finds it set already.
|
||||
|
||||
* If you do not have a `python2` in your `PATH` you'll also need to set the
|
||||
`CLOUDSDK_PYTHON` environment variable at the end of your `.zshrc`. This is
|
||||
used by the SDK to call a compatible interpreter when you run one of the
|
||||
SDK commands.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user