Merge branch 'ohmyzsh:master' into master

This commit is contained in:
Vigneshwar Ravichandar 2021-09-10 15:12:39 +05:30 committed by GitHub
commit be561bc027
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 901 additions and 1909 deletions

View file

@ -37,19 +37,63 @@ function _omz {
changelog) local -a refs
refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
_describe 'command' refs ;;
plugin) subcmds=('info:Get plugin information' 'list:List plugins')
plugin) subcmds=(
'disable:Disable plugin(s)'
'enable:Enable plugin(s)'
'info:Get plugin information'
'list:List plugins'
'load:Load plugin(s)'
)
_describe 'command' subcmds ;;
pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches')
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
_describe 'command' subcmds ;;
theme) subcmds=('use:Load a theme' 'list:List themes')
theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
_describe 'command' subcmds ;;
esac
elif (( CURRENT == 4 )); then
case "$words[2]::$words[3]" in
plugin::info) compadd "$ZSH"/plugins/*/README.md(.N:h:t) \
"$ZSH_CUSTOM"/plugins/*/README.md(.N:h:t) ;;
theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \
"$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;;
case "${words[2]}::${words[3]}" in
plugin::(disable|enable|load))
local -aU valid_plugins
if [[ "${words[3]}" = disable ]]; then
# if command is "disable", only offer already enabled plugins
valid_plugins=($plugins)
else
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t))
# if command is "enable", remove already enabled plugins
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi
_describe 'plugin' valid_plugins ;;
plugin::info)
local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t))
_describe 'plugin' plugins ;;
theme::(set|use))
local -aU themes=("$ZSH"/themes/*.zsh-theme(.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
_describe 'theme' themes ;;
esac
elif (( CURRENT > 4 )); then
case "${words[2]}::${words[3]}" in
plugin::(enable|disable|load))
local -aU valid_plugins
if [[ "${words[3]}" = disable ]]; then
# if command is "disable", only offer already enabled plugins
valid_plugins=($plugins)
else
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t))
# if command is "enable", remove already enabled plugins
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi
# Remove plugins already passed as arguments
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
# has a space after them. This is to avoid removing plugins partially passed, which makes
# the completion not add a space after the completed plugin.
local -a args=(${words[4,$(( CURRENT - 1))]})
valid_plugins=(${valid_plugins:|args})
_describe 'plugin' valid_plugins ;;
esac
fi
@ -106,7 +150,7 @@ function _omz::log {
## User-facing commands
function _omz::help {
cat <<EOF
cat >&2 <<EOF
Usage: omz <command> [options]
Available commands:
@ -127,7 +171,7 @@ function _omz::changelog {
if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \
! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \
! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then
cat <<EOF
cat >&2 <<EOF
Usage: omz changelog [version]
NOTE: <version> must be a valid branch, tag or commit.
@ -140,13 +184,16 @@ EOF
function _omz::plugin {
(( $# > 0 && $+functions[_omz::plugin::$1] )) || {
cat <<EOF
cat >&2 <<EOF
Usage: omz plugin <command> [options]
Available commands:
info <plugin> Get information of a plugin
list List all available Oh My Zsh plugins
disable <plugin> Disable plugin(s)
enable <plugin> Enable plugin(s)
info <plugin> Get information of a plugin
list List all available Oh My Zsh plugins
load <plugin> Load plugin(s)
EOF
return 1
@ -158,6 +205,170 @@ EOF
_omz::plugin::$command "$@"
}
function _omz::plugin::disable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin disable <plugin> [...]"
return 1
fi
# Check that plugin is in $plugins
local -a dis_plugins=()
for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
_omz::log warn "plugin '$plugin' is not enabled."
continue
fi
dis_plugins+=("$plugin")
done
# Exit if there are no enabled plugins to disable
if [[ ${#dis_plugins} -eq 0 ]]; then
return 1
fi
# Remove plugins substitution awk script
local awk_subst_plugins="\
gsub(/\s+(${(j:|:)dis_plugins})/, \"\") # with spaces before
gsub(/(${(j:|:)dis_plugins})\s+/, \"\") # with spaces after
gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin)
"
# Disable plugins awk script
local awk_script="
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
/^\s*plugins=\([^#]+\).*\$/ {
$awk_subst_plugins
print \$0
next
}
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
/^\s*plugins=\(/ {
multi=1
$awk_subst_plugins
print \$0
next
}
# if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag
multi == 1 && /^[^#]*\)/ {
multi=0
$awk_subst_plugins
print \$0
next
}
multi == 1 && length(\$0) > 0 {
$awk_subst_plugins
if (length(\$0) > 0) print \$0
next
}
{ print \$0 }
"
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
local ret=$?
_omz::log error "error disabling plugins."
return $ret
}
# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
return 1
fi
# Restart the zsh session if there were no errors
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}."
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
}
function _omz::plugin::enable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin enable <plugin> [...]"
return 1
fi
# Check that plugin is not in $plugins
local -a add_plugins=()
for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
_omz::log warn "plugin '$plugin' is already enabled."
continue
fi
add_plugins+=("$plugin")
done
# Exit if there are no plugins to enable
if [[ ${#add_plugins} -eq 0 ]]; then
return 1
fi
# Enable plugins awk script
local awk_script="
# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line
/^\s*plugins=\([^#]+\).*\$/ {
sub(/\)/, \" $add_plugins&\")
print \$0
next
}
# if plugins=() is in multiline form, enable multi flag
/^\s*plugins=\(/ {
multi=1
}
# if multi flag is enabled and we find a valid closing parenthesis,
# add new plugins and disable multi flag
multi == 1 && /^[^#]*\)/ {
multi=0
sub(/\)/, \" $add_plugins&\")
print \$0
next
}
{ print \$0 }
"
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
local ret=$?
_omz::log error "error enabling plugins."
return $ret
}
# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
return 1
fi
# Restart the zsh session if there were no errors
_omz::log info "plugins enabled: ${(j:, :)add_plugins}."
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
}
function _omz::plugin::info {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin info <plugin>"
@ -194,20 +405,70 @@ function _omz::plugin::list {
if (( ${#custom_plugins} )); then
print -P "%U%BCustom plugins%b%u:"
print -l ${(q-)custom_plugins} | column
print -l ${(q-)custom_plugins} | column -x
fi
if (( ${#builtin_plugins} )); then
(( ${#custom_plugins} )) && echo # add a line of separation
print -P "%U%BBuilt-in plugins%b%u:"
print -l ${(q-)builtin_plugins} | column
print -l ${(q-)builtin_plugins} | column -x
fi
}
function _omz::plugin::load {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin load <plugin> [...]"
return 1
fi
local plugins=("$@")
local plugin base has_completion=0
for plugin in $plugins; do
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
base="$ZSH_CUSTOM/plugins/$plugin"
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
base="$ZSH/plugins/$plugin"
else
_omz::log warn "plugin '$plugin' not found"
continue
fi
# Check if its a valid plugin
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
_omz::log warn "'$plugin' is not a valid plugin"
continue
# It it is a valid plugin, add its directory to $fpath unless it is already there
elif (( ! ${fpath[(Ie)$base]} )); then
fpath=("$base" $fpath)
fi
# Check if it has completion to reload compinit
if [[ -f "$base/_$plugin" ]]; then
has_completion=1
fi
# Load the plugin
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
source "$base/$plugin.plugin.zsh"
fi
done
# If we have completion, we need to reload the completion
# We pass -D to avoid generating a new dump file, which would overwrite our
# current one for the next session (and we don't want that because we're not
# actually enabling the plugins for the next session).
# Note that we still have to pass -d "$_comp_dumpfile", so that compinit
# doesn't use the default zcompdump location (${ZDOTDIR:-$HOME}/.zcompdump).
if (( has_completion )); then
compinit -D -d "$_comp_dumpfile"
fi
}
function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
cat <<EOF
cat >&2 <<EOF
Usage: omz pr <command> [options]
Available commands:
@ -339,13 +600,14 @@ function _omz::pr::test {
function _omz::theme {
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
cat <<EOF
cat >&2 <<EOF
Usage: omz theme <command> [options]
Available commands:
list List all available Oh My Zsh themes
use <theme> Load an Oh My Zsh theme
set <theme> Set a theme in your .zshrc file
use <theme> Load a theme
EOF
return 1
@ -370,17 +632,84 @@ function _omz::theme::list {
if (( ${#custom_themes} )); then
print -P "%U%BCustom themes%b%u:"
print -l ${(q-)custom_themes} | column
print -l ${(q-)custom_themes} | column -x
fi
if (( ${#builtin_themes} )); then
(( ${#custom_themes} )) && echo # add a line of separation
print -P "%U%BBuilt-in themes%b%u:"
print -l ${(q-)builtin_themes} | column
print -l ${(q-)builtin_themes} | column -x
fi
}
function _omz::theme::set {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme set <theme>"
return 1
fi
# Check that theme exists
if [[ ! -f "$ZSH_CUSTOM/$1.zsh-theme" ]] \
&& [[ ! -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]] \
&& [[ ! -f "$ZSH/themes/$1.zsh-theme" ]]; then
_omz::log error "%B$1%b theme not found"
return 1
fi
# Enable theme in .zshrc
local awk_script='
!set && /^\s*ZSH_THEME=[^#]+.*$/ {
set=1
sub(/^\s*ZSH_THEME=[^#]+.*$/, "ZSH_THEME=\"'$1'\" # set by `omz`")
print $0
next
}
{ print $0 }
END {
# If no ZSH_THEME= line was found, return an error
if (!set) exit 1
}
'
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
|| {
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist
cat <<EOF
ZSH_THEME="$1" # set by \`omz\`
EOF
cat ~/.zshrc
} > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
local ret=$?
_omz::log error "error setting theme."
return $ret
}
# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
return 1
fi
# Restart the zsh session if there were no errors
_omz::log info "'$1' theme set correctly."
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
}
function _omz::theme::use {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme use <theme>"
@ -395,7 +724,7 @@ function _omz::theme::use {
elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
source "$ZSH/themes/$1.zsh-theme"
else
_omz::log error "theme '$1' not found"
_omz::log error "%B$1%b theme not found"
return 1
fi
}

View file

@ -76,7 +76,7 @@ function detect-clipboard() {
function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; }
function clippaste() { win32yank -o; }
elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then
function clipcopy() { termux-clipboard-set "${1:-/dev/stdin}"; }
function clipcopy() { termux-clipboard-set < "${1:-/dev/stdin}"; }
function clippaste() { termux-clipboard-get; }
elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then
function clipcopy() { tmux load-buffer "${1:--}"; }

View file

@ -13,10 +13,6 @@ function upgrade_oh_my_zsh() {
omz update
}
function takedir() {
mkdir -p $@ && cd ${@:$#}
}
function open_command() {
local open_cmd
@ -37,27 +33,35 @@ function open_command() {
${=open_cmd} "$@" &>/dev/null
}
# take functions
# mkcd is equivalent to takedir
function mkcd takedir() {
mkdir -p $@ && cd ${@:$#}
}
function takeurl() {
data=$(mktemp)
curl -L $1 > $data
tar xf $data
thedir=$(tar tf $data | head -1)
rm $data
cd $thedir
local data thedir
data="$(mktemp)"
curl -L "$1" > "$data"
tar xf "$data"
thedir="$(tar tf "$data" | head -1)"
rm "$data"
cd "$thedir"
}
function takegit() {
git clone $1
cd $(basename ${1%%.git})
git clone "$1"
cd "$(basename ${1%%.git})"
}
function take() {
if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then
takeurl $1
takeurl "$1"
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
takegit $1
takegit "$1"
else
takedir $1
takedir "$@"
fi
}

View file

@ -5,7 +5,7 @@ This plugin provides completion support for [`ag`](https://github.com/ggreer/the
To use it, add ag to the plugins array in your zshrc file.
```zsh
plugins=(... aws)
plugins=(... ag)
```
## INSTALLATION NOTES

View file

@ -10,6 +10,7 @@ autojump_paths=(
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
)
for file in $autojump_paths; do

1
plugins/cargo/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
_cargo

View file

@ -1,407 +0,0 @@
#compdef cargo
autoload -U regexp-replace
_cargo() {
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
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]'
)
# 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'
# 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'
)
parallel=(
'(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
)
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]"
)
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'
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'
;;
build|b)
_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]' \
;;
check|c)
_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]' \
;;
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]'
;;
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]' \
;;
fetch)
_arguments -s -S $common $triple $manifest
;;
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]'
;;
generate-lockfile)
_arguments -s -S $common $manifest
;;
git-checkout)
_arguments -s -S $common \
'--reference=:reference' \
'--url=:url:_urls'
;;
help)
_cargo_cmds
;;
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'
;;
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"'
;;
locate-project)
_arguments -s -S $common $manifest
;;
login)
_arguments -s -S $common $registry \
'*: :_guard "^-*" "token"'
;;
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)'
;;
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]'
;;
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"'
;;
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]"
;;
pkgid)
_arguments -s -S $common $manifest \
'(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
'*: :_guard "^-*" "spec"'
;;
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]'
;;
read-manifest)
_arguments -s -S $common $manifest
;;
run|r)
_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'
;;
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-'
;;
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-'
;;
search)
_arguments -s -S $common $registry \
'--index=[specify registry index]:index' \
'--limit=[limit the number of results]:results [10]' \
'*: :_guard "^-*" "query"'
;;
test|t)
_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_unstable_flags() {
local flags
flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
_describe -t flags 'unstable flag' flags
}
_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
_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
_cargo_names_from_array() {
# strip json from the path
local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
if [[ -z $manifest ]]; then
return 0
fi
local last_line
local -a names;
local in_block=false
local block_name=$1
names=()
while read -r line; do
if [[ $last_line == "[[$block_name]]" ]]; then
in_block=true
else
if [[ $last_line =~ '\s*\[\[.*' ]]; then
in_block=false
fi
fi
if [[ $in_block == true ]]; then
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
}
#Gets the test names from the manifest file
_cargo_test_names() {
_cargo_names_from_array "test"
}
#Gets the bench names from the manifest file
_cargo_benchmark_names() {
_cargo_names_from_array "bench"
}
_cargo

View file

@ -0,0 +1,11 @@
# COMPLETION FUNCTION
if (( $+commands[rustup] && $+commands[cargo] )); then
if [[ ! -f $ZSH_CACHE_DIR/cargo_version ]] \
|| [[ "$(cargo --version)" != "$(< "$ZSH_CACHE_DIR/cargo_version")" ]] \
|| [[ ! -f $ZSH/plugins/cargo/_cargo ]]; then
rustup completions zsh cargo > $ZSH/plugins/cargo/_cargo
cargo --version > $ZSH_CACHE_DIR/cargo_version
fi
autoload -Uz _cargo
_comps[cargo]=_cargo
fi

View file

@ -37,7 +37,7 @@ _homebrew-installed() {
}
_chruby-from-homebrew-installed() {
[ -r _brew_prefix ] &> /dev/null
[ -r $_brew_prefix ] &> /dev/null
}
_ruby-build_installed() {

View file

@ -1,26 +0,0 @@
# 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.

View file

@ -1,4 +0,0 @@
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
plugins/colemak/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.less

View file

@ -19,4 +19,15 @@ bindkey -a 'N' vi-join
bindkey -a 'j' vi-forward-word-end
bindkey -a 'J' vi-forward-blank-word-end
lesskey $ZSH/plugins/colemak/colemak-less
# New less versions will read this file directly
export LESSKEYIN="${0:h:A}/colemak-less"
# Only run lesskey if less version is older than v582
less_ver=$(less --version | awk '{print $2;exit}')
autoload -Uz is-at-least
if ! is-at-least 582 $less_ver; then
# Old less versions will read this transformed file
export LESSKEY="${0:h:A}/.less"
lesskey -o "$LESSKEY" "$LESSKEYIN" 2>/dev/null
fi
unset less_ver

View file

@ -25,7 +25,7 @@ The enabled options for rsync are:
* `-hhh`: outputs numbers in human-readable format, in units of 1024 (K, M, G, T).
* `--backup-dir=/tmp/rsync`: move backup copies to "/tmp/rsync".
* `--backup-dir="/tmp/rsync-$USERNAME"`: move backup copies to "/tmp/rsync-$USERNAME".
* `-e /dev/null`: only work on local files (disable remote shells).

View file

@ -1,4 +1,4 @@
cpv() {
rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@"
rsync -pogbr -hhh --backup-dir="/tmp/rsync-${USERNAME}" -e /dev/null --progress "$@"
}
compdef _files cpv

View file

@ -17,6 +17,9 @@ plugins=(... dirhistory)
| <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 |
NOTE: some terminals might override the ALT+Arrows key bindings (Windows Terminal, for example).
If these don't work check your terminal settings and change them to a different keyboard shortcut.
## 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.

View file

@ -21,6 +21,8 @@ plugins=(... extract)
| `apk` | Android app file |
| `aar` | Android library file |
| `bz2` | Bzip2 file |
| `cab` | Microsoft cabinet archive |
| `cpio` | Cpio archive |
| `deb` | Debian package |
| `ear` | Enterprise Application aRchive |
| `gz` | Gzip file |

View file

@ -3,5 +3,5 @@
_arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|ear|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)(-.)'" \
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|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

View file

@ -1,82 +1,85 @@
alias x=extract
extract() {
local remove_archive
local success
local extract_dir
setopt localoptions noautopushd
if (( $# == 0 )); then
cat <<-'EOF' >&2
Usage: extract [-option] [file ...]
if (( $# == 0 )); then
cat >&2 <<'EOF'
Usage: extract [-option] [file ...]
Options:
-r, --remove Remove archive after unpacking.
EOF
fi
Options:
-r, --remove Remove archive after unpacking.
EOF
fi
remove_archive=1
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
remove_archive=0
shift
fi
local remove_archive=1
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
remove_archive=0
shift
fi
while (( $# > 0 )); do
if [[ ! -f "$1" ]]; then
echo "extract: '$1' is not a valid file" >&2
shift
continue
fi
local pwd="$PWD"
while (( $# > 0 )); do
if [[ ! -f "$1" ]]; then
echo "extract: '$1' is not a valid file" >&2
shift
continue
fi
success=0
extract_dir="${1:t:r}"
case "${1:l}" in
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
(*.tar.xz|*.txz)
tar --xz --help &> /dev/null \
&& tar --xz -xvf "$1" \
|| xzcat "$1" | tar xvf - ;;
(*.tar.zma|*.tlz)
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" ;;
(*.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|*.ear|*.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"
mkdir -p "$extract_dir/data"
cd "$extract_dir"; ar vx "../${1}" > /dev/null
cd control; tar xzvf ../control.tar.gz
cd ../data; extract ../data.tar.*
cd ..; rm *.tar.* debian-binary
cd ..
;;
(*.zst) unzstd "$1" ;;
(*)
echo "extract: '$1' cannot be extracted" >&2
success=1
;;
esac
local success=0
local extract_dir="${1:t:r}"
local file="$1" full_path="${1:A}"
case "${file:l}" in
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$file" | tar xv } || tar zxvf "$file" ;;
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$file" ;;
(*.tar.xz|*.txz)
tar --xz --help &> /dev/null \
&& tar --xz -xvf "$file" \
|| xzcat "$file" | tar xvf - ;;
(*.tar.zma|*.tlz)
tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$file" \
|| lzcat "$file" | tar xvf - ;;
(*.tar.zst|*.tzst)
tar --zstd --help &> /dev/null \
&& tar --zstd -xvf "$file" \
|| zstdcat "$file" | tar xvf - ;;
(*.tar) tar xvf "$file" ;;
(*.tar.lz) (( $+commands[lzip] )) && tar xvf "$file" ;;
(*.tar.lz4) lz4 -c -d "$file" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$file" ;;
(*.gz) (( $+commands[pigz] )) && pigz -dk "$file" || gunzip -k "$file" ;;
(*.bz2) bunzip2 "$file" ;;
(*.xz) unxz "$file" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$file" ;;
(*.lz4) lz4 -d "$file" ;;
(*.lzma) unlzma "$file" ;;
(*.z) uncompress "$file" ;;
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$file" -d "$extract_dir" ;;
(*.rar) unrar x -ad "$file" ;;
(*.rpm)
command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \
&& rpm2cpio "$full_path" | cpio --quiet -id ;;
(*.7z) 7za x "$file" ;;
(*.deb)
command mkdir -p "$extract_dir/control" "$extract_dir/data"
builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null
builtin cd -q control; extract ../control.tar.*
builtin cd -q ../data; extract ../data.tar.*
builtin cd -q ..; command rm *.tar.* debian-binary ;;
(*.zst) unzstd "$file" ;;
(*.cab) cabextract -d "$extract_dir" "$file" ;;
(*.cpio) cpio -idmvF "$file" ;;
(*)
echo "extract: '$file' cannot be extracted" >&2
success=1 ;;
esac
(( success = $success > 0 ? $success : $? ))
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
shift
done
(( success = success > 0 ? success : $? ))
(( success == 0 && remove_archive == 0 )) && rm "$full_path"
shift
# Go back to original working directory in case we ran cd previously
builtin cd -q "$pwd"
done
}

View file

@ -1 +0,0 @@
The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead.

View file

@ -1,3 +0,0 @@
print -P "%F{yellow}The 'fedora' plugin is deprecated. Use the '%Udnf%u' plugin instead.%f"
source "$ZSH/plugins/dnf/dnf.plugin.zsh"

View file

@ -29,14 +29,10 @@ alias unheap='frontend unheap'
alias vuejs='frontend vuejs'
function _frontend_fallback() {
local url
if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then
url="https://duckduckgo.com/?sites=$1&q="
else
url="https://google.com/search?as_sitesearch=$1&as_q="
fi
echo "$url"
case "$FRONTEND_SEARCH_FALLBACK" in
duckduckgo) echo "https://duckduckgo.com/?sites=$1&q=" ;;
*) echo "https://google.com/search?as_sitesearch=$1&as_q=" ;;
esac
}
function frontend() {
@ -51,7 +47,7 @@ function frontend() {
bootsnipp 'https://bootsnipp.com/search?q='
bundlephobia 'https://bundlephobia.com/result?p='
caniuse 'https://caniuse.com/#search='
codepen 'https://codepen.io/search?q='
codepen 'https://codepen.io/search/pens?q='
compassdoc 'http://compass-style.org/search?q='
cssflow 'http://www.cssflow.com/search?q='
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'

View file

@ -7,6 +7,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
search_locations=(
"$HOME/google-cloud-sdk"
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/usr/share/google-cloud-sdk"
"/snap/google-cloud-sdk/current"
"/usr/lib64/google-cloud-sdk/"

View file

@ -11,8 +11,9 @@ function git-fetch-all {
return 0
fi
# Do nothing if auto-fetch disabled
if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; then
# Do nothing if auto-fetch is disabled or don't have permissions
if [[ ! -w "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]] ||
[[ -f "$gitdir/FETCH_LOG" && ! -w "$gitdir/FETCH_LOG" ]]; then
return 0
fi
@ -24,8 +25,9 @@ function git-fetch-all {
fi
# Fetch all remotes (avoid ssh passphrase prompt)
date -R &>! "$gitdir/FETCH_LOG"
GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
command git fetch --all 2>/dev/null &>! "$gitdir/FETCH_LOG"
command git fetch --all 2>/dev/null &>> "$gitdir/FETCH_LOG"
) &|
}

View file

@ -23,7 +23,7 @@ plugins=(... git)
| gb | git branch |
| gba | git branch -a |
| gbd | git branch -d |
| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d |
| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| xargs git branch -d 2>/dev/null |
| gbD | git branch -D |
| gbl | git blame -b -w |
| gbnm | git branch --no-merged |
@ -49,8 +49,8 @@ plugins=(... git)
| gcl | git clone --recurse-submodules |
| gclean | git clean -id |
| gpristine | git reset --hard && git clean -dffx |
| gcm | git checkout $(git_main_branch) |
| gcd | git checkout develop |
| gcm | git checkout $(git_main_branch) |
| gcd | git checkout $(git_develop_branch) |
| gcmsg | git commit -m |
| gco | git checkout |
| gcor | git checkout --recurse-submodules |
@ -66,6 +66,7 @@ plugins=(... git)
| gds | git diff --staged |
| gdt | git diff-tree --no-commit-id --name-only -r |
| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)&ast;.lock" |
| gdu | git diff @{u} |
| gdv | git diff -w $@ \| view - |
| gdw | git diff --word-diff |
| gf | git fetch |
@ -88,7 +89,7 @@ plugins=(... git)
| ghh | git help |
| gignore | git update-index --assume-unchanged |
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
| gk | gitk --all --branches |
| gke | gitk --all $(git log -g --pretty=%h) |
| gl | git pull |
@ -98,19 +99,19 @@ plugins=(... git)
| glgga | git log --graph --decorate --all |
| glgm | git log --graph --max-count=10 |
| glo | git log --oneline --decorate |
| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' |
| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat |
| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' |
| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat |
| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' |
| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short |
| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all |
| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all |
| glog | git log --oneline --decorate --graph |
| gloga | git log --oneline --decorate --graph --all |
| glp | git log --pretty=\<format\> |
| gm | git merge |
| gmom | git merge origin/$(git_main_branch) |
| gmt | git mergetool --no-prompt |
| gmtvim | git mergetool --no-prompt --tool=vimdiff |
| gmum | git merge upstream/$(git_main_branch) |
| gmom | git merge origin/$(git_main_branch) |
| gmtl | git mergetool --no-prompt |
| gmtlvim | git mergetool --no-prompt --tool=vimdiff |
| gmum | git merge upstream/$(git_main_branch) |
| gma | git merge --abort |
| gp | git push |
| gpd | git push --dry-run |
@ -125,10 +126,10 @@ plugins=(... git)
| grb | git rebase |
| grba | git rebase --abort |
| grbc | git rebase --continue |
| grbd | git rebase develop |
| grbd | git rebase $(git_develop_branch) |
| grbi | git rebase -i |
| grbm | git rebase $(git_main_branch) |
| grbo | git rebase --onto |
| grbm | git rebase $(git_main_branch) |
| grbo | git rebase --onto |
| grbs | git rebase --skip |
| grev | git revert |
| grh | git reset |
@ -176,7 +177,7 @@ plugins=(... git)
| gupv | git pull --rebase -v |
| gupa | git pull --rebase --autostash |
| gupav | git pull --rebase --autostash -v |
| glum | git pull upstream $(git_main_branch) |
| glum | git pull upstream $(git_main_branch) |
| gwch | git whatchanged -p --abbrev-commit --pretty=medium |
| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" |
| gam | git am |
@ -214,13 +215,14 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa
### Current
| Command | Description |
|:-----------------------|:-----------------------------------------------------------------------------|
| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
| current_branch | Return the name of the current branch |
| git_current_user_name | Returns the `user.name` config value |
| git_current_user_email | Returns the `user.email` config value |
| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
| Command | Description |
|:-----------------------|:---------------------------------------------------------------------------------------------------------|
| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
| current_branch | Return the name of the current branch |
| git_current_user_name | Returns the `user.name` config value |
| git_current_user_email | Returns the `user.email` config value |
| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
| git_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
### Work in Progress (WIP)

View file

@ -31,15 +31,28 @@ function work_in_progress() {
# Check if main exists and use instead of master
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local ref
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk}; do
if command git show-ref -q --verify $ref; then
echo ${ref:t}
return
fi
done
echo master
}
# Check for develop and similarly named branches
function git_develop_branch() {
command git rev-parse --git-dir &>/dev/null || return
local branch
for branch in main trunk; do
for branch in dev devel development; do
if command git show-ref -q --verify refs/heads/$branch; then
echo $branch
return
fi
done
echo master
echo develop
}
#
@ -60,7 +73,7 @@ alias gapt='git apply --3way'
alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -d'
alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d'
alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch -d 2>/dev/null'
alias gbD='git branch -D'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
@ -88,7 +101,7 @@ alias gcl='git clone --recurse-submodules'
alias gclean='git clean -id'
alias gpristine='git reset --hard && git clean -dffx'
alias gcm='git checkout $(git_main_branch)'
alias gcd='git checkout develop'
alias gcd='git checkout $(git_develop_branch)'
alias gcmsg='git commit -m'
alias gco='git checkout'
alias gcor='git checkout --recurse-submodules'
@ -106,6 +119,7 @@ alias gdcw='git diff --cached --word-diff'
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdu='git diff @{u}'
alias gdw='git diff --word-diff'
function gdnolock() {
@ -197,19 +211,19 @@ alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glo='git log --oneline --decorate'
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat"
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'"
alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat"
alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all"
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all"
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
alias glp="_git_log_prettily"
alias gm='git merge'
alias gmom='git merge origin/$(git_main_branch)'
alias gmt='git mergetool --no-prompt'
alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
alias gmtl='git mergetool --no-prompt'
alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
alias gmum='git merge upstream/$(git_main_branch)'
alias gma='git merge --abort'
@ -227,7 +241,7 @@ alias gra='git remote add'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbd='git rebase develop'
alias grbd='git rebase $(git_develop_branch)'
alias grbi='git rebase -i'
alias grbm='git rebase $(git_main_branch)'
alias grbo='git rebase --onto'

View file

@ -1 +0,0 @@
The go plugin is deprecated. Use the [golang plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/golang) instead.

View file

@ -1,3 +0,0 @@
print -P "%F{yellow}The 'go' plugin is deprecated. Use the '%Ugolang%u' plugin instead.%f"
source "$ZSH/plugins/golang/golang.plugin.zsh"

10
plugins/invoke/README.md Normal file
View file

@ -0,0 +1,10 @@
# Invoke plugin
This plugin adds completion for [invoke](https://github.com/pyinvoke/invoke).
To use it, add `invoke` to the plugins array in your `~/.zshrc` file:
```zsh
plugins=(... invoke)
```

View file

@ -0,0 +1,5 @@
# Autocompletion for invoke.
#
if [ $commands[invoke] ]; then
source <(invoke --print-completion-script=zsh)
fi

View file

@ -3,12 +3,7 @@ typeset -A kubectx_mapping
function kubectx_prompt_info() {
if [ $commands[kubectl] ]; then
local current_ctx=`kubectl config current-context`
#if associative array declared
if [[ -n $kubectx_mapping ]]; then
echo "${kubectx_mapping[$current_ctx]}"
else
echo $current_ctx
fi
# use value in associative array if it exists, otherwise fall back to the context name
echo "${kubectx_mapping[$current_ctx]:-$current_ctx}"
fi
}

12
plugins/octozen/README.md Normal file
View file

@ -0,0 +1,12 @@
# Octozen plugin
Displays a zen quote from GitHub's Octocat on start up.
To use it, add `octozen` to the plugins array in your zshrc file:
```zsh
plugins=(... octozen)
```
It defines a `display_octozen` function that fetches a GitHub Octocat zen quote.
NOTE: Internet connection is required (will time out if not fetched in 2 seconds).

View file

@ -0,0 +1,11 @@
# octozen plugin
# Displays a zen quote from octocat
function display_octozen() {
curl -m 2 -fsL "https://api.github.com/octocat"
add-zsh-hook -d precmd display_octozen
}
# Display the octocat on the first precmd, after the whole starting process has finished
autoload -Uz add-zsh-hook
add-zsh-hook precmd display_octozen

View file

@ -1,4 +1,4 @@
# pyenv
# pyenv
This plugin looks for [pyenv](https://github.com/pyenv/pyenv), a Simple Python version
management system, and loads it if it's found. It also loads pyenv-virtualenv, a pyenv
@ -10,6 +10,14 @@ To use it, add `pyenv` to the plugins array in your zshrc file:
plugins=(... pyenv)
```
## Settings
- `ZSH_PYENV_QUIET`: if set to `true`, the plugin will not print any messages if it
finds that `pyenv` is not properly configured.
- `ZSH_PYENV_VIRTUALENV`: if set to `false`, the plugin will not load pyenv-virtualenv
when it finds it.
## Functions
- `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python

View file

@ -1,3 +1,24 @@
pyenv_config_warning() {
[[ "$ZSH_PYENV_QUIET" != true ]] || return 0
local reason="$1"
local pyenv_root="${PYENV_ROOT/#$HOME/\$HOME}"
cat >&2 <<EOF
Found pyenv, but it is badly configured ($reason). pyenv might not
work correctly for non-interactive shells (for example, when run from a script).
${(%):-"%B%F{yellow}"}
To fix this message, add these lines to the '.profile' and '.zprofile' files
in your home directory:
${(%):-"%f"}
export PYENV_ROOT="$pyenv_root"
export PATH="\$PYENV_ROOT/bin:\$PATH"
eval "\$(pyenv init --path)"
${(%):-"%F{yellow}"}
You'll need to restart your user session for the changes to take effect.${(%):-%b%f}
For more information go to https://github.com/pyenv/pyenv/#installation.
EOF
}
# This plugin loads pyenv into the current shell and provides prompt info via
# the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available.
@ -30,31 +51,34 @@ if [[ $FOUND_PYENV -ne 1 ]]; then
# If we found pyenv, load it but show a caveat about non-interactive shells
if [[ $FOUND_PYENV -eq 1 ]]; then
cat <<EOF
Found pyenv, but it is badly configured. pyenv might not work for
non-interactive shells (for example, when run from a script).
${bold_color}
To fix this message, add these lines to the '.profile' and '.zprofile' files
in your home directory:
export PYENV_ROOT="${dir/#$HOME/\$HOME}"
export PATH="\$PYENV_ROOT/bin:\$PATH"
eval "\$(pyenv init --path)"
${reset_color}
For more info go to https://github.com/pyenv/pyenv/#installation.
EOF
# Configuring in .zshrc only makes pyenv available for interactive shells
export PYENV_ROOT=$dir
export PYENV_ROOT="$dir"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
# Show warning due to bad pyenv configuration
pyenv_config_warning 'pyenv command not found in $PATH'
fi
fi
if [[ $FOUND_PYENV -eq 1 ]]; then
if [[ -z "$PYENV_ROOT" ]]; then
# This is only for backwards compatibility with users that previously relied
# on this plugin exporting it. pyenv itself does not require it to be exported
export PYENV_ROOT="$(pyenv root)"
fi
# Add pyenv shims to $PATH if not already added
if [[ -z "${path[(Re)$(pyenv root)/shims]}" ]]; then
eval "$(pyenv init --path)"
pyenv_config_warning 'missing pyenv shims in $PATH'
fi
# Load pyenv
eval "$(pyenv init - --no-rehash zsh)"
if (( ${+commands[pyenv-virtualenv-init]} )); then
# If pyenv-virtualenv exists, load it
if [[ -d "$(pyenv root)/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then
eval "$(pyenv virtualenv-init - zsh)"
fi
@ -69,3 +93,4 @@ else
fi
unset FOUND_PYENV pyenvdirs dir
unfunction pyenv_config_warning

1
plugins/rustup/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
_rustup

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
# COMPLETION FUNCTION
if (( $+commands[rustup] )); then
if [[ ! -f $ZSH_CACHE_DIR/rustup_version ]] \
|| [[ "$(rustup --version 2> /dev/null)" \
!= "$(< "$ZSH_CACHE_DIR/rustup_version")" ]] \
|| [[ ! -f $ZSH/plugins/rustup/_rustup ]]; then
rustup completions zsh > $ZSH/plugins/rustup/_rustup
rustup --version 2> /dev/null > $ZSH_CACHE_DIR/rustup_version
fi
autoload -Uz _rustup
_comps[rustup]=_rustup
fi

View file

@ -27,6 +27,15 @@ To **load multiple identities** use the `identities` style, For example:
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
```
**NOTE:** the identities may be an absolute path if they are somewhere other than
`~/.ssh`. For example:
```zsh
zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_rsa2 ~/.config/ssh/id_github
# which can be simplified to
zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github}
```
----
To **set the maximum lifetime of the identities**, use the `lifetime` style.
@ -55,6 +64,15 @@ ssh-add -K -c -a /run/user/1000/ssh-auth <identities>
For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`.
----
To set an **external helper** to ask for the passwords and possibly store
them in the system keychain use the `helper` style. For example:
```zsh
zstyle :omz:plugins:ssh-agent helper ksshaskpass
```
## Credits
Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html

View file

@ -1,84 +1,119 @@
typeset _agent_forwarding _ssh_env_cache
# Get the filename to store/lookup the environment from
ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
function _start_agent() {
local lifetime
zstyle -s :omz:plugins:ssh-agent lifetime lifetime
# Check if ssh-agent is already running
if [[ -f "$ssh_env_cache" ]]; then
. "$ssh_env_cache" > /dev/null
# start ssh-agent and setup environment
echo Starting ssh-agent...
ssh-agent -s ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache
chmod 600 $_ssh_env_cache
. $_ssh_env_cache > /dev/null
{
[[ "$USERNAME" = root ]] && command ps ax || command ps x
} | command grep ssh-agent | command grep -q $SSH_AGENT_PID && return 0
fi
# Set a maximum lifetime for identities added to ssh-agent
local lifetime
zstyle -s :omz:plugins:ssh-agent lifetime lifetime
# start ssh-agent and setup environment
echo Starting ssh-agent...
ssh-agent -s ${lifetime:+-t} ${lifetime} | sed '/^echo/d' >! "$ssh_env_cache"
chmod 600 "$ssh_env_cache"
. "$ssh_env_cache" > /dev/null
}
function _add_identities() {
local id line sig lines
local -a identities loaded_sigs loaded_ids not_loaded
zstyle -a :omz:plugins:ssh-agent identities identities
local id file line sig lines
local -a identities loaded_sigs loaded_ids not_loaded
zstyle -a :omz:plugins:ssh-agent identities identities
# check for .ssh folder presence
if [[ ! -d $HOME/.ssh ]]; then
return
fi
# check for .ssh folder presence
if [[ ! -d "$HOME/.ssh" ]]; then
return
fi
# add default keys if no identities were set up via zstyle
# this is to mimic the call to ssh-add with no identities
if [[ ${#identities} -eq 0 ]]; then
# key list found on `ssh-add` man page's DESCRIPTION section
for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do
# check if file exists
[[ -f "$HOME/.ssh/$id" ]] && identities+=$id
done
fi
# add default keys if no identities were set up via zstyle
# this is to mimic the call to ssh-add with no identities
if [[ ${#identities} -eq 0 ]]; then
# key list found on `ssh-add` man page's DESCRIPTION section
for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do
# check if file exists
[[ -f "$HOME/.ssh/$id" ]] && identities+=($id)
done
fi
# get list of loaded identities' signatures and filenames
if lines=$(ssh-add -l); then
for line in ${(f)lines}; do
loaded_sigs+=${${(z)line}[2]}
loaded_ids+=${${(z)line}[3]}
done
fi
# get list of loaded identities' signatures and filenames
if lines=$(ssh-add -l); then
for line in ${(f)lines}; do
loaded_sigs+=${${(z)line}[2]}
loaded_ids+=${${(z)line}[3]}
done
fi
# add identities if not already loaded
for id in $identities; do
# check for filename match, otherwise try for signature match
if [[ ${loaded_ids[(I)$HOME/.ssh/$id]} -le 0 ]]; then
sig="$(ssh-keygen -lf "$HOME/.ssh/$id" | awk '{print $2}')"
[[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+="$HOME/.ssh/$id"
fi
done
# add identities if not already loaded
for id in $identities; do
# if id is an absolute path, make file equal to id
[[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id"
# check for filename match, otherwise try for signature match
if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then
sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
[[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
fi
done
local args
zstyle -a :omz:plugins:ssh-agent ssh-add-args args
[[ -n "$not_loaded" ]] && ssh-add "${args[@]}" ${^not_loaded}
# abort if no identities need to be loaded
if [[ ${#not_loaded} -eq 0 ]]; then
return
fi
# pass extra arguments to ssh-add
local args
zstyle -a :omz:plugins:ssh-agent ssh-add-args args
# use user specified helper to ask for password (ksshaskpass, etc)
local helper
zstyle -s :omz:plugins:ssh-agent helper helper
if [[ -n "$helper" ]]; then
if [[ -z "${commands[$helper]}" ]]; then
echo "ssh-agent: the helper '$helper' has not been found."
else
SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null
return $?
fi
fi
ssh-add "${args[@]}" ${^not_loaded}
}
# Get the filename to store/lookup the environment from
_ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
# test if agent-forwarding is enabled
zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding
zstyle -b :omz:plugins:ssh-agent agent-forwarding agent_forwarding
if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
# Add a nifty symlink for screen/tmux if agent forwarding
[[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
elif [[ -f "$_ssh_env_cache" ]]; then
# Source SSH settings, if applicable
. $_ssh_env_cache > /dev/null
if [[ $USERNAME == "root" ]]; then
FILTER="ax"
else
FILTER="x"
fi
ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || {
_start_agent
}
# Add a nifty symlink for screen/tmux if agent forwarding
if [[ $agent_forwarding = "yes" && -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
else
_start_agent
_start_agent
fi
_add_identities
() {
emulate -L zsh
# tidy up after ourselves
unset _agent_forwarding _ssh_env_cache
command mkdir "$ZSH_CACHE_DIR/ssh-agent.lock" 2>/dev/null || return
trap "
ret=\$?
command rm -rf '$ZSH_CACHE_DIR/ssh-agent.lock'
unset agent_forwarding ssh_env_cache
unfunction _start_agent _add_identities 2>/dev/null
return \$ret
" EXIT INT QUIT
_add_identities
}
unset agent_forwarding ssh_env_cache
unfunction _start_agent _add_identities

View file

@ -15,48 +15,76 @@
# ------------------------------------------------------------------------------
__sudo-replace-buffer() {
local old=$1 new=$2 space=${2:+ }
if [[ ${#LBUFFER} -le ${#old} ]]; then
RBUFFER="${space}${BUFFER#$old }"
LBUFFER="${new}"
else
LBUFFER="${new}${space}${LBUFFER#$old }"
fi
local old=$1 new=$2 space=${2:+ }
if [[ ${#LBUFFER} -le ${#old} ]]; then
RBUFFER="${space}${BUFFER#$old }"
LBUFFER="${new}"
else
LBUFFER="${new}${space}${LBUFFER#$old }"
fi
}
sudo-command-line() {
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
# If line is empty, get the last run command from history
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
# Save beginning space
local WHITESPACE=""
if [[ ${LBUFFER:0:1} = " " ]]; then
WHITESPACE=" "
LBUFFER="${LBUFFER:1}"
# Save beginning space
local WHITESPACE=""
if [[ ${LBUFFER:0:1} = " " ]]; then
WHITESPACE=" "
LBUFFER="${LBUFFER:1}"
fi
# If $EDITOR is not set, just toggle the sudo prefix on and off
if [[ -z "$EDITOR" ]]; then
case "$BUFFER" in
sudoedit\ *) __sudo-replace-buffer "sudoedit" "" ;;
sudo\ *) __sudo-replace-buffer "sudo" "" ;;
*) LBUFFER="sudo $LBUFFER" ;;
esac
else
# Check if the typed command is really an alias to $EDITOR
# Get the first part of the typed command
local cmd="${${(Az)BUFFER}[1]}"
# Get the first part of the alias of the same name as $cmd, or $cmd if no alias matches
local realcmd="${${(Az)aliases[$cmd]}[1]:-$cmd}"
# Get the first part of the $EDITOR command ($EDITOR may have arguments after it)
local editorcmd="${${(Az)EDITOR}[1]}"
# Note: ${var:c} makes a $PATH search and expands $var to the full path
# The if condition is met when:
# - $realcmd is '$EDITOR'
# - $realcmd is "cmd" and $EDITOR is "cmd"
# - $realcmd is "cmd" and $EDITOR is "cmd --with --arguments"
# - $realcmd is "/path/to/cmd" and $EDITOR is "cmd"
# - $realcmd is "/path/to/cmd" and $EDITOR is "/path/to/cmd"
# or
# - $realcmd is "cmd" and $EDITOR is "cmd"
# - $realcmd is "cmd" and $EDITOR is "/path/to/cmd"
# or
# - $realcmd is "cmd" and $EDITOR is /alternative/path/to/cmd that appears in $PATH
if [[ "$realcmd" = (\$EDITOR|$editorcmd|${editorcmd:c}) \
|| "${realcmd:c}" = ($editorcmd|${editorcmd:c}) ]] \
|| builtin which -a "$realcmd" | command grep -Fx -q "$editorcmd"; then
editorcmd="$cmd" # replace $editorcmd with the typed command so it matches below
fi
# Get the first part of the typed command and check if it's an alias to $EDITOR
# If so, locally change $EDITOR to the alias so that it matches below
if [[ -n "$EDITOR" ]]; then
local cmd="${${(Az)BUFFER}[1]}"
if [[ "${aliases[$cmd]} " = (\$EDITOR|$EDITOR)\ * ]]; then
local EDITOR="$cmd"
fi
fi
# Check for editor commands in the typed command and replace accordingly
case "$BUFFER" in
$editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudoedit" ;;
\$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudoedit" ;;
sudoedit\ *) __sudo-replace-buffer "sudoedit" "$EDITOR" ;;
sudo\ *) __sudo-replace-buffer "sudo" "" ;;
*) LBUFFER="sudo $LBUFFER" ;;
esac
fi
if [[ -n $EDITOR && $BUFFER = $EDITOR\ * ]]; then
__sudo-replace-buffer "$EDITOR" "sudoedit"
elif [[ -n $EDITOR && $BUFFER = \$EDITOR\ * ]]; then
__sudo-replace-buffer "\$EDITOR" "sudoedit"
elif [[ $BUFFER = sudoedit\ * ]]; then
__sudo-replace-buffer "sudoedit" "$EDITOR"
elif [[ $BUFFER = sudo\ * ]]; then
__sudo-replace-buffer "sudo" ""
else
LBUFFER="sudo $LBUFFER"
fi
# Preserve beginning space
LBUFFER="${WHITESPACE}${LBUFFER}"
# Preserve beginning space
LBUFFER="${WHITESPACE}${LBUFFER}"
# Redisplay edit buffer (compatibility with zsh-syntax-highlighting)
zle redisplay
}
zle -N sudo-command-line

View file

@ -2,9 +2,9 @@
**Maintainer**: [r-darwish](https://github.com/r-darwish)
Alias for Zypper according to the official Zypper's alias
Alias for Zypper according to the official Zypper's alias
To use it add `suse` to the plugins array in you zshrc file.
To use it add `suse` to the plugins array in you zshrc file.
```zsh
plugins=(... suse)
@ -60,6 +60,12 @@ plugins=(... suse)
| zse | `zypper se` | search for packages |
| zwp | `zypper wp` | list all packages providing the specified capability |
NOTE: `--no-refresh` is passed to zypper for speeding up the calls and avoid errors due to lack
of root privileges. If you need to refresh the repositories, call `sudo zypper ref` (`zref` alias)
before runing these aliases.
Related: [#9798](https://github.com/ohmyzsh/ohmyzsh/pull/9798).
## Repositories commands
| Alias | Commands | Description |

View file

@ -25,16 +25,16 @@ alias zup='sudo zypper up'
alias zpatch='sudo zypper patch'
#Request commands
alias zif='zypper if'
alias zpa='zypper pa'
alias zpatch-info='zypper patch-info'
alias zpattern-info='zypper pattern-info'
alias zproduct-info='zypper product-info'
alias zpch='zypper pch'
alias zpd='zypper pd'
alias zpt='zypper pt'
alias zse='zypper se'
alias zwp='zypper wp'
alias zif='zypper --no-refresh if'
alias zpa='zypper --no-refresh pa'
alias zpatch-info='zypper --no-refresh patch-info'
alias zpattern-info='zypper --no-refresh pattern-info'
alias zproduct-info='zypper --no-refresh product-info'
alias zpch='zypper --no-refresh pch'
alias zpd='zypper --no-refresh pd'
alias zpt='zypper --no-refresh pt'
alias zse='zypper --no-refresh se'
alias zwp='zypper --no-refresh wp'
#Repositories commands
alias zar='sudo zypper ar'

View file

@ -22,7 +22,8 @@ EOH
local cmd=""
local before="<esc>"
local after=""
local name="GVIM"
# Look up the newest instance
local name="$(gvim --serverlist | tail -n 1)"
while getopts ":b:a:n:" option
do
case $option in

View file

@ -12,17 +12,40 @@
# # # Feel free to customize! # # #
# # # # # # # # # # # # # # # # # #
# To customize symbols (e.g MLH_AT_SYMBOL), simply set them as environment variables
# for example in your ~/.zshrc file, like this:
# MLH_AT_SYMBOL=" at "
#
# Settings *must* be set before sourcing oh-my-zsh.sh the .zshrc file.
#
# To easily discover colors and their codes, type `spectrum_ls` in the terminal
# enable or disable particular elements
PRINT_EXIT_CODE=true
PRINT_TIME=true
# right prompt default settings
if [ -z "$MLH_PRINT_EXIT_CODE" ]; then
MLH_PRINT_EXIT_CODE=true
fi
# symbols
AT_SYMBOL=" @ "
IN_SYMBOL=" in "
ON_SYMBOL=" on "
SHELL_SYMBOL="$"
if [ -z "$MLH_PRINT_TIME" ]; then
MLH_PRINT_TIME=false
fi
# left prompt symbols default settings
if [ -z "$MLH_AT_SYMBOL" ]; then
MLH_AT_SYMBOL="@"
fi
if [ -z "$MLH_IN_SYMBOL" ]; then
MLH_IN_SYMBOL=" in "
fi
if [ -z "$MLH_ON_SYMBOL" ]; then
MLH_ON_SYMBOL=" on "
fi
if [ -z "$MLH_SHELL_SYMBOL" ]; then
MLH_SHELL_SYMBOL="$ "
fi
# colors
USER_COLOR="%F{001}"
@ -47,24 +70,28 @@ directory() {
# Prints current time
current_time() {
if [ "$PRINT_TIME" = true ]; then
if [ "$MLH_PRINT_TIME" = true ]; then
echo " $TIME_COLOR%*%f"
fi
}
# Prints exit code of the last executed command
exit_code() {
if [ "$PRINT_EXIT_CODE" = true ]; then
if [ "$MLH_PRINT_EXIT_CODE" = true ]; then
echo "%(?..%F{001}exit %?)%f"
fi
}
prompt_end() {
printf "\n$MLH_SHELL_SYMBOL"
}
# Set git_prompt_info text
ZSH_THEME_GIT_PROMPT_PREFIX="${ON_SYMBOL}${BRANCH_COLOR}"
ZSH_THEME_GIT_PROMPT_PREFIX="${MLH_ON_SYMBOL}${BRANCH_COLOR}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%f"
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
# %B and %b make the text bold
PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SHELL_SYMBOL '
PROMPT='%b$(username)$MLH_AT_SYMBOL$(device)$MLH_IN_SYMBOL$(directory)$(git_prompt_info)%b$(prompt_end)'
RPROMPT="$(exit_code)$(current_time)"

View file

@ -181,6 +181,12 @@ function display-release {
return
fi
# Get length of longest scope for padding
local max_scope=0
for hash in ${(k)scopes}; do
max_scope=$(( max_scope < ${#scopes[$hash]} ? ${#scopes[$hash]} : max_scope ))
done
##* Formatting functions
# Format the hash according to output format
@ -220,18 +226,13 @@ function display-release {
#* Uses $scopes (A) and $hash from outer scope
local scope="${1:-${scopes[$hash]}}"
# Get length of longest scope for padding
local max_scope=0 padding=0
for hash in ${(k)scopes}; do
max_scope=$(( max_scope < ${#scopes[$hash]} ? ${#scopes[$hash]} : max_scope ))
done
# If no scopes, exit the function
if [[ $max_scope -eq 0 ]]; then
return
fi
# Get how much padding is required for this scope
local padding=0
padding=$(( max_scope < ${#scope} ? 0 : max_scope - ${#scope} ))
padding="${(r:$padding:: :):-}"
@ -285,15 +286,21 @@ function display-release {
(( $#breaking != 0 )) || return 0
case "$output" in
text) fmt:header "\e[31mBREAKING CHANGES" 3 ;;
raw) fmt:header "BREAKING CHANGES" 3 ;;
text|md) fmt:header "BREAKING CHANGES" 3 ;;
md) fmt:header "BREAKING CHANGES" 3 ;;
esac
local hash subject
local hash message
local wrap_width=$(( (COLUMNS < 100 ? COLUMNS : 100) - 3 ))
for hash message in ${(kv)breaking}; do
echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject "${message}")"
done | sort
echo
# Format the BREAKING CHANGE message by word-wrapping it at maximum 100
# characters (use $COLUMNS if smaller than 100)
message="$(fmt -w $wrap_width <<< "$message")"
# Display hash and scope in their own line, and then the full message with
# blank lines as separators and a 3-space left padding
echo " - $(fmt:hash) $(fmt:scope)\n\n$(fmt:subject "$message" | sed 's/^/ /')\n"
done
}
function display:type {
@ -391,9 +398,7 @@ function main {
# Get commit list from $until commit until $since commit, or until root
# commit if $since is unset, in short hash form.
# --first-parent is used when dealing with merges: it only prints the
# merge commit, not the commits of the merged branch.
command git rev-list --first-parent --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do
command git rev-list --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do
# Truncate list on versions with a lot of commits
if [[ -z "$since" ]] && (( ++read_commits > 35 )); then
truncate=1

View file

@ -30,7 +30,7 @@ if [ -t 1 ]; then
BOLD=$(printf '\033[1m')
DIM=$(printf '\033[2m')
UNDER=$(printf '\033[4m')
RESET=$(printf '\033[m')
RESET=$(printf '\033[0m')
fi
# Update upstream remote to ohmyzsh org