mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
Merge branch 'ohmyzsh:master' into conda
This commit is contained in:
commit
2b1bd03705
60 changed files with 1183 additions and 5079 deletions
|
|
@ -1,46 +1,9 @@
|
|||
if (( ${+commands[op]} )); then
|
||||
eval "$(op completion zsh)"
|
||||
compdef _op op
|
||||
fi
|
||||
# Do nothing if op is not installed
|
||||
(( ${+commands[op]} )) || return
|
||||
|
||||
# opswd puts the password of the named service into the clipboard. If there's a
|
||||
# one time password, it will be copied into the clipboard after 10 seconds. The
|
||||
# clipboard is cleared after another 20 seconds.
|
||||
function opswd() {
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "Usage: opswd <service>"
|
||||
return 1
|
||||
fi
|
||||
# Load op completion
|
||||
eval "$(op completion zsh)"
|
||||
compdef _op op
|
||||
|
||||
local service=$1
|
||||
|
||||
# If not logged in, print error and return
|
||||
op list users > /dev/null || return
|
||||
|
||||
local password
|
||||
# Copy the password to the clipboard
|
||||
if ! password=$(op get item "$service" --fields password 2>/dev/null); then
|
||||
echo "error: could not obtain password for $service"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -n "$password" | clipcopy
|
||||
echo "✔ password for $service copied to clipboard"
|
||||
|
||||
# If there's a one time password, copy it to the clipboard after 5 seconds
|
||||
local totp
|
||||
if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
|
||||
sleep 10 && echo -n "$totp" | clipcopy
|
||||
echo "✔ TOTP for $service copied to clipboard"
|
||||
fi
|
||||
|
||||
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
|
||||
}
|
||||
|
||||
function _opswd() {
|
||||
local -a services
|
||||
services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
|
||||
[[ -z "$services" ]] || compadd -a -- services
|
||||
}
|
||||
|
||||
compdef _opswd opswd
|
||||
# Load opswd function
|
||||
autoload -Uz opswd
|
||||
|
|
|
|||
|
|
@ -25,11 +25,14 @@ which service you want to get.
|
|||
For example, `opswd github.com` will put your GitHub password into your clipboard, and if
|
||||
a TOTP is available, it will be copied to the clipboard after 10 seconds.
|
||||
|
||||
> NOTE: you need to be logged in for `opswd` to work. See:
|
||||
> NOTE: you need to be signed in for `opswd` to work. If you are using biometric unlock,
|
||||
> 1Password CLI will automatically prompt you to sign in. See:
|
||||
>
|
||||
> - [Sign in or out](https://support.1password.com/command-line/#sign-in-or-out)
|
||||
> - [Session management](https://support.1password.com/command-line/#appendix-session-management)
|
||||
> - [Get started with 1Password CLI 2: Sign in](https://developer.1password.com/docs/cli/get-started#sign-in)
|
||||
> - [Sign in to your 1Password account manually](https://developer.1password.com/docs/cli/sign-in-manually)
|
||||
|
||||
## Requirements
|
||||
|
||||
- [1Password's command line utility](https://1password.com/downloads/command-line/).
|
||||
- [1Password CLI 2](https://developer.1password.com/docs/cli/get-started#install)
|
||||
|
||||
> NOTE: if you're using 1Password CLI 1, [see how to upgrade to CLI 2](https://developer.1password.com/docs/cli/upgrade).
|
||||
|
|
|
|||
19
plugins/1password/_opswd
Normal file
19
plugins/1password/_opswd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#compdef opswd
|
||||
|
||||
function _opswd() {
|
||||
local -a services
|
||||
services=("${(@f)$(op item list --categories Login --cache 2>/dev/null | awk 'NR != 1 { print $2 }')}")
|
||||
[[ -z "$services" ]] || compadd -a -- services
|
||||
}
|
||||
|
||||
# TODO: 2022-03-26: Remove support for op CLI 1
|
||||
autoload -Uz is-at-least
|
||||
is-at-least 2.0.0 $(op --version) || {
|
||||
function _opswd() {
|
||||
local -a services
|
||||
services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
|
||||
[[ -z "$services" ]] || compadd -a -- services
|
||||
}
|
||||
}
|
||||
|
||||
_opswd "$@"
|
||||
78
plugins/1password/opswd
Normal file
78
plugins/1password/opswd
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#autoload
|
||||
|
||||
# opswd puts the password of the named service into the clipboard. If there's a
|
||||
# one time password, it will be copied into the clipboard after 10 seconds. The
|
||||
# clipboard is cleared after another 20 seconds.
|
||||
function opswd() {
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "Usage: opswd <service>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local service=$1
|
||||
|
||||
# If not logged in, print error and return
|
||||
op user list > /dev/null || return
|
||||
|
||||
local password
|
||||
# Copy the password to the clipboard
|
||||
if ! password=$(op item get "$service" --fields password 2>/dev/null); then
|
||||
echo "error: could not obtain password for $service"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -n "$password" | clipcopy
|
||||
echo "✔ password for $service copied to clipboard"
|
||||
|
||||
# If there's a one time password, copy it to the clipboard after 10 seconds
|
||||
local totp
|
||||
if totp=$(op item get --otp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
|
||||
sleep 10 && echo -n "$totp" | clipcopy
|
||||
echo "✔ TOTP for $service copied to clipboard"
|
||||
fi
|
||||
|
||||
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
|
||||
}
|
||||
|
||||
# TODO: 2022-03-26: Remove support for op CLI 1
|
||||
autoload -Uz is-at-least
|
||||
is-at-least 2.0.0 $(op --version) || {
|
||||
print -ru2 ${(%):-"%F{yellow}opswd: usage with op version $(op --version) is deprecated. Upgrade to CLI 2 and reload zsh.
|
||||
For instructions, see https://developer.1password.com/docs/cli/upgrade.%f"}
|
||||
|
||||
# opswd puts the password of the named service into the clipboard. If there's a
|
||||
# one time password, it will be copied into the clipboard after 10 seconds. The
|
||||
# clipboard is cleared after another 20 seconds.
|
||||
function opswd() {
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "Usage: opswd <service>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local service=$1
|
||||
|
||||
# If not logged in, print error and return
|
||||
op list users > /dev/null || return
|
||||
|
||||
local password
|
||||
# Copy the password to the clipboard
|
||||
if ! password=$(op get item "$service" --fields password 2>/dev/null); then
|
||||
echo "error: could not obtain password for $service"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -n "$password" | clipcopy
|
||||
echo "✔ password for $service copied to clipboard"
|
||||
|
||||
# If there's a one time password, copy it to the clipboard after 5 seconds
|
||||
local totp
|
||||
if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
|
||||
sleep 10 && echo -n "$totp" | clipcopy
|
||||
echo "✔ TOTP for $service copied to clipboard"
|
||||
fi
|
||||
|
||||
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
|
||||
}
|
||||
}
|
||||
|
||||
opswd "$@"
|
||||
|
|
@ -13,6 +13,7 @@ if ! type autoenv_init >/dev/null; then
|
|||
~/.autoenv
|
||||
~/.local/bin
|
||||
/usr/local/opt/autoenv
|
||||
/opt/homebrew/opt/autoenv
|
||||
/usr/local/bin
|
||||
/usr/share/autoenv-git
|
||||
~/Library/Python/bin
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ compctl -K _aws_profiles asp acp aws_change_access_key
|
|||
# AWS prompt
|
||||
function aws_prompt_info() {
|
||||
[[ -n "$AWS_PROFILE" ]] || return
|
||||
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX:=>}"
|
||||
echo "${ZSH_THEME_AWS_PREFIX=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX=>}"
|
||||
}
|
||||
|
||||
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
## Bazel autocomplete plugin
|
||||
# Bazel plugin
|
||||
|
||||
A copy of the completion script from the
|
||||
[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel)
|
||||
git repo.
|
||||
This plugin adds completion for [bazel](https://bazel.build), an open-source build and
|
||||
test tool that scalably supports multi-language and multi-platform projects.
|
||||
|
||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... bazel)
|
||||
```
|
||||
|
||||
The plugin has a copy of [the completion script from the git repository][1].
|
||||
|
||||
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'}
|
||||
print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
|
||||
|
||||
# TODO: 2021-12-28: remove this block
|
||||
# Handle $0 according to the standard:
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
# Remove old generated completion file
|
||||
command rm -f "${0:A:h}/_cargo" "$ZSH_CACHE_DIR/cargo_version"
|
||||
|
||||
(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {
|
||||
fpath=("$ZSH/plugins/rust" $fpath)
|
||||
source "$ZSH/plugins/rust/rust.plugin.zsh"
|
||||
|
|
|
|||
9
plugins/charm/README.md
Normal file
9
plugins/charm/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Charm plugin
|
||||
|
||||
This plugin adds completion for the [charm](https://github.com/charmbracelet/charm) CLI.
|
||||
|
||||
To use it, add `charm` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... charm)
|
||||
```
|
||||
14
plugins/charm/charm.plugin.zsh
Normal file
14
plugins/charm/charm.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for the Charm CLI (charm).
|
||||
if (( ! $+commands[charm] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `charm`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_charm" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _charm
|
||||
_comps[charm]=_charm
|
||||
fi
|
||||
|
||||
charm completion zsh >| "$ZSH_CACHE_DIR/completions/_charm" &|
|
||||
|
|
@ -39,14 +39,14 @@
|
|||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
local curcontext="$curcontext" state line ret=1 version opts first second third
|
||||
local curcontext="$curcontext" state line ret=1 version
|
||||
local -a opts
|
||||
typeset -A opt_args
|
||||
version=(${(f)"$(_call_program version $words[1] --version)"})
|
||||
version=(${(f)"$(_call_program version $words[1] --version)"}) || return ret
|
||||
version=${${(z)${version[1]}}[3]}
|
||||
first=$(echo $version|cut -d '.' -f 1)
|
||||
second=$(echo $version|cut -d '.' -f 2)
|
||||
third=$(echo $version|cut -d '.' -f 3)
|
||||
if (( $first < 2 )) && (( $second < 7 )) && (( $third < 3 ));then
|
||||
|
||||
autoload -Uz is-at-least
|
||||
if ! is-at-least 1.6.3 "$version"; then
|
||||
opts+=('(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]'
|
||||
'(-r --require)'{-r,--require}'[require a library before executing your script]:library')
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,80 +1,84 @@
|
|||
# Usage: dash [keyword:]query
|
||||
dash() { open dash://"$*" }
|
||||
dash() { open -a Dash.app dash://"$*" }
|
||||
compdef _dash dash
|
||||
|
||||
_dash() {
|
||||
# No sense doing this for anything except the 2nd position and if we haven't
|
||||
# specified which docset to query against
|
||||
if [[ $CURRENT -eq 2 && ! "$words[2]" =~ ":" ]]; then
|
||||
local -a _all_docsets
|
||||
_all_docsets=()
|
||||
# Use defaults to get the array of docsets from preferences
|
||||
# Have to smash it into one big line so that each docset is an element of
|
||||
# our DOCSETS array
|
||||
DOCSETS=("${(@f)$(defaults read com.kapeli.dashdoc docsets | tr -d '\n' | grep -oE '\{.*?\}')}")
|
||||
if [[ $CURRENT -ne 2 || "$words[2]" =~ ":" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# remove all newlines since defaults prints so pretty like
|
||||
# Now get each docset and output each on their own line
|
||||
for doc in "$DOCSETS[@]"; do
|
||||
# Only output docsets that are actually enabled
|
||||
if [[ "`echo $doc | grep -Eo \"isEnabled = .*?;\" | sed 's/[^01]//g'`" == "0" ]]; then
|
||||
local -aU docsets
|
||||
docsets=()
|
||||
|
||||
# Use defaults to get the array of docsets from preferences
|
||||
# Have to smash it into one big line so that each docset is an element of our docsets array
|
||||
# Only output docsets that are actually enabled
|
||||
local -a enabled_docsets
|
||||
enabled_docsets=("${(@f)$(defaults read com.kapeli.dashdoc docsets \
|
||||
| tr -d '\n' | grep -oE '\{.*?\}' | grep -E 'isEnabled = 1;')}")
|
||||
|
||||
local docset name keyword
|
||||
# Now get each docset and output each on their own line
|
||||
for docset in "$enabled_docsets[@]"; do
|
||||
keyword=''
|
||||
# Order of preference as explained to me by @kapeli via email
|
||||
for locator in keyword suggestedKeyword platform; do
|
||||
# Echo the docset, try to find the appropriate keyword
|
||||
# Strip doublequotes and colon from any keyword so that everything has the
|
||||
# same format when output (we'll add the colon in the completion)
|
||||
if [[ "$docset" =~ "$locator = ([^;]*);" ]]; then
|
||||
keyword="${match[1]//[\":]}"
|
||||
fi
|
||||
|
||||
if [[ -z "$keyword" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
keyword=''
|
||||
|
||||
# Order of preference as explained to me by @kapeli via email
|
||||
KEYWORD_LOCATORS=(keyword suggestedKeyword platform)
|
||||
for locator in "$KEYWORD_LOCATORS[@]"; do
|
||||
# Echo the docset, try to find the appropriate keyword
|
||||
# Strip doublequotes and colon from any keyword so that everything has the
|
||||
# same format when output (we'll add the colon in the completion)
|
||||
keyword=`echo $doc | grep -Eo "$locator = .*?;" | sed -e "s/$locator = \(.*\);/\1/" -e "s/[\":]//g"`
|
||||
if [[ ! -z "$keyword" ]]; then
|
||||
# if we fall back to platform, we should do some checking per @kapeli
|
||||
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|java|qt|cocos2d) ]]; then
|
||||
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
|
||||
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
|
||||
# if we fall back to platform, we should do some checking per @kapeli
|
||||
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|java|qt|cocos2d) ]]; then
|
||||
if [[ "$docset" =~ "docsetName = ([^;]*);" ]]; then
|
||||
name="${match[1]//[\":]}"
|
||||
case "$keyword" in
|
||||
python)
|
||||
case "$name" in
|
||||
"Python 2") keyword="python2" ;;
|
||||
"Python 3") keyword="python3" ;;
|
||||
esac ;;
|
||||
java)
|
||||
case "$name" in
|
||||
"Java SE7") keyword="java7" ;;
|
||||
"Java SE6") keyword="java6" ;;
|
||||
"Java SE8") keyword="java8" ;;
|
||||
esac ;;
|
||||
qt)
|
||||
case "$name" in
|
||||
"Qt 5") keyword="qt5" ;;
|
||||
"Qt 4"|Qt) keyword="qt4" ;;
|
||||
esac ;;
|
||||
cocos2d)
|
||||
case "$name" in
|
||||
Cocos3D) keyword="cocos3d" ;;
|
||||
esac ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Bail once we have a match
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# If we have a keyword, add it to the list!
|
||||
if [[ ! -z "$keyword" ]]; then
|
||||
_all_docsets+=($keyword)
|
||||
fi
|
||||
|
||||
# Bail once we have a match
|
||||
break
|
||||
done
|
||||
|
||||
# special thanks to [arx] on #zsh for getting me sorted on this piece
|
||||
compadd -qS: -- "$_all_docsets[@]"
|
||||
return
|
||||
fi
|
||||
# If we have a keyword, add it to the list!
|
||||
if [[ -n "$keyword" ]]; then
|
||||
docsets+=($keyword)
|
||||
fi
|
||||
done
|
||||
|
||||
# special thanks to [arx] on #zsh for getting me sorted on this piece
|
||||
compadd -qS: -- "$docsets[@]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,19 +16,6 @@ if (( ! $+commands[deno] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# TODO: 2021-12-28: remove this block
|
||||
# Handle $0 according to the standard:
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
# Remove old generated files
|
||||
command rm -f "${0:A:h}/_deno" "$ZSH_CACHE_DIR/deno_version"
|
||||
|
||||
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
|
||||
# Add completions folder in $ZSH_CACHE_DIR
|
||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `deno`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then
|
||||
|
|
|
|||
|
|
@ -2,19 +2,6 @@ if (( ! $+commands[fnm] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# TODO: 2021-12-28: remove this block
|
||||
# Handle $0 according to the standard:
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
# remove old generated files
|
||||
command rm -f "${0:A:h}/_fnm" "$ZSH_CACHE_DIR/fnm_version"
|
||||
|
||||
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
|
||||
# Add completions folder in $ZSH_CACHE_DIR
|
||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `fnm`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ export FZF_DEFAULT_COMMAND='<your fzf default command>'
|
|||
|
||||
If not set, the plugin will try to set it to these, in the order in which they're found:
|
||||
|
||||
- [`rg`](https://github.com/BurntSushi/ripgrep)
|
||||
- [`fd`](https://github.com/sharkdp/fd)
|
||||
- [`rg`](https://github.com/BurntSushi/ripgrep)
|
||||
- [`ag`](https://github.com/ggreer/the_silver_searcher)
|
||||
|
||||
### `DISABLE_FZF_AUTO_COMPLETION`
|
||||
|
|
|
|||
|
|
@ -173,6 +173,32 @@ function fzf_setup_using_cygwin() {
|
|||
return 0
|
||||
}
|
||||
|
||||
function fzf_setup_using_macports() {
|
||||
# If the command is not found, the package isn't installed
|
||||
(( $+commands[fzf] )) || return 1
|
||||
|
||||
# The fzf-zsh-completion package installs the auto-completion in
|
||||
local completions="/opt/local/share/zsh/site-functions/fzf"
|
||||
# The fzf-zsh-completion package installs the key-bindings file in
|
||||
local key_bindings="/opt/local/share/fzf/shell/key-bindings.zsh"
|
||||
|
||||
if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Auto-completion
|
||||
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
|
||||
source "$completions" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
|
||||
source "$key_bindings" 2>/dev/null
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Indicate to user that fzf installation not found if nothing worked
|
||||
function fzf_setup_error() {
|
||||
cat >&2 <<'EOF'
|
||||
|
|
@ -185,16 +211,17 @@ fzf_setup_using_openbsd \
|
|||
|| fzf_setup_using_debian \
|
||||
|| fzf_setup_using_opensuse \
|
||||
|| fzf_setup_using_cygwin \
|
||||
|| fzf_setup_using_macports \
|
||||
|| fzf_setup_using_base_dir \
|
||||
|| fzf_setup_error
|
||||
|
||||
unset -f -m 'fzf_setup_*'
|
||||
|
||||
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
||||
if (( $+commands[rg] )); then
|
||||
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
|
||||
elif (( $+commands[fd] )); then
|
||||
if (( $+commands[fd] )); then
|
||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
|
||||
elif (( $+commands[rg] )); then
|
||||
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
|
||||
elif (( $+commands[ag] )); then
|
||||
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -3,19 +3,6 @@ if (( ! $+commands[gh] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# TODO: 2021-12-28: remove this block
|
||||
# Handle $0 according to the standard:
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
# Remove old generated files
|
||||
command rm -f "${0:A:h}/_gh" "$ZSH_CACHE_DIR/gh_version"
|
||||
|
||||
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
|
||||
# Add completions folder in $ZSH_CACHE_DIR
|
||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `gh`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ autoload -U add-zsh-hook
|
|||
add-zsh-hook preexec _gpg-agent_update-tty_preexec
|
||||
|
||||
# If enable-ssh-support is set, fix ssh agent integration
|
||||
if [[ $(gpgconf --list-options gpg-agent | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
|
||||
if [[ $(gpgconf --list-options gpg-agent 2>/dev/null | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
|
||||
unset SSH_AGENT_PID
|
||||
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
|
||||
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
|
||||
|
|
|
|||
|
|
@ -2,15 +2,6 @@ if (( ! $+commands[helm] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# TODO: 2021-12-28: delete this block
|
||||
# Remove old generated file
|
||||
command rm -f "${ZSH_CACHE_DIR}/helm_completion"
|
||||
|
||||
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
|
||||
# Add completions folder in $ZSH_CACHE_DIR
|
||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# If the completion file does not exist, generate it and then source it
|
||||
# Otherwise, source it and regenerate in the background
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ plugins=(... kubectl)
|
|||
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
|
||||
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
|
||||
| kccc | `kubectl config current-context` | Display the current-context |
|
||||
| kcgc | `kubectl config get-contexts` | List of contexts available
|
||||
| kcgc | `kubectl config get-contexts` | List of contexts available |
|
||||
| | | **General aliases** |
|
||||
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
|
||||
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
|
||||
|
|
@ -71,9 +71,11 @@ plugins=(... kubectl)
|
|||
| kdeld | `kubectl delete deployment` | Delete the deployment |
|
||||
| ksd | `kubectl scale deployment` | Scale a deployment |
|
||||
| krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
|
||||
| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
|
||||
| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
|
||||
| | | **Rollout management** |
|
||||
| kgrs | `kubectl get rs` | To see the ReplicaSet `rs` created by the deployment |
|
||||
| kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment |
|
||||
| kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail |
|
||||
| kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor |
|
||||
| krh | `kubectl rollout history` | Check the revisions of this deployment |
|
||||
| kru | `kubectl rollout undo` | Rollback to the previous revision |
|
||||
| | | **Port forwarding** |
|
||||
|
|
@ -120,6 +122,11 @@ plugins=(... kubectl)
|
|||
| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
|
||||
| kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
|
||||
| kdelcj | `kubectl delete cronjob` | Delete the CronJob |
|
||||
| | | **Job management** |
|
||||
| kgj | `kubectl get job` | List all Job in ps output format |
|
||||
| kej | `kubectl edit job` | Edit a Job in details |
|
||||
| kdj | `kubectl describe job` | Describe the Job |
|
||||
| kdelj | `kubectl delete job` | Delete the Job |
|
||||
|
||||
## Wrappers
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,4 @@
|
|||
if (( $+commands[kubectl] )); then
|
||||
# TODO: 2022-01-05: remove this block
|
||||
# remove old generated files
|
||||
command rm -f "$ZSH_CACHE_DIR/kubectl_completion"
|
||||
|
||||
# TODO: 2022-01-05: remove this bit of code as it exists in oh-my-zsh.sh
|
||||
# Add completions folder in $ZSH_CACHE_DIR
|
||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# If the completion file does not exist, generate it and then source it
|
||||
# Otherwise, source it and regenerate in the background
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then
|
||||
|
|
@ -112,7 +103,9 @@ function kres(){
|
|||
}
|
||||
|
||||
# Rollout management.
|
||||
alias kgrs='kubectl get rs'
|
||||
alias kgrs='kubectl get replicaset'
|
||||
alias kdrs='kubectl describe replicaset'
|
||||
alias kers='kubectl edit replicaset'
|
||||
alias krh='kubectl rollout history'
|
||||
alias kru='kubectl rollout undo'
|
||||
|
||||
|
|
@ -178,6 +171,12 @@ alias kecj='kubectl edit cronjob'
|
|||
alias kdcj='kubectl describe cronjob'
|
||||
alias kdelcj='kubectl delete cronjob'
|
||||
|
||||
# Job management.
|
||||
alias kgj='kubectl get job'
|
||||
alias kej='kubectl edit job'
|
||||
alias kdj='kubectl describe job'
|
||||
alias kdelj='kubectl delete job'
|
||||
|
||||
# Only run if the user actually has kubectl installed
|
||||
if (( ${+_comps[kubectl]} )); then
|
||||
function kj() { kubectl "$@" -o json | jq; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# Rails
|
||||
|
||||
This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and [Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables.
|
||||
This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and
|
||||
[Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables.
|
||||
|
||||
To use it, add `rails` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
@ -12,47 +13,52 @@ plugins=(... rails)
|
|||
|
||||
### Rails aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|----------------------------|----------------------------------------------------|
|
||||
| `rc` | `rails console` | Interact with your Rails app from the CLI |
|
||||
| `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data |
|
||||
| `rd` | `rails destroy` | Undo a generate operation |
|
||||
| `rdb` | `rails dbconsole` | Interact with your db from the console |
|
||||
| `rgen`| `rails generate` | Generate boilerplate code |
|
||||
| `rgm` | `rails generate migration` | Generate a db migration |
|
||||
| `rp` | `rails plugin` | Run a Rails plugin command |
|
||||
| `rr` | `rails routes` | List all defined routes |
|
||||
| `rrg` | `rails routes \| grep` | List and filter the defined routes |
|
||||
| `ru` | `rails runner` | Run Ruby code in the context of Rails |
|
||||
| `rs` | `rails server` | Launch a web server |
|
||||
| `rsd` | `rails server --debugger` | Launch a web server with debugger |
|
||||
| `rsp` | `rails server --port` | Launch a web server and specify the listening port |
|
||||
| Alias | Command | Description |
|
||||
| ------- | -------------------------------- | ------------------------------------------------------ |
|
||||
| `rc` | `rails console` | Interact with your Rails app from the CLI |
|
||||
| `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data |
|
||||
| `rd` | `rails destroy` | Undo a generate operation |
|
||||
| `rdb` | `rails dbconsole` | Interact with your db from the console |
|
||||
| `rdc` | `rails db:create` | Create the database |
|
||||
| `rdd` | `rails db:drop` | Delete the database |
|
||||
| `rdm` | `rails db:migrate` | Run pending db migrations |
|
||||
| `rdmd` | `rails db:migrate:down` | Undo specific db migration |
|
||||
| `rdmr` | `rails db:migrate:redo` | Redo specific db migration |
|
||||
| `rdms` | `rails db:migrate:status` | Show current db migration status |
|
||||
| `rdmtc` | `rails db:migrate db:test:clone` | Run pending migrations and clone db into test database |
|
||||
| `rdmu` | `rails db:migrate:up` | Run specific db migration |
|
||||
| `rdr` | `rails db:rollback` | Roll back the last migration |
|
||||
| `rdrs` | `rails db:reset` | Delete the database and set it up again |
|
||||
| `rds` | `rails db:seed` | Seed the database |
|
||||
| `rdsl` | `rails db:schema:load` | Load the database schema |
|
||||
| `rdtc` | `rails db:test:clone` | Clone the database into the test database |
|
||||
| `rdtp` | `rails db:test:prepare` | Duplicate the db schema into your test database |
|
||||
| `rgen` | `rails generate` | Generate boilerplate code |
|
||||
| `rgm` | `rails generate migration` | Generate a db migration |
|
||||
| `rlc` | `rails log:clear` | Clear Rails logs |
|
||||
| `rmd` | `rails middleware` | Interact with Rails middlewares |
|
||||
| `rn` | `rails notes` | Search for notes (`FIXME`, `TODO`) in code comments |
|
||||
| `rp` | `rails plugin` | Run a Rails plugin command |
|
||||
| `rr` | `rails routes` | List all defined routes |
|
||||
| `rrg` | `rails routes \| grep` | List and filter the defined routes |
|
||||
| `rs` | `rails server` | Launch a web server |
|
||||
| `rsb` | `rails server --bind` | Launch a web server binding it to a specific IP |
|
||||
| `rsd` | `rails server --debugger` | Launch a web server with debugger |
|
||||
| `rsp` | `rails server --port` | Launch a web server and specify the listening port |
|
||||
| `rsts` | `rails stats` | Print code statistics |
|
||||
| `rt` | `rails test` | Run Rails tests |
|
||||
| `ru` | `rails runner` | Run Ruby code in the context of Rails |
|
||||
|
||||
### Rake aliases
|
||||
### Foreman
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|---------------------------------|--------------------------------------------------------|
|
||||
| `rdm` | `rake db:migrate` | Run pending db migrations |
|
||||
| `rdms` | `rake db:migrate:status` | Show current db migration status |
|
||||
| `rdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database |
|
||||
| `rdr` | `rake db:rollback` | Roll back the last migration |
|
||||
| `rdc` | `rake db:create` | Create the database |
|
||||
| `rds` | `rake db:seed` | Seed the database |
|
||||
| `rdd` | `rake db:drop` | Delete the database |
|
||||
| `rdrs` | `rake db:reset` | Delete the database and set it up again |
|
||||
| `rdtc` | `rake db:test:clone` | Clone the database into the test database |
|
||||
| `rdtp` | `rake db:test:prepare` | Duplicate the db schema into your test database |
|
||||
| `rdsl` | `rake db:schema:load` | Load the database schema |
|
||||
| `rlc` | `rake log:clear` | Clear Rails logs |
|
||||
| `rn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments |
|
||||
| `rt` | `rake test` | Run Rails tests |
|
||||
| `rmd` | `rake middleware` | Interact with Rails middlewares |
|
||||
| `rsts` | `rake stats` | Print code statistics |
|
||||
| Alias | Command | Description |
|
||||
| ------ | --------------- | ----------------------------------------- |
|
||||
| `fmns` | `foreman start` | Interact with your Rails app from the CLI |
|
||||
|
||||
### Utility aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-----------|-------------------------------|------------------------------------------------|
|
||||
| --------- | ----------------------------- | ---------------------------------------------- |
|
||||
| `devlog` | `tail -f log/development.log` | Show and follow changes to the development log |
|
||||
| `prodlog` | `tail -f log/production.log` | Show and follow changes to the production log |
|
||||
| `testlog` | `tail -f log/test.log` | Show and follow changes to the test log |
|
||||
|
|
@ -60,7 +66,7 @@ plugins=(... rails)
|
|||
### Environment settings
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|-------------------------|---------------------------------|
|
||||
| ----- | ----------------------- | ------------------------------- |
|
||||
| `RED` | `RAILS_ENV=development` | Sets `RAILS_ENV` to development |
|
||||
| `REP` | `RAILS_ENV=production` | Sets `RAILS_ENV` to production |
|
||||
| `RET` | `RAILS_ENV=test` | Sets `RAILS_ENV` to test |
|
||||
|
|
@ -68,15 +74,45 @@ plugins=(... rails)
|
|||
These are global aliases. Use in combination with a command or just run them
|
||||
separately. For example: `REP rake db:migrate` will migrate the production db.
|
||||
|
||||
### Legacy stuff
|
||||
## Legacy
|
||||
|
||||
### Rake aliases
|
||||
|
||||
The following commands are run [using `rails` instead of `rake` since Rails v5][1], but are preserved under the
|
||||
prefix `rk` for backwards compatibility.
|
||||
|
||||
[1]: https://guides.rubyonrails.org/v5.2/command_line.html#bin-rails
|
||||
|
||||
| Alias | Command | Description |
|
||||
| -------- | ------------------------------- | ------------------------------------------------------ |
|
||||
| `rkdc` | `rake db:create` | Create the database |
|
||||
| `rkdd` | `rake db:drop` | Delete the database |
|
||||
| `rkdm` | `rake db:migrate` | Run pending db migrations |
|
||||
| `rkdms` | `rake db:migrate:status` | Show current db migration status |
|
||||
| `rkdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database |
|
||||
| `rkdr` | `rake db:rollback` | Roll back the last migration |
|
||||
| `rkdrs` | `rake db:reset` | Delete the database and set it up again |
|
||||
| `rkds` | `rake db:seed` | Seed the database |
|
||||
| `rkdsl` | `rake db:schema:load` | Load the database schema |
|
||||
| `rkdtc` | `rake db:test:clone` | Clone the database into the test database |
|
||||
| `rkdtp` | `rake db:test:prepare` | Duplicate the db schema into your test database |
|
||||
| `rklc` | `rake log:clear` | Clear Rails logs |
|
||||
| `rkmd` | `rake middleware` | Interact with Rails middlewares |
|
||||
| `rkn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments |
|
||||
| `rksts` | `rake stats` | Print code statistics |
|
||||
| `rkt` | `rake test` | Run Rails tests |
|
||||
|
||||
### Other
|
||||
|
||||
| Alias | Command |
|
||||
|---------|------------------------------------|
|
||||
| `sstat` | `thin --stats "/thin/stats" start` |
|
||||
| `sg` | `ruby script/generate` |
|
||||
| ------- | ---------------------------------- |
|
||||
| `sc` | `ruby script/console` |
|
||||
| `sd` | `ruby script/destroy` |
|
||||
| `sd` | `ruby script/server --debugger` |
|
||||
| `sg` | `ruby script/generate` |
|
||||
| `sp` | `ruby script/plugin` |
|
||||
| `sr` | `ruby script/runner` |
|
||||
| `ssp` | `ruby script/spec` |
|
||||
| `sc` | `ruby script/console` |
|
||||
| `sd` | `ruby script/server --debugger` |
|
||||
| `sstat` | `thin --stats "/thin/stats" start` |
|
||||
|
||||
- `remote_console <server> <directory>`: runs `ruby script/console production` on a remote server.
|
||||
|
|
|
|||
|
|
@ -1,66 +1,624 @@
|
|||
#compdef rails
|
||||
#autoload
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the zsh-users nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for Ruby on Rails (http://rubyonrails.org/).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Kazuya Takeshima (https://github.com/mitukiii)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'generate:Generate new code (short-cut alias: "g")'
|
||||
'console:Start the Rails console (short-cut alias: "c")'
|
||||
'server:Start the Rails server (short-cut alias: "s")'
|
||||
'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")'
|
||||
'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"'
|
||||
'application:Generate the Rails application code'
|
||||
'destroy:Undo code generated with "generate"'
|
||||
|
||||
'benchmarker:See how fast a piece of code runs'
|
||||
'profiler:Get profile information from a piece of code'
|
||||
'plugin:Install a plugin'
|
||||
_rails() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
'plugin new:Generates skeleton for developing a Rails plugin'
|
||||
'runner:Run a piece of code in the application environment (short-cut alias: "r")'
|
||||
)
|
||||
|
||||
_rails_generate_arguments() {
|
||||
generate_arguments=(
|
||||
assets
|
||||
controller
|
||||
decorator
|
||||
generator
|
||||
helper
|
||||
integration_test
|
||||
mailer
|
||||
migration
|
||||
model
|
||||
observer
|
||||
performance_test
|
||||
plugin
|
||||
resource
|
||||
scaffold
|
||||
scaffold_controller
|
||||
session_migration
|
||||
stylesheets
|
||||
task
|
||||
)
|
||||
if (( CURRENT > 2 )); then
|
||||
(( CURRENT-- ))
|
||||
shift words
|
||||
_call_function - "_rails_${words[1]}" || _nothing
|
||||
else
|
||||
__rails_commands
|
||||
fi
|
||||
}
|
||||
|
||||
__rails_commands() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
_arguments \
|
||||
'(--version)--version[show version]' \
|
||||
'(--help)--help[show help]' \
|
||||
'*:: :->subcmds' && return 0
|
||||
local -a rails_options
|
||||
__rails_setup_rails_options
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "rails subcommand" _1st_arguments
|
||||
return
|
||||
else
|
||||
_files
|
||||
return
|
||||
fi
|
||||
_arguments -C \
|
||||
$rails_options \
|
||||
': :->command'
|
||||
|
||||
case "$words[1]" in
|
||||
g|generate)
|
||||
_rails_generate_arguments
|
||||
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
|
||||
d|destroy)
|
||||
_rails_generate_arguments
|
||||
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
|
||||
esac
|
||||
case "$state" in
|
||||
command)
|
||||
local -a commands
|
||||
local application_directory
|
||||
__rails_setup_application_directory
|
||||
|
||||
if [ -n "$application_directory" ]; then
|
||||
commands=(
|
||||
{generate,g}'[Generate new code]'
|
||||
{console,c}'[Start the Rails console]'
|
||||
{server,s}'[Start the Rails server]'
|
||||
{dbconsole,db}'[Start a console for the database specified in config/database.yml]'
|
||||
application'[Generate the Rails application code]'
|
||||
{destroy,d}'[Undo code generated with "generate"]'
|
||||
benchmarker'[See how fast a piece of code runs]'
|
||||
profiler'[Get profile information from a piece of code]'
|
||||
plugin'[Install a plugin]'
|
||||
{runner,r}'[Run a piece of code in the application environment]'
|
||||
{test,t}'[Run tests]'
|
||||
)
|
||||
else
|
||||
commands=(
|
||||
new'[Create a new Rails application]'
|
||||
)
|
||||
fi
|
||||
|
||||
_values 'command' $commands
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__rails_setup_application_directory() {
|
||||
application_directory="$(pwd)"
|
||||
|
||||
while [ -n "$application_directory" ]; do
|
||||
if [ -f "${application_directory}/script/rails" -o -f "${application_directory}/bin/rails" ]; then
|
||||
return
|
||||
fi
|
||||
application_directory="${application_directory%/*}"
|
||||
done
|
||||
|
||||
application_directory=
|
||||
}
|
||||
|
||||
__rails_setup_rails_options() {
|
||||
rails_options=(
|
||||
{-h,--help}'[Show this help message and quit]'
|
||||
{-v,--version}'[Show Rails version number and quit]'
|
||||
)
|
||||
}
|
||||
|
||||
__rails_setup_runtime_options() {
|
||||
runtime_options=(
|
||||
'(-f --force)'{-f,--force}'[Overwrite files that already exist]'
|
||||
'(-p --pretend)'{-p,--pretend}'[Run but do not make any changes]'
|
||||
'(-q --quiet)'{-q,--quiet}'[Suppress status output]'
|
||||
'(-s --skip)'{-s,--skip}'[Skip files that already exist]'
|
||||
)
|
||||
}
|
||||
|
||||
__rails_setup_generators_options() {
|
||||
local -a runtime_options
|
||||
__rails_setup_runtime_options
|
||||
|
||||
generators_options=(
|
||||
$runtime_options
|
||||
--skip-namespace'[Skip namespace (affects only isolated applications)]'
|
||||
--old-style-hash"[Force using old style hash (:foo => 'bar') on Ruby >= 1.9]"
|
||||
)
|
||||
}
|
||||
|
||||
__rails_setup_model_generators_options() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
model_generators_options=(
|
||||
$generators_options
|
||||
'(-o --orm)'{-o,--orm=}'[Orm to be invoked]:orm'
|
||||
)
|
||||
}
|
||||
|
||||
__rails_setup_resource_generators_options() {
|
||||
local -a model_generators_options
|
||||
__rails_setup_model_generators_options
|
||||
|
||||
resource_generators_options=(
|
||||
$model_generators_options
|
||||
--force-plural'[Forces the use of a plural ModelName]'
|
||||
--resource-route'[Indicates when to generate resource route]: :__rails_boolean'
|
||||
)
|
||||
}
|
||||
|
||||
__rails_boolean() {
|
||||
_values 'boolean' 'true' 'false'
|
||||
}
|
||||
|
||||
__rails_migration_fields() {
|
||||
if compset -P '*:*:'; then
|
||||
_values 'index' 'index' 'uniq'
|
||||
else
|
||||
if compset -P '*:'; then
|
||||
_values -s ':' 'type' 'string' 'text' 'integer' 'float' 'decimal' 'datetime' 'timestamp' 'time' 'date' 'binary' 'boolean' 'references'
|
||||
else
|
||||
_guard '[[:alnum:]_]#' 'field'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_rails_generate() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
if (( CURRENT > 2 )); then
|
||||
(( CURRENT-- ))
|
||||
shift words
|
||||
_call_function - "_rails_generate_${words[1]}" || _rails_generate_default
|
||||
else
|
||||
__rails_generate_commands
|
||||
fi
|
||||
}
|
||||
|
||||
_rails_g() {
|
||||
_rails_generate
|
||||
}
|
||||
|
||||
__rails_generate_commands() {
|
||||
local context curcontext="$curcontext" update_policy
|
||||
|
||||
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
|
||||
if [ -z "$update_policy" ]; then
|
||||
zstyle ":completion:${curcontext}:" cache-policy _rails_generate_commands_caching_policy
|
||||
fi
|
||||
|
||||
local application_directory
|
||||
__rails_setup_application_directory
|
||||
local cache_name
|
||||
cache_name="rails/${application_directory##*/}/all_generators"
|
||||
if ! _retrieve_cache ${cache_name}; then
|
||||
local -a all_generators
|
||||
all_generators=($(_call_program rails_generators rails generate 2> /dev/null | awk '/^ [a-zA-Z_]+/{ print $1 }'))
|
||||
_store_cache ${cache_name} all_generators
|
||||
fi
|
||||
|
||||
local -a rails_generators
|
||||
rails_generators=(${all_generators:#*:*})
|
||||
_describe -t rails_generators 'rails generator' rails_generators
|
||||
|
||||
local -a -U namespaces
|
||||
local namespace
|
||||
local -a generators
|
||||
namespaces=(${(R)${(M)all_generators:#*:*}%:*})
|
||||
for namespace in $namespaces; do
|
||||
generators=(${${(M)all_generators:#${namespace}:*}/:/\\:})
|
||||
_describe -t ${namespace}_generators "${namespace/_/ } generator" generators
|
||||
done
|
||||
}
|
||||
|
||||
_rails_generate_commands_caching_policy() {
|
||||
local application_directory
|
||||
__rails_setup_application_directory
|
||||
|
||||
if [ "${application_directory}/Gemfile" -nt "$1" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local -a oldp
|
||||
oldp=( "$1"(Nmw+1) )
|
||||
(( $#oldp ))
|
||||
}
|
||||
|
||||
_rails_generate_default() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
'*:argument'
|
||||
}
|
||||
|
||||
_rails_generate_assets() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
'(-j --javascripts)'{-j,--javascripts}'[Generate JavaScripts]: :__rails_boolean' \
|
||||
'(-y --stylesheets)'{-y,--stylesheets}'[Generate Stylesheets]: :__rails_boolean' \
|
||||
'(-je --javascript-engine)'{-je,--javascript-engine=}'[Engine for JavaScripts]:javascript engine' \
|
||||
'(-se --stylesheet-engine)'{-se,--stylesheet-engine=}'[Engine for Stylesheets]:stylesheet engine' \
|
||||
': :_guard "^-*" "name"'
|
||||
}
|
||||
|
||||
_rails_generate_controller() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
'(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \
|
||||
'(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \
|
||||
--helper'[Indicates when to generate helper]: :__rails_boolean' \
|
||||
--assets'[Indicates when to generate assets]: :__rails_boolean' \
|
||||
': :_guard "^-*" "name"' \
|
||||
'*: :_guard "^-*" "action"'
|
||||
}
|
||||
|
||||
_rails_generate_generator() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
--namespace'[Namespace generator under lib/generators/name]: :__rails_boolean' \
|
||||
': :_guard "^-*" "name"'
|
||||
}
|
||||
|
||||
_rails_generate_helper() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
'(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \
|
||||
': :_guard "^-*" "name"' \
|
||||
}
|
||||
|
||||
_rails_generate_integration_test() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
--integration-tool='[Integration tool to be invoke]:integration tool' \
|
||||
': :_guard "^-*" "name"' \
|
||||
}
|
||||
|
||||
_rails_generate_jbuilder() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
': :_guard "^-*" "name"' \
|
||||
'*: :__rails_migration_fields'
|
||||
}
|
||||
|
||||
_rails_generate_mailer() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
'(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \
|
||||
'(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \
|
||||
': :_guard "^-*" "name"' \
|
||||
'*: :_guard "^-*" "method"'
|
||||
}
|
||||
|
||||
_rails_generate_migration() {
|
||||
local -a modelgenerators_options
|
||||
__rails_setup_model_generators_options
|
||||
|
||||
_arguments \
|
||||
$model_generators_options \
|
||||
': :_guard "^-*" "name"' \
|
||||
'*: :__rails_migration_fields'
|
||||
}
|
||||
|
||||
_rails_generate_model() {
|
||||
_rails_generate_migration
|
||||
}
|
||||
|
||||
_rails_generate_observer() {
|
||||
local -a model_generators_options
|
||||
__rails_setup_model_generators_options
|
||||
|
||||
_arguments \
|
||||
$model_generators_options \
|
||||
': :_guard "^-*" "name"'
|
||||
}
|
||||
|
||||
_rails_generate_performance_test() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
--performance-tool='[Performance tool to be invoked]:performance tool' \
|
||||
': :_guard "^-*" "name"' \
|
||||
}
|
||||
|
||||
_rails_generate_resource() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
local -a resource_generators_options
|
||||
__rails_setup_resource_generators_options
|
||||
|
||||
_arguments -C \
|
||||
$resource_generators_options \
|
||||
'(-c --resource-controller)'{-c,--resource-controller=}'[Resource controller to be invoked]:name' \
|
||||
'(-a --actions)'{-a,--actions=}'[Actions for the resource controller]: :->actions' \
|
||||
': :->name' \
|
||||
'*: :->fields'
|
||||
|
||||
if (( words[(I)(--actions=*|-a)] > 0 && words[(I)(--actions=*|-a)] == words[(I)-*] )); then
|
||||
state=actions
|
||||
fi
|
||||
|
||||
case "$state" in
|
||||
actions)
|
||||
_guard "[[:alnum:]_]#" "actions"
|
||||
;;
|
||||
name)
|
||||
_guard "^-*" "name"
|
||||
;;
|
||||
fields)
|
||||
__rails_migration_fields
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_rails_generate_scaffold() {
|
||||
local -a resource_generators_options
|
||||
__rails_setup_resource_generators_options
|
||||
|
||||
_arguments \
|
||||
$resource_generators_options \
|
||||
'(-y --stylesheets)'{-y,--stylesheets}'[Generate Stylesheets]: :__rails_boolean' \
|
||||
'(-se --stylesheet-engine)'{-se,--stylesheet-engine=}'[Engine for Stylesheets]:stylesheet engine' \
|
||||
'(-c --scaffold-controller)'{-c,--scaffold-controller=}'[Scaffold controller to be invoked]:name' \
|
||||
--assets'[Indicates when to generate assets]:boolean:(true false)' \
|
||||
': :_guard "^-*" "name"' \
|
||||
'*: :__rails_migration_fields'
|
||||
}
|
||||
|
||||
_rails_generate_scaffold_controller() {
|
||||
local -a model_generators_options
|
||||
__rails_setup_model_generators_options
|
||||
|
||||
_arguments \
|
||||
$model_generators_options \
|
||||
'(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \
|
||||
'(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \
|
||||
--helper'[Indicates when to generate helper]: :__rails_boolean' \
|
||||
': :_guard "^-*" "name"'
|
||||
}
|
||||
|
||||
_rails_generate_session_migration() {
|
||||
local -a model_generators_options
|
||||
__rails_setup_model_generators_options
|
||||
|
||||
_arguments \
|
||||
$model_generators_options \
|
||||
': :_guard "^-*" "name"'
|
||||
}
|
||||
|
||||
_rails_generate_task() {
|
||||
local -a generators_options
|
||||
__rails_setup_generators_options
|
||||
|
||||
_arguments \
|
||||
$generators_options \
|
||||
': :_guard "^-*" "name"' \
|
||||
'*: :_guard "^-*" "action"'
|
||||
}
|
||||
|
||||
_rails_console() {
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[Show this help message]' \
|
||||
'(-s --sandbox)'{-s,--sandbox}'[Rollback database modifications on exit]' \
|
||||
--debugger'[Enable ruby-debugging for the console]'
|
||||
}
|
||||
|
||||
_rails_c() {
|
||||
_rails_console
|
||||
}
|
||||
|
||||
_rails_server() {
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[Show this help message]' \
|
||||
'(-p --port)'{-p,--port=}'[Runs Rails on the specified port]: :_guard "[[\:digit\:]]#" "port"' \
|
||||
'(-b --binding)'{-b,--binding=}'[Binds Rails to the specified ip]:ip:_hosts' \
|
||||
'(-c --config)'{-c,--config=}'[Use custom rackup configuration file]:file:_files -g "*.ru"' \
|
||||
'(-d --daemon)'{-d,--daemon}'[Make server run as a Daemon]' \
|
||||
'(-u --debugger)'{-u,--debugger}'[Enable ruby-debugging for the server]' \
|
||||
'(-e --environment)'{-e,--environment=}'[Specifies the environment to run this server under (test/development/production)]:name:(test development production)' \
|
||||
'(-P --pid)'{-P,--pid=}'[Specifies the PID file]:pid:_files -g "*.pid"'
|
||||
}
|
||||
|
||||
_rails_s() {
|
||||
_rails_server
|
||||
}
|
||||
|
||||
_rails_dbconsole() {
|
||||
_arguments \
|
||||
'(- *)'--help'[Show this help message]' \
|
||||
'(-p --include-password)'{-p,--include-password}'[Automatically provide the password from database.yml]' \
|
||||
--mode'[Automatically put the sqlite3 database in the specified mode (html, list, line, column)]:mode:(html list line column)' \
|
||||
--header
|
||||
}
|
||||
|
||||
_rails_new() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
local _a rails_options runtime_options
|
||||
__rails_setup_rails_options
|
||||
__rails_setup_runtime_options
|
||||
|
||||
_arguments -C \
|
||||
$rails_options \
|
||||
$runtime_options \
|
||||
'(-r --ruby)'{-r,--ruby=}'[Path to the Ruby binary of your choice]:path' \
|
||||
'(-b --builder)'{-b,--builder=}'[Path to a application builder (can be a filesystem path or URL)]: :->path_or_url' \
|
||||
'(-m --template)'{-m,--template=}'[Path to an application template (can be a filesystem path or URL)]: :->path_or_url' \
|
||||
--skip-gemfile"[Don't create a Gemfile]" \
|
||||
--skip-bundle"[Don't run bundle install]" \
|
||||
'(-G --skip-git)'{-G,--skip-git}'[Skip Git ignores and keeps]' \
|
||||
'(-O --skip-active-record)'{-O,--skip-active-record}'[Skip Active Record files]' \
|
||||
'(-S --skip-sprockets)'{-S,--skip-sprockets}'[Skip Sprockets files]' \
|
||||
'(-d --database)'{-d,--database=}'[Preconfigure for selected database]:database:(mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc)' \
|
||||
'(-j --javascript)'{-j,--javascript=}'[Preconfigure for selected JavaScript library]:javascript' \
|
||||
'(-J --skip-javascript)'{-J,--skip-javascript}'[Skip JavaScript files]' \
|
||||
--dev'[Setup the application with Gemfile pointing to your Rails checkout]' \
|
||||
--edge'[Setup the application with Gemfile pointing to Rails repository]' \
|
||||
'(-T --skip-test-unit)'{-T,--skip-test-unit}'[Skip Test::Unit files]' \
|
||||
--old-style-hash"[Force using old style hash (:foo => 'bar') on Ruby >= 1.9]" \
|
||||
':app path:_directories'
|
||||
|
||||
case "$state" in
|
||||
path_or_url)
|
||||
_alternative \
|
||||
'files:path:_files -g "*.rb"' \
|
||||
'url:url:_urls'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_rails_application() {
|
||||
_rails_new
|
||||
}
|
||||
|
||||
_rails_db() {
|
||||
_rails_dbconsole
|
||||
}
|
||||
|
||||
_rails_destroy() {
|
||||
_rails_generate
|
||||
}
|
||||
|
||||
_rails_d() {
|
||||
_rails_destroy
|
||||
}
|
||||
|
||||
_rails_benchmarker() {
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[Show this help message]' \
|
||||
'(-r --runs)'{-r,--runs}'[Number of runs]: :_guard "[[\:digit\:]]#" "number"' \
|
||||
'(-o --output)'{-o,--output}'[Directory to use when writing the results]:directory:_directories' \
|
||||
'(-m --metrics)'{-m,--metrics}'[Metrics to use]: :_values -s "," "metrics" "wall_time" "memory" "objects" "gc_runs" "gc_time"' \
|
||||
'*: :_guard "^-*" "ruby code"'
|
||||
}
|
||||
|
||||
_rails_profiler() {
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[Show this help message]' \
|
||||
'(-r --runs)'{-r,--runs}'[Number of runs]: :_guard "[[\:digit\:]]#" "number"' \
|
||||
'(-o --output)'{-o,--output}'[Directory to use when writing the results]:directory:_directories' \
|
||||
'(-m --metrics)'{-m,--metrics}'[Metrics to use]: :_values -s "," "metrics" "process_time" "memory" "objects"' \
|
||||
'(-f --formats)'{-f,--formats}'[Formats to output to]: :_values -s "," "formats" "flat" "graph" "html" "call_tree" "call_stack"' \
|
||||
'*: :_guard "^-*" "ruby code"'
|
||||
}
|
||||
|
||||
_rails_plugin() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
if (( CURRENT > 2 )); then
|
||||
(( CURRENT-- ))
|
||||
shift words
|
||||
_call_function - "_rails_plugin_${words[1]}" || _nothing
|
||||
else
|
||||
__rails_plugin_commands
|
||||
fi
|
||||
}
|
||||
|
||||
__rails_plugin_commands() {
|
||||
_values 'plugin command' \
|
||||
install'[Install plugin(s) from known repositories or URLs]' \
|
||||
remove'[Uninstall plugins]' \
|
||||
new
|
||||
}
|
||||
|
||||
_rails_plugin_install() {
|
||||
_arguments \
|
||||
'(-x --externals)'{-x,--externals}'[Use svn:externals to grab the plugin. Enables plugin updates and plugin versioning]' \
|
||||
'(-o --checkout)'{-o,--checkout}'[Use svn checkout to grab the plugin. Enables updating but does not add a svn:externals entry]' \
|
||||
'(-e --export)'{-e,--export}'[Use svn export to grab the plugin. Exports the plugin, allowing you to check it into your local repository. Does not enable updates or add an svn:externals entry]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[Suppresses the output from installation. Ignored if -v is passed (rails plugin -v install ...)]' \
|
||||
'(-r --revision)'{-r,--revision=}'[Checks out the given revision from subversion or git. Ignored if subversion/git is not used]:revision' \
|
||||
'(-f --force)'{-f,--force}"[Reinstalls a plugin if it's already installed]" \
|
||||
'*:plugin:_urls'
|
||||
}
|
||||
|
||||
_rails_plugin_remove() {
|
||||
local -a plugins
|
||||
|
||||
plugins=($(_call_program rails_plugins ls -1 vendor/plugins))
|
||||
|
||||
_describe -t plugins 'plugin' plugins
|
||||
}
|
||||
|
||||
_rails_plugin_new() {
|
||||
_rails_new
|
||||
}
|
||||
|
||||
_rails_runner() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
_arguments -C \
|
||||
'(- *)'{-h,--help}'[Show this help message]' \
|
||||
'(-e --environment)'{-e,--environment=}'[Specifies the environment for the runner to operate under (test/development/production)]:name:(test development production)' \
|
||||
': :->code_or_path'
|
||||
|
||||
case "$state" in
|
||||
code_or_path)
|
||||
_alternative \
|
||||
'files:filename:_files -g "*.rb"' \
|
||||
'codes:ruby code:_guard "^-*" "ruby code"'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_rails_r() {
|
||||
_rails_runner
|
||||
}
|
||||
|
||||
_rails_test() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
_arguments -C \
|
||||
': :->path'
|
||||
|
||||
case "$state" in
|
||||
path)
|
||||
_alternative \
|
||||
'files:filename:_files -g "*.rb"'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_rails_t() {
|
||||
_rails_test
|
||||
}
|
||||
|
||||
_rails "$@"
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# rails command wrapper
|
||||
function _rails_command () {
|
||||
if [ -e "bin/stubs/rails" ]; then
|
||||
bin/stubs/rails $@
|
||||
|
|
@ -12,28 +13,31 @@ function _rails_command () {
|
|||
fi
|
||||
}
|
||||
|
||||
alias rails='_rails_command'
|
||||
compdef _rails_command=rails
|
||||
|
||||
# rake command wrapper
|
||||
function _rake_command () {
|
||||
if [ -e "bin/stubs/rake" ]; then
|
||||
bin/stubs/rake $@
|
||||
elif [ -e "bin/rake" ]; then
|
||||
bin/rake $@
|
||||
elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then
|
||||
elif type bundle &> /dev/null && [[ -e "Gemfile" || -e "gems.rb" ]]; then
|
||||
bundle exec rake $@
|
||||
else
|
||||
command rake $@
|
||||
fi
|
||||
}
|
||||
|
||||
alias rails='_rails_command'
|
||||
compdef _rails_command=rails
|
||||
|
||||
alias rake='_rake_command'
|
||||
compdef _rake_command=rake
|
||||
|
||||
# Log aliases
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias prodlog='tail -f log/production.log'
|
||||
alias testlog='tail -f log/test.log'
|
||||
|
||||
# Environment settings
|
||||
alias -g RED='RAILS_ENV=development'
|
||||
alias -g REP='RAILS_ENV=production'
|
||||
alias -g RET='RAILS_ENV=test'
|
||||
|
|
@ -43,47 +47,69 @@ alias rc='rails console'
|
|||
alias rcs='rails console --sandbox'
|
||||
alias rd='rails destroy'
|
||||
alias rdb='rails dbconsole'
|
||||
alias rdc='rails db:create'
|
||||
alias rdd='rails db:drop'
|
||||
alias rdm='rails db:migrate'
|
||||
alias rdmd='rails db:migrate:down'
|
||||
alias rdmr='rails db:migrate:redo'
|
||||
alias rdms='rails db:migrate:status'
|
||||
alias rdmtc='rails db:migrate db:test:clone'
|
||||
alias rdmu='rails db:migrate:up'
|
||||
alias rdr='rails db:rollback'
|
||||
alias rdrs='rails db:reset'
|
||||
alias rds='rails db:seed'
|
||||
alias rdsl='rails db:schema:load'
|
||||
alias rdtc='rails db:test:clone'
|
||||
alias rdtp='rails db:test:prepare'
|
||||
alias rgen='rails generate'
|
||||
alias rgm='rails generate migration'
|
||||
alias rlc='rails log:clear'
|
||||
alias rmd='rails middleware'
|
||||
alias rn='rails notes'
|
||||
alias rp='rails plugin'
|
||||
alias rr='rails routes'
|
||||
alias rrg='rails routes | grep'
|
||||
alias ru='rails runner'
|
||||
alias rs='rails server'
|
||||
alias rsb='rails server --bind'
|
||||
alias rsd='rails server --debugger'
|
||||
alias rsp='rails server --port'
|
||||
alias rsb='rails server --bind'
|
||||
alias rsts='rails stats'
|
||||
alias rt='rails test'
|
||||
alias ru='rails runner'
|
||||
|
||||
# Foreman aliases
|
||||
alias fmns='foreman start'
|
||||
|
||||
# Rake aliases
|
||||
alias rdm='rake db:migrate'
|
||||
alias rdmr='rake db:migrate:redo'
|
||||
alias rdmd='rake db:migrate:down'
|
||||
alias rdms='rake db:migrate:status'
|
||||
alias rdmu='rake db:migrate:up'
|
||||
alias rdr='rake db:rollback'
|
||||
alias rdc='rake db:create'
|
||||
alias rds='rake db:seed'
|
||||
alias rdd='rake db:drop'
|
||||
alias rdrs='rake db:reset'
|
||||
alias rdtc='rake db:test:clone'
|
||||
alias rdtp='rake db:test:prepare'
|
||||
alias rdmtc='rake db:migrate db:test:clone'
|
||||
alias rdsl='rake db:schema:load'
|
||||
alias rlc='rake log:clear'
|
||||
alias rn='rake notes'
|
||||
alias rt='rake test'
|
||||
alias rmd='rake middleware'
|
||||
alias rsts='rake stats'
|
||||
alias rkdc='rake db:create'
|
||||
alias rkdd='rake db:drop'
|
||||
alias rkdm='rake db:migrate'
|
||||
alias rkdmd='rake db:migrate:down'
|
||||
alias rkdmr='rake db:migrate:redo'
|
||||
alias rkdms='rake db:migrate:status'
|
||||
alias rkdmtc='rake db:migrate db:test:clone'
|
||||
alias rkdmu='rake db:migrate:up'
|
||||
alias rkdr='rake db:rollback'
|
||||
alias rkdrs='rake db:reset'
|
||||
alias rkds='rake db:seed'
|
||||
alias rkdsl='rake db:schema:load'
|
||||
alias rkdtc='rake db:test:clone'
|
||||
alias rkdtp='rake db:test:prepare'
|
||||
alias rklc='rake log:clear'
|
||||
alias rkmd='rake middleware'
|
||||
alias rkn='rake notes'
|
||||
alias rksts='rake stats'
|
||||
alias rkt='rake test'
|
||||
|
||||
# legacy stuff
|
||||
alias sstat='thin --stats "/thin/stats" start'
|
||||
alias sg='ruby script/generate'
|
||||
alias sc='ruby script/console'
|
||||
alias sd='ruby script/destroy'
|
||||
alias sd='ruby script/server --debugger'
|
||||
alias sg='ruby script/generate'
|
||||
alias sp='ruby script/plugin'
|
||||
alias sr='ruby script/runner'
|
||||
alias ssp='ruby script/spec'
|
||||
alias sc='ruby script/console'
|
||||
alias sd='ruby script/server --debugger'
|
||||
alias sstat='thin --stats "/thin/stats" start'
|
||||
|
||||
function remote_console() {
|
||||
/usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
|
||||
|
|
|
|||
|
|
@ -2,12 +2,6 @@ if (( ! $+commands[rbw] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
|
||||
# Add completions folder in $ZSH_CACHE_DIR
|
||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `rbw`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
|
||||
|
|
|
|||
|
|
@ -2,11 +2,6 @@ if ! (( $+commands[rustup] && $+commands[cargo] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# Add completions folder in $ZSH_CACHE_DIR
|
||||
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
|
||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `cargo`. Otherwise, compinit will have already done that
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
print ${(%):-'%F{yellow}The `rustup` plugin is deprecated and has been moved to the `rust` plugin.'}
|
||||
print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
|
||||
|
||||
# TODO: 2021-12-28: remove this block
|
||||
# Handle $0 according to the standard:
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
# Remove old generated completion file
|
||||
command rm -f "${0:A:h}/_rustup" "$ZSH_CACHE_DIR/rustup_version"
|
||||
|
||||
(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {
|
||||
fpath=("$ZSH/plugins/rust" $fpath)
|
||||
source "$ZSH/plugins/rust/rust.plugin.zsh"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ plugins=(... rvm)
|
|||
| `rb26` | `rvm use ruby-2.6` |
|
||||
| `rb27` | `rvm use ruby-2.7` |
|
||||
| `rb30` | `rvm use ruby-3.0` |
|
||||
| `rb31` | `rvm use ruby-3.1` |
|
||||
| `rvm-update` | `rvm get head` |
|
||||
| `gems` | `gem list` |
|
||||
| `rvms` | `rvm gemset` |
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ rubies=(
|
|||
26 'ruby-2.6'
|
||||
27 'ruby-2.7'
|
||||
30 'ruby-3.0'
|
||||
31 'ruby-3.1'
|
||||
)
|
||||
|
||||
for v in ${(k)rubies}; do
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ plugins=(... sprunge)
|
|||
| `echo data \| sprunge` | Any piped data will be uploaded |
|
||||
|
||||
Once sprunge has processed the input it will give you a unique HTTP address:
|
||||
```
|
||||
|
||||
```console
|
||||
$ sprunge "hello"
|
||||
http://sprunge.us/XxjnKz
|
||||
```
|
||||
|
|
@ -30,3 +31,8 @@ http://sprunge.us/XxjnKz
|
|||
- Argument precedence goes as follows: stdin > piped input > text strings.
|
||||
- If a filename is misspelled or doesn't have the necessary path description, it will NOT
|
||||
generate an error, but instead treat it as a text string.
|
||||
|
||||
## Credits
|
||||
|
||||
- Original code: [shellperson.net](https://web.archive.org/web/20190910065842/https://www.shellperson.net/sprunge-pastebin-script/).
|
||||
- Adapted by: Matt Parnell (@ilikenwf).
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
# Contributed and SLIGHTLY modded by Matt Parnell/ilikenwf <parwok -at- gmail>
|
||||
# Created by the blogger at the URL below...I don't know where to find his/her name
|
||||
# Original found at https://www.shellperson.net/sprunge-pastebin-script/
|
||||
|
||||
sprunge() {
|
||||
if [[ "$1" = --help ]]; then
|
||||
fmt -s >&2 << EOF
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ To use it, add `svn-fast-info` to the plugins array in your zshrc file:
|
|||
plugins=(... svn-fast-info)
|
||||
```
|
||||
|
||||
It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase
|
||||
It's faster because it has an efficient use of svn (single svn call) which saves a lot on a huge codebase.
|
||||
It displays the current status of the local files (added, deleted, modified, replaced, or else...)
|
||||
|
||||
Use `svn_prompt_info` method to display the svn repository status in your theme.
|
||||
Use `svn_prompt_info` method to display the svn repository status in your theme.
|
||||
|
||||
## Functions
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ plugins=(... terraform)
|
|||
| `tfd` | `terraform destroy` |
|
||||
| `tff` | `terraform fmt` |
|
||||
| `tfi` | `terraform init` |
|
||||
| `tfo` | `terraform output` |
|
||||
| `tfp` | `terraform plan` |
|
||||
| `tfv` | `terraform validate` |
|
||||
|
||||
|
|
|
|||
|
|
@ -13,5 +13,6 @@ alias tfa='terraform apply'
|
|||
alias tfd='terraform destroy'
|
||||
alias tff='terraform fmt'
|
||||
alias tfi='terraform init'
|
||||
alias tfo='terraform output'
|
||||
alias tfp='terraform plan'
|
||||
alias tfv='terraform validate'
|
||||
|
|
|
|||
19
plugins/toolbox/README.md
Normal file
19
plugins/toolbox/README.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# toolbox plugin
|
||||
|
||||
Plugin for [toolbox](https://containertoolbx.org), a tool to use containerized CLI environments.
|
||||
|
||||
To use it, add `toolbox` to your plugins array in your `.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... toolbox)
|
||||
```
|
||||
|
||||
## Prompt function
|
||||
|
||||
This plugins adds `toolbox_prompt_info()` function. Using it in your prompt, it will show the toolbox indicator ⬢ (if you are running in a toolbox container), and nothing if not.
|
||||
|
||||
You can use it by adding `$(toolbox_prompt_info)` to your `PROMPT` or `RPROMPT` variable:
|
||||
|
||||
```zsh
|
||||
RPROMPT='$(toolbox_prompt_info)'
|
||||
```
|
||||
3
plugins/toolbox/kubectx.plugin.zsh
Normal file
3
plugins/toolbox/kubectx.plugin.zsh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function toolbox_prompt_info() {
|
||||
[[ -f /run/.toolboxenv ]] && echo "⬢"
|
||||
}
|
||||
|
|
@ -3,11 +3,6 @@ if (( ! $+commands[volta] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
|
||||
# Add completions folder in $ZSH_CACHE_DIR
|
||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `deno`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_volta" ]]; then
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ Zsh plugins may look scary, as they seem to have some "architecture". In fact, w
|
|||
1. It has its directory added to `fpath`
|
||||
2. It has any first `*.plugin.zsh` file sourced
|
||||
|
||||
That's it. When one contributes to Oh-My-Zsh or creates a plugin for any plugin manager, he only needs to account for this.
|
||||
That's it. When one contributes to Oh-My-Zsh or creates a plugin for any plugin manager, they only need to account for this.
|
||||
The same with doing any non-typical Zsh Navigation Tools installation.
|
||||
|
||||
## More
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue