Merge branch 'ohmyzsh:master' into conda

This commit is contained in:
Jeonguk Choi 2022-02-11 23:43:06 +09:00 committed by GitHub
commit 88097374c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 978 additions and 1177 deletions

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2009-2021 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
Copyright (c) 2009-2022 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,4 +1,4 @@
<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p>
<p align="center"><img src="https://ohmyzsh.s3.amazonaws.com/omz-ansi-github.png" alt="Oh My Zsh"></p>
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.

View file

@ -105,7 +105,10 @@ function _omz {
return 0
}
compdef _omz omz
# If run from a script, do not set the completion function
if (( ${+functions[compdef]} )); then
compdef _omz omz
fi
## Utility functions
@ -299,10 +302,8 @@ multi == 1 && length(\$0) > 0 {
# 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"
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
}
function _omz::plugin::enable {
@ -375,10 +376,8 @@ multi == 1 && /^[^#]*\)/ {
# 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"
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
}
function _omz::plugin::info {
@ -574,7 +573,7 @@ function _omz::pr::test {
# Rebase pull request branch against the current master
_omz::log info "rebasing PR #$1..."
command git rebase master ohmyzsh/pull-$1 || {
command git rebase --no-gpg-sign master ohmyzsh/pull-$1 || {
command git rebase --abort &>/dev/null
_omz::log warn "could not rebase PR #$1 on top of master."
_omz::log warn "you might not see the latest stable changes."
@ -731,10 +730,8 @@ EOF
# 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"
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
}
function _omz::theme::use {

View file

@ -57,14 +57,14 @@ mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
source $ZSH/tools/check_for_upgrade.sh
if [[ "$DISABLE_AUTO_UPDATE" != true ]]; then
source "$ZSH/tools/check_for_upgrade.sh"
fi
# Initializes Oh My Zsh
# add a function path
fpath=($ZSH/functions $ZSH/completions $fpath)
fpath=("$ZSH/functions" "$ZSH/completions" $fpath)
# Load all stock functions (from $fpath files) called below.
autoload -U compaudit compinit
@ -75,7 +75,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom"
fi
is_plugin() {
local base_dir=$1
local name=$2
@ -86,10 +85,10 @@ is_plugin() {
# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
if is_plugin $ZSH_CUSTOM $plugin; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
elif is_plugin $ZSH $plugin; then
fpath=($ZSH/plugins/$plugin $fpath)
if is_plugin "$ZSH_CUSTOM" "$plugin"; then
fpath=("$ZSH_CUSTOM/plugins/$plugin" $fpath)
elif is_plugin "$ZSH" "$plugin"; then
fpath=("$ZSH/plugins/$plugin" $fpath)
else
echo "[oh-my-zsh] plugin '$plugin' not found"
fi
@ -98,14 +97,14 @@ done
# Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then
# macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
else
SHORT_HOST=${HOST/.*/}
SHORT_HOST="${HOST/.*/}"
fi
# Save the location of the current completion dump file.
if [ -z "$ZSH_COMPDUMP" ]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
if [[ -z "$ZSH_COMPDUMP" ]]; then
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi
# Construct zcompdump OMZ metadata
@ -119,15 +118,15 @@ if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
zcompdump_refresh=1
fi
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
source $ZSH/lib/compfix.zsh
if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
source "$ZSH/lib/compfix.zsh"
# If completion insecurities exist, warn the user
handle_completion_insecurities
# Load only from secure directories
compinit -i -C -d "${ZSH_COMPDUMP}"
compinit -i -C -d "$ZSH_COMPDUMP"
else
# If the user wants it, load from all found directories
compinit -u -C -d "${ZSH_COMPDUMP}"
compinit -u -C -d "$ZSH_COMPDUMP"
fi
# Append zcompdump metadata if missing
@ -140,40 +139,48 @@ $zcompdump_revision
$zcompdump_fpath
EOF
fi
unset zcompdump_revision zcompdump_fpath zcompdump_refresh
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
[ -f "${custom_config_file}" ] && config_file=${custom_config_file}
source $config_file
for config_file ("$ZSH"/lib/*.zsh); do
custom_config_file="$ZSH_CUSTOM/lib/${config_file:t}"
[[ -f "$custom_config_file" ]] && config_file="$custom_config_file"
source "$config_file"
done
unset custom_config_file
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
if [[ -f "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh" ]]; then
source "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh"
elif [[ -f "$ZSH/plugins/$plugin/$plugin.plugin.zsh" ]]; then
source "$ZSH/plugins/$plugin/$plugin.plugin.zsh"
fi
done
unset plugin
# Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
source $config_file
for config_file ("$ZSH_CUSTOM"/*.zsh(N)); do
source "$config_file"
done
unset config_file
# Load the theme
if [ ! "$ZSH_THEME" = "" ]; then
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
is_theme() {
local base_dir=$1
local name=$2
builtin test -f $base_dir/$name.zsh-theme
}
if [[ -n "$ZSH_THEME" ]]; then
if is_theme "$ZSH_CUSTOM" "$ZSH_THEME"; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
elif is_theme "$ZSH_CUSTOM/themes" "$ZSH_THEME"; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else
elif is_theme "$ZSH/themes" "$ZSH_THEME"; then
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
else
echo "[oh-my-zsh] theme '$ZSH_THEME' not found"
fi
fi

View file

@ -4,8 +4,8 @@ if (( ${+commands[op]} )); then
fi
# 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 5 seconds. The
# clipboard is cleared after another 10 seconds.
# 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>"

View file

@ -1,12 +0,0 @@
# Django plugin
This plugin adds completion for the [Django Project](https://www.djangoproject.com/) commands
(`manage.py`, `django-admin`, ...).
## Deprecation (2021-09-22)
The plugin used to provide completion for `./manage.py` and `django-admin`, but Zsh already provides
a better, more extensive completion for those, so this plugin is no longer needed.
Right now a warning message is shown, but in the near future the plugin will stop working altogether.
So you can remove it from your plugins and you'll automatically start using Zsh's django completion.

View file

@ -1,407 +0,0 @@
#compdef manage.py
typeset -ga nul_args
nul_args=(
'--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))'
'--settings=-[the Python path to a settings module.]:file:_files'
'--pythonpath=-[a directory to add to the Python path.]:directory:_directories'
'--traceback[print traceback on exception.]'
"--no-color[Don't colorize the command output.]"
"--version[show program's version number and exit.]"
{-h,--help}'[show this help message and exit.]'
)
typeset -ga start_args
start_args=(
'--template=-[The path or URL to load the template from.]:directory:_directories'
'--extension=-[The file extension(s) to render (default: "py").]'
'--name=-[The file name(s) to render.]:file:_files'
)
typeset -ga db_args
db_args=(
'--database=-[Nominates a database. Defaults to the "default" database.]'
)
typeset -ga noinput_args
noinput_args=(
'--noinput[tells Django to NOT prompt the user for input of any kind.]'
)
typeset -ga no_init_data_args
no_init_data_args=(
'--no-initial-data[Tells Django not to load any initial data after database synchronization.]'
)
typeset -ga tag_args
tag_args=(
'--tag=-[Run only checks labeled with given tag.]'
'--list-tags[List available tags.]'
)
_managepy-check(){
_arguments -s : \
$tag_args \
$nul_args && ret=0
}
_managepy-changepassword(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-createcachetable(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-createsuperuser(){
_arguments -s : \
'--username=-[Specifies the login for the superuser.]' \
'--email=-[Specifies the email for the superuser.]' \
$noinput_args \
$db_args \
$nul_args && ret=0
}
_managepy-collectstatic(){
_arguments -s : \
'--link[Create a symbolic link to each file instead of copying.]' \
'--no-post-process[Do NOT post process collected files.]' \
'--ignore=-[Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.]' \
'--dry-run[Do everything except modify the filesystem.]' \
'--clear[Clear the existing files using the storage before trying to copy or link the original file.]' \
'--link[Create a symbolic link to each file instead of copying.]' \
'--no-default-ignore[Do not ignore the common private glob-style patterns "CVS", ".*" and "*~".]' \
$noinput_args \
$nul_args && ret=0
}
_managepy-dbshell(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-diffsettings(){
_arguments -s : \
"--all[Display all settings, regardless of their value.]"
$nul_args && ret=0
}
_managepy-dumpdata(){
_arguments -s : \
'--format=-[Specifies the output serialization format for fixtures.]:format:(json yaml xml)' \
'--indent=-[Specifies the indent level to use when pretty-printing output.]' \
'--exclude=-[An app_label or app_label.ModelName to exclude (use multiple --exclude to exclude multiple apps/models).]' \
'--natural-foreign[Use natural foreign keys if they are available.]' \
'--natural-primary[Use natural primary keys if they are available.]' \
"--all[Use Django's base manager to dump all models stored in the database.]" \
'--pks=-[Only dump objects with given primary keys.]' \
$db_args \
$nul_args \
'*::appname:_applist' && ret=0
}
_managepy-flush(){
_arguments -s : \
$no_init_data_args \
$db_args \
$noinput_args \
$nul_args && ret=0
}
_managepy-help(){
_arguments -s : \
'*:command:_managepy_cmds' \
$nul_args && ret=0
}
_managepy_cmds(){
local line
local -a cmd
_call_program help-command ./manage.py help \
|& sed -n '/^ /s/[(), ]/ /gp' \
| while read -A line; do cmd=($line $cmd) done
_describe -t managepy-command 'manage.py command' cmd
}
_managepy-inspectdb(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-loaddata(){
_arguments -s : \
'--ignorenonexistent[Ignores entries in the serialized data for fields that do not currently exist on the model.]' \
'--app=-[Only look for fixtures in the specified app.]:appname:_applist' \
'*::file:_files' \
$db_args \
$nul_args && ret=0
}
_managepy-makemessages(){
_arguments -s : \
'--locale=-[Creates or updates the message files for the given locale(s) (e.g. pt_BR).]' \
'--domain=-[The domain of the message files (default: "django").]' \
'--all[Updates the message files for all existing locales.]' \
'--extension=-[The file extension(s) to examine (default: "html,txt", or "js" if the domain is "djangojs").]' \
'--symlinks[Follows symlinks to directories when examining source code and templates for translation strings.]' \
'--ignore=-[Ignore files or directories matching this glob-style pattern.]' \
"--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \
"--no-wrap[Don't break long message lines into several lines.]" \
"--no-location[Don't write '#: filename:line' lines.]" \
'--no-obsolete[Remove obsolete message strings.]' \
'--keep-pot[Keep .pot file after making messages.]' \
$nul_args && ret=0
}
_managepy-makemigrations(){
_arguments -s : \
'--dry-run[Just show what migrations would be made]' \
'--merge[Enable fixing of migration conflicts.]' \
'--empty[Create an empty migration.]' \
$noinput_args \
$nul_args && ret=0
}
_managepy-migrate(){
_arguments -s : \
'--fake[Mark migrations as run without actually running them]' \
'--list[Show a list of all known migrations and which are applied]' \
$no_init_data_args \
$noinput_args \
$db_args \
$nul_args && ret=0
}
_managepy-runfcgi(){
local state
local fcgi_opts
fcgi_opts=(
'protocol[fcgi, scgi, ajp, ... (default fcgi)]:protocol:(fcgi scgi ajp)'
'host[hostname to listen on..]:'
'port[port to listen on.]:'
'socket[UNIX socket to listen on.]:file:_files'
'method[prefork or threaded (default prefork)]:method:(prefork threaded)'
'maxrequests[number of requests a child handles before it is killed and a new child is forked (0 = no limit).]:'
'maxspare[max number of spare processes / threads.]:'
'minspare[min number of spare processes / threads.]:'
'maxchildren[hard limit number of processes / threads.]:'
'daemonize[whether to detach from terminal.]:boolean:(False True)'
'pidfile[write the spawned process-id to this file.]:file:_files'
'workdir[change to this directory when daemonizing.]:directory:_files'
'outlog[write stdout to this file.]:file:_files'
'errlog[write stderr to this file.]:file:_files'
)
_arguments -s : \
$nul_args \
'*: :_values "FCGI Setting" $fcgi_opts' && ret=0
}
_managepy-runserver(){
_arguments -s : \
'--ipv6[Tells Django to use an IPv6 address.]' \
'--nothreading[Tells Django to NOT use threading.]' \
'--noreload[Tells Django to NOT use the auto-reloader.]' \
'--nostatic[Tells Django to NOT automatically serve static files at STATIC_URL.]' \
'--insecure[Allows serving static files even if DEBUG is False.]' \
$nul_args && ret=0
}
_managepy-shell(){
_arguments -s : \
'--plain[Tells Django to use plain Python, not IPython.]' \
'--no-startup[When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.]' \
'--interface=-[Specify an interactive interpreter interface.]:INTERFACE:((ipython bpython))' \
$nul_args && ret=0
}
_managepy-sql(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlall(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlclear(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlcustom(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-dropindexes(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlflush(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlindexes(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlinitialdata(){
_arguments -s : \
$nul_args && ret=0
}
_managepy-sqlsequencereset(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-squashmigrations(){
_arguments -s : \
'--no-optimize[Do not try to optimize the squashed operations.]' \
$noinput_args \
$nul_args && ret=0
}
_managepy-startapp(){
_arguments -s : \
$start_args \
$nul_args && ret=0
}
_managepy-startproject(){
_arguments -s : \
$start_args \
$nul_args && ret=0
}
_managepy-syncdb() {
_arguments -s : \
$noinput_args \
$no_init_data_args \
$db_args \
$nul_args && ret=0
}
_managepy-test() {
_arguments -s : \
'--failfast[Tells Django to stop running the test suite after first failed test.]' \
'--testrunner=-[Tells Django to use specified test runner class instead of the one specified by the TEST_RUNNER setting.]' \
'--liveserver=-[Overrides the default address where the live server (used with LiveServerTestCase) is expected to run from. The default value is localhost:8081.]' \
'--top-level-directory=-[Top level of project for unittest discovery.]' \
'--pattern=-[The test matching pattern. Defaults to test*.py.]:' \
$noinput_args \
'*::appname:_applist' \
$nul_args && ret=0
}
_managepy-testserver() {
_arguments -s : \
'--addrport=-[port number or ipaddr:port to run the server on.]' \
'--ipv6[Tells Django to use an IPv6 address.]' \
$noinput_args \
'*::fixture:_files' \
$nul_args && ret=0
}
_managepy-validate() {
_arguments -s : \
$tag_args \
$nul_args && ret=0
}
_managepy-commands() {
local -a commands
commands=(
"changepassword:Change a user's password for django.contrib.auth."
'check:Checks the entire Django project for potential problems.'
'compilemessages:Compiles .po files to .mo files for use with builtin gettext support.'
'createcachetable:Creates the table needed to use the SQL cache backend.'
'createsuperuser:Used to create a superuser.'
'collectstatic:Collect static files in a single location.'
'dbshell:Runs the command-line client for the current DATABASE_ENGINE.'
"diffsettings:Displays differences between the current settings.py and Django's default settings."
'dumpdata:Output the contents of the database as a fixture of the given format.'
'flush:Executes ``sqlflush`` on the current database.'
'help:manage.py help.'
'inspectdb:Introspects the database tables in the given database and outputs a Django model module.'
'loaddata:Installs the named fixture(s) in the database.'
'makemessages:Runs over the entire source tree of the current directory and pulls out all strings marked for translation.'
'makemigrations:Creates new migration(s) for apps.'
'migrate:Updates database schema. Manages both apps with migrations and those without.'
'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,'
'runserver:Starts a lightweight Web server for development.'
'shell:Runs a Python interactive interpreter.'
'showmigrations:Shows all available migrations for the current project.'
'sql:Prints the CREATE TABLE SQL statements for the given app name(s).'
'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).'
'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).'
'sqlcustom:Prints the custom table modifying SQL statements for the given app name(s).'
'sqldropindexes:Prints the DROP INDEX SQL statements for the given model module name(s).'
'sqlflush:Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.'
'sqlindexes:Prints the CREATE INDEX SQL statements for the given model module name(s).'
"sqlinitialdata:RENAMED: see 'sqlcustom'"
'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).'
'squashmigrations:Squashes an existing set of migrations (from first until specified) into a single new one.'
"startapp:Creates a Django app directory structure for the given app name in this project's directory."
"startproject:Creates a Django project directory structure for the given project name in this current directory."
"syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created."
'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.'
'testserver:Runs a development server with data from the given fixture(s).'
'validate:Validates all installed models.'
)
_describe -t commands 'manage.py command' commands && ret=0
}
_applist() {
local line
local -a apps
_call_program help-command "python -c \"import sys; del sys.path[0];\\
import os.path as op, re, django.conf;\\
bn=op.basename(op.abspath(op.curdir));[sys\\
.stdout.write(str(re.sub(r'^%s\.(.*?)$' %
bn, r'\1', i)) + '\n') for i in django.conf.settings.\\
INSTALLED_APPS if re.match(r'^%s' % bn, i)]\"" \
| while read -A line; do apps=($line $apps) done
_values 'Application' $apps && ret=0
}
_managepy() {
local curcontext=$curcontext ret=1
if ((CURRENT == 2)); then
_managepy-commands
else
shift words
(( CURRENT -- ))
curcontext="${curcontext%:*:*}:managepy-$words[1]:"
_call_function ret _managepy-$words[1]
fi
}
compdef _managepy manage.py
compdef _managepy django
compdef _managepy django-admin
compdef _managepy django-admin.py
compdef _managepy django-manage
print -P "%F{yellow}The django plugin is deprecated in favor of Zsh's Django completion.
%BPlease remove it from your plugins to stop using it.%b%f"

View file

@ -33,8 +33,9 @@ if [ -z "$script" ]; then
bash_completion='/usr/share/bash-completion/completions/'
locations=(
"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
"${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash
"$HOME/.local/share/bash-completion/completions/git"
'/usr/local/share/bash-completion/completions/git'
"$bash_completion/git"
'/etc/bash_completion.d/git' # old debian
)
@ -51,13 +52,20 @@ functions[complete]="$old_complete"
__gitcompadd ()
{
compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0
}
__gitcomp ()
{
emulate -L zsh
IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }"
}
__gitcomp_opts ()
{
emulate -L zsh
local cur_="${3-$cur}"
[[ "$cur_" == *= ]] && return
@ -70,7 +78,7 @@ __gitcomp ()
break
fi
if [[ -z "${4-}" ]]; then
if [[ -z "${4+set}" ]]; then
case $c in
*=) c="${c%=}"; sfx="=" ;;
*.) sfx="" ;;
@ -79,7 +87,7 @@ __gitcomp ()
else
sfx="$4"
fi
__gitcompadd "$c" "${2-}" "$sfx" -q
__gitcompadd "$c" "${2-}" "$sfx"
done
}
@ -87,7 +95,10 @@ __gitcomp_nl ()
{
emulate -L zsh
IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
# words that don't end up in space
compadd -p "${2-}" -S "${4- }" -q -- ${${(f)1}:#*\ } && _ret=0
# words that end in space
compadd -p "${2-}" -S " ${4- }" -q -- ${${(M)${(f)1}:#*\ }% } && _ret=0
}
__gitcomp_file ()
@ -107,21 +118,6 @@ __gitcomp_file_direct ()
__gitcomp_file "$1" ""
}
__gitcomp_nl_append ()
{
__gitcomp_nl "$@"
}
__gitcomp_direct_append ()
{
__gitcomp_direct "$@"
}
_git_zsh ()
{
__gitcomp "v1.2"
}
__git_complete_command ()
{
emulate -L zsh
@ -206,9 +202,7 @@ __git_zsh_main ()
{
local curcontext="$curcontext" state state_descr line
typeset -A opt_args
local -a orig_words __git_C_args
orig_words=( ${words[@]} )
local -a __git_C_args
_arguments -C \
'(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
@ -245,7 +239,7 @@ __git_zsh_main ()
emulate ksh -c __git_complete_config_variable_name_and_value
;;
(arg)
local command="${words[1]}" __git_dir
local command="${words[1]}" __git_dir __git_cmd_idx=1
if (( $+opt_args[--bare] )); then
__git_dir='.'
@ -259,7 +253,7 @@ __git_zsh_main ()
(( $+opt_args[--help] )) && command='help'
words=( ${orig_words[@]} )
words=( git ${words[@]} )
__git_zsh_bash_func $command
;;
@ -269,7 +263,7 @@ __git_zsh_main ()
_git ()
{
local _ret=1
local cur cword prev
local cur cword prev __git_cmd_idx=0
cur=${words[CURRENT]}
prev=${words[CURRENT-1]}

File diff suppressed because it is too large Load diff

View file

@ -138,6 +138,7 @@ __git_ps1_show_upstream ()
done <<< "$output"
# parse configuration values
local option
for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in
git|svn) upstream="$option" ;;
@ -432,8 +433,8 @@ __git_ps1 ()
fi
local sparse=""
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
[ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ -z "${GIT_PS1_OMITSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
sparse="|SPARSE"
fi
@ -542,7 +543,7 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}"
fi
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
h="?"
fi

View file

@ -1,7 +1,7 @@
#!/bin/sh
url="https://raw.githubusercontent.com/felipec/git-completion"
version="1.2"
version="1.3.6"
curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&

View file

@ -15,34 +15,46 @@ Naming convention:
- `!` suffix: `--force --no-wait -y`.
- `ds` suffix: `--destroy-storage`.
- `jsh` prefix means `juju show-*`.
### General
| Alias | Command | Description |
|--------|---------------------------------------------|--------------------------------------------------------|
| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
| `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
| `jh` | `juju help` | Show help on a command or other topic |
| `jssl` | `juju juju show-status-log` | Output past statuses for the specified entity |
| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
| `jst` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
| Alias | Command | Description |
|---------|---------------------------------------------|--------------------------------------------------------|
| `j` | `juju` | The juju command |
| `jcld` | `juju clouds` | Lists all clouds with registered credentials |
| `jclda` | `juju clouds --all` | Lists all clouds available to Juju |
| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
| `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
| `jh` | `juju help` | Show help on a command or other topic |
| `jshsl` | `juju show-status-log` | Output past statuses for the specified entity |
| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
| `jst` | `juju status --relations --color` | Show status, including relations, in color |
| `jsts` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
### Bootstrap
| Alias | Command | Description |
|-------|---------------------------|-------------------------------------------|
| `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
| Alias | Command | Description |
|---------|-------------------------------------|-------------------------------------------------------|
| `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
| `jbng` | `juju bootstrap --no-gui` | Initializing a Juju cloud environment without GUI |
| `jbl` | `juju bootstrap localhost` | Initializing an lxd cloud environment |
| `jblng` | `juju bootstrap --no-gui localhost` | Initializing an lxd cloud environment without GUI |
| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
| `jbmng` | `juju bootstrap --no-gui microk8s` | Initializing a MicroK8s cloud environment without GUI |
### Controller
| Alias | Command | Description |
|----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| `jctl` | `juju controllers` | List all controllers |
| `jctlr` | `juju controllers --refresh` | List all controllers (download latest details) |
| `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller |
| `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller |
| `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage |
| `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage |
| `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller |
| `jshc` | `juju show-controller` | Shows detailed information of a controller |
| `jsw` | `juju switch` | Select or identify the current controller and model |
### Model
@ -74,9 +86,9 @@ Naming convention:
| `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage |
| `jrp` | `juju refresh --path` | Upgrade charm from local charm file |
| `jsa` | `juju scale-application` | Set the desired number of application units |
| `jsh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
| `jshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
| `jsu` | `juju show-unit` | Displays information about a unit |
| `jssh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
| `jsshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
| `jshu` | `juju show-unit` | Displays information about a unit |
### Storage
@ -113,5 +125,6 @@ Naming convention:
- `jaddr <app_name> [unit_num]`: display app or unit IP address.
- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data.
- `jclean`: destroy all controllers
- `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval
(default: 5s); you may pass additional arguments to `watch`.

View file

@ -16,12 +16,22 @@ unset completion_file
# Generally, #
# - `!` means --force --no-wait -y #
# - `ds` suffix means --destroy-storage #
# - `jsh` prefix means juju show-* #
# ---------------------------------------------------------- #
alias j="juju"
alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\
--config update-status-hook-interval=\"60m\""
alias jb='juju bootstrap'
alias jbng='juju bootstrap --no-gui'
alias jbl='juju bootstrap localhost'
alias jblng='juju bootstrap --no-gui localhost'
alias jbm='juju bootstrap microk8s'
alias jbmng='juju bootstrap --no-gui microk8s'
alias jc='juju config'
alias jcld='juju clouds'
alias jclda='juju clouds --all'
alias jctl='juju controllers'
alias jctlr='juju controllers --refresh'
alias jdc='juju destroy-controller --destroy-all-models'
alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y'
alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage'
@ -56,13 +66,16 @@ alias jrp='juju refresh --path'
alias jrs='juju remove-storage'
alias 'jrs!'='juju remove-storage --force'
alias jsa='juju scale-application'
alias jsh='juju ssh'
alias jshc='juju ssh --container'
alias jsha='juju show-application'
alias jshc='juju show-controller'
alias jshm='juju show-model'
alias jssl='juju show-status-log'
alias jshsl='juju show-status-log'
alias jshu='juju show-unit'
alias jssh='juju ssh'
alias jsshc='juju ssh --container'
alias jstj='juju status --format=json'
alias jst='juju status --relations --storage --color'
alias jsu='juju show-unit'
alias jst='juju status --relations --color'
alias jsts='juju status --relations --storage --color'
alias jsw='juju switch'
# ---------------------------------------------------------- #
@ -95,6 +108,37 @@ jaddr() {
fi
}
# Destroy all controllers
jclean() {
if (( ! ${+commands[jq]} )); then
echo "jq is required but could not be found." >&2
return 1
fi
local controllers=$(juju controllers --format=json | jq -r '.controllers | keys[]' 2>/dev/null)
if [[ -z "$controllers" ]]; then
echo "No controllers registered"
return 0
fi
echo "This will forcefully destroy all storages, models and controllers."
echo "Controllers to be destroyed:"
echo "$controllers"
if ! read -q '?Are you sure (y/n)? '; then
echo
echo "Aborted."
return 0
fi
echo
for controller in ${=controllers}; do
timeout 2m juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y $controller
timeout 2m juju kill-controller -y -t 0 $controller 2>/dev/null
timeout 10s juju unregister $controller 2>/dev/null
done
}
# Display app and unit relation data
jreld() {
# $1 = relation name
@ -123,5 +167,6 @@ jreld() {
wjst() {
local interval="${1:-5}"
shift $(( $# > 0 ))
watch -n "$interval" --color juju status --relations --storage --color "$@"
watch -n "$interval" --color juju status --relations --color "$@"
}

View file

@ -29,7 +29,7 @@ alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca'
alias kaf='kubectl apply -f'
# Drop into an interactive terminal on a container
alias keti='kubectl exec -ti'
alias keti='kubectl exec -t -i'
# Manage configuration quickly to switch contexts between local, dev ad staging.
alias kcuc='kubectl config use-context'

View file

@ -3,7 +3,9 @@ typeset -g -A kubectx_mapping
function kubectx_prompt_info() {
(( $+commands[kubectl] )) || return
local current_ctx=$(kubectl config current-context)
local current_ctx=$(kubectl config current-context 2> /dev/null)
[[ -n "$current_ctx" ]] || return
# use value in associative array if it exists
# otherwise fall back to the context name

View file

@ -0,0 +1,22 @@
# multipass
This plugin provides completion for [multipass](https://multipass.run), as well as aliases
for multipass commands.
To use it, add `multipass` to the plugins array in your zshrc file:
```zsh
plugins=(... multipass)
```
## Aliases
| Alias | Command |
| ------ | ------------------------------------------------------------------- |
| `mp` | `multipass` |
| `mpl` | `multipass list` |
| `mpla` | `multipass launch` |
| `mpln` | `multipass launch --network en0 --network name=bridge0,mode=manual` |
| `mps` | `multipass shell` |
| `mpsp` | `multipass stop` |
| `mpst` | `multipass start` |

View file

@ -0,0 +1,73 @@
#compdef multipass
_multipass_get_command_list () {
# Sample output:
# $ multipass --help
# ...
# Options:
# -h, --help Display this help
# -v, --verbose Increase logging verbosity. Repeat the 'v' in the short option
# for more detail. Maximum verbosity is obtained with 4 (or more)
# v's, i.e. -vvvv.
# ...
# Available commands:
# alias Create an alias
# aliases List available aliases
# ...
#
$_comp_command1 --help | sed '1,/Available commands/d' | awk '/^[ \t]*[a-z]+/ { print $1 }'
}
_multipass_get_args_list () {
# Sample output:
# $ multpass help stop
# ...
# Options:
# -h, --help Display this help
# -v, --verbose Increase logging verbosity. Repeat the 'v' in the short
# option for more detail. Maximum verbosity is obtained with
# 4 (or more) v's, i.e. -vvvv.
# --all Stop all instances
# -t, --time <time> Time from now, in minutes, to delay shutdown of the
# instance
# -c, --cancel Cancel a pending delayed shutdown
#
# Arguments:
# name Names of instances to stop. If omitted, and without the
# --all option, 'primary' will be assumed.
#
local arg_name=$($_comp_command1 help ${words[2]} | sed '1,/Arguments/d' | awk '/^[ \t]*[a-z]+/ { print $1; exit }')
case $arg_name in
name)
# Sample output:
# $ multipass list
# Name State IPv4 Image
# workable-poacher Running 10.2.0.28 Ubuntu openHAB Home Appliance
#
$_comp_command1 list | sed '1d' | awk '/^[ \t]*[^ ]+/ { print $1 }'
;;
command)
_multipass_get_command_list
;;
esac
}
_multipass () {
typeset -A opt_args
_arguments \
'1: :->command'\
'*: :->args'
case $state in
command)
compadd $(_multipass_get_command_list)
;;
*)
compadd $(_multipass_get_args_list)
;;
esac
}
_multipass "$@"

View file

@ -0,0 +1,7 @@
alias mp="multipass"
alias mpl="multipass list"
alias mpla="multipass launch"
alias mpln="multipass launch --network en0 --network name=bridge0,mode=manual"
alias mps="multipass shell"
alias mpsp="multipass stop"
alias mpst="multipass start"

View file

@ -1,27 +1,4 @@
# NPX Plugin
> npx(1) -- execute npm package binaries. ([more info](https://github.com/npm/npx))
This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
To use it, add `npx` to the plugins array in your zshrc file:
```zsh
plugins=(.... npx)
```
## Note
The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`:
```
➜ jasmine@latest # or just `jasmine@`
npx: installed 13 in 1.896s
Randomized with seed 54385
Started
```
It does it this way so folks using the fallback don't accidentally try to install regular typoes.
# npx plugin
## Deprecation

View file

@ -1,7 +1,12 @@
# NPX Plugin
# https://www.npmjs.com/package/npx
# Maintainer: Pooya Parsa <pooya@pi0.ir>
if (( ! $+commands[npx] )); then
return
fi
(( $+commands[npx] )) && {
source <(npx --shell-auto-fallback zsh)
}
if ! npx_fallback_script="$(npx --shell-auto-fallback zsh 2>/dev/null)"; then
print -u2 ${(%):-"%F{yellow}This \`npx\` version ($(npx --version)) is not supported.%f"}
else
source <(<<< "$npx_fallback_script")
fi
print -u2 ${(%):-"%F{yellow}The \`npx\` plugin is deprecated and will be removed soon. %BPlease disable it%b.%f"}
unset npx_fallback_script

View file

@ -1,5 +1,5 @@
print ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'}
print ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'}
print -u2 ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'}
print -u2 ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'}
(( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath)
source "$ZSH/plugins/macos/macos.plugin.zsh"

View file

@ -9,4 +9,14 @@ To use it, add `rbw` to the plugins array in your zshrc file:
plugins=(... rbw)
```
## `rbwpw`
The `rbwpw` function is a wrapper around `rbw`. It copies the password in the
clipboard for the service you ask for and clears the clipboard 20s later.
The usage is as follows:
```zsh
rbwpw <service>
```
This plugin does not add any aliases.

View file

@ -17,3 +17,33 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
fi
rbw gen-completions zsh >| "$ZSH_CACHE_DIR/completions/_rbw" &|
# rbwpw function copies the password of a service to the clipboard
# and clears it after 20 seconds
function rbwpw {
if [[ $# -ne 1 ]]; then
echo "usage: rbwpw <service>"
return 1
fi
local service=$1
if ! rbw unlock; then
echo "rbw is locked"
return 1
fi
local pw=$(rbw get $service 2>/dev/null)
if [[ -z $pw ]]; then
echo "$service not found"
return 1
fi
echo -n $pw | clipcopy
echo "password for $service copied!"
{sleep 20 && clipcopy </dev/null 2>/dev/null} &|
}
function _rbwpw {
local -a services
services=("${(@f)$(rbw ls 2>/dev/null)}")
[[ -n "$services" ]] && compadd -a -- services
}
compdef _rbwpw rbwpw

View file

@ -15,16 +15,16 @@ The plugin also supports the following:
## Aliases
| Alias | Command | Description |
| ---------- | ---------------------- | -------------------------------------------------------- |
| `ta` | tmux attach -t | Attach new tmux session to already running named session |
| `tad` | tmux attach -d -t | Detach named tmux session |
| `ts` | tmux new-session -s | Create a new named tmux session |
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
| `tksv` | tmux kill-server | Terminate all running tmux sessions |
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
| `tmuxconf` | `$EDITOR ~/.tmux.conf` | Open .tmux.conf file with an editor |
| Alias | Command | Description |
| ---------- | -------------------------- | -------------------------------------------------------- |
| `ta` | tmux attach -t | Attach new tmux session to already running named session |
| `tad` | tmux attach -d -t | Detach named tmux session |
| `ts` | tmux new-session -s | Create a new named tmux session |
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
| `tksv` | tmux kill-server | Terminate all running tmux sessions |
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
| `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
## Configuration Variables

View file

@ -3,16 +3,6 @@ if ! (( $+commands[tmux] )); then
return 1
fi
# ALIASES
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'
alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
alias tmuxconf='$EDITOR ~/.tmux.conf'
# CONFIGURATION VARIABLES
# Automatically start tmux
: ${ZSH_TMUX_AUTOSTART:=false}
@ -40,6 +30,16 @@ alias tmuxconf='$EDITOR ~/.tmux.conf'
# Set -u option to support unicode
: ${ZSH_TMUX_UNICODE:=false}
# ALIASES
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'
alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
# Determine if the terminal supports 256 colors
if [[ $terminfo[colors] == 256 ]]; then
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR

View file

@ -56,7 +56,13 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV
if [[ -n "$VIRTUAL_ENV" ]]; then
# Only deactivate if VIRTUAL_ENV was set
# User may have deactivated manually or via another mechanism
deactivate
fi
# clean up regardless
unset CD_VIRTUAL_ENV
fi
if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active

View file

@ -9,6 +9,15 @@ To use it, add `yarn` to the plugins array in your zshrc file:
plugins=(... yarn)
```
## Global scripts directory
It also adds `yarn` global scripts dir (commonly `~/.yarn/bin`) to the `$PATH`.
To disable this feature, set the following style in your `.zshrc`:
```zsh
zstyle ':omz:plugins:yarn' global-path false
```
## Aliases
| Alias | Command | Description |

View file

@ -1,12 +1,14 @@
# Skip yarn call if default global bin dir exists
[[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)"
if zstyle -T ':omz:plugins:yarn' global-path; then
# Skip yarn call if default global bin dir exists
[[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)"
# Add yarn bin directory to $PATH if it exists and not already in $PATH
[[ $? -eq 0 ]] \
&& [[ -d "$bindir" ]] \
&& (( ! ${path[(Ie)$bindir]} )) \
&& path+=("$bindir")
unset bindir
# Add yarn bin directory to $PATH if it exists and not already in $PATH
[[ $? -eq 0 ]] \
&& [[ -d "$bindir" ]] \
&& (( ! ${path[(Ie)$bindir]} )) \
&& path+=("$bindir")
unset bindir
fi
alias y="yarn"
alias ya="yarn add"

View file

@ -1,3 +0,0 @@
# zsh_reload plugin
**This plugin is deprecated.** Use `omz reload` or `exec zsh` instead.

View file

@ -1,7 +0,0 @@
print ${(%):-"%F{yellow}The \`zsh_reload\` plugin is deprecated and will be removed."}
print ${(%):-"Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f"}
src() {
print ${(%):-"%F{yellow}$0 is deprecated. Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f\n"}
omz reload
}

View file

@ -16,7 +16,7 @@ ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
bureau_git_branch () {
bureau_git_info () {
local ref
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
@ -25,20 +25,21 @@ bureau_git_branch () {
bureau_git_status() {
local result gitstatus
gitstatus="$(command git status --porcelain -b 2>/dev/null)"
# check status of files
gitstatus=$(command git status --porcelain -b 2> /dev/null)
if [[ -n "$gitstatus" ]]; then
if $(echo "$gitstatus" | command grep -q '^[AMRD]. '); then
local gitfiles="$(tail -n +2 <<< "$gitstatus")"
if [[ -n "$gitfiles" ]]; then
if [[ "$gitfiles" =~ $'(^|\n)[AMRD]. ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_STAGED"
fi
if $(echo "$gitstatus" | command grep -q '^.[MTD] '); then
if [[ "$gitfiles" =~ $'(^|\n).[MTD] ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
if $(echo "$gitstatus" | command grep -q -E '^\?\? '); then
if [[ "$gitfiles" =~ $'(^|\n)\\?\\? ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
if $(echo "$gitstatus" | command grep -q '^UU '); then
if [[ "$gitfiles" =~ $'(^|\n)UU ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
else
@ -46,17 +47,19 @@ bureau_git_status() {
fi
# check status of local repository
if $(echo "$gitstatus" | command grep -q '^## .*ahead'); then
local gitbranch="$(head -n 1 <<< "$gitstatus")"
if [[ "$gitbranch" =~ '^## .*ahead' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
if $(echo "$gitstatus" | command grep -q '^## .*behind'); then
if [[ "$gitbranch" =~ '^## .*behind' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
if $(echo "$gitstatus" | command grep -q '^## .*diverged'); then
if [[ "$gitbranch" =~ '^## .*diverged' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi
if $(command git rev-parse --verify refs/stash &> /dev/null); then
# check if there are stashed changes
if command git rev-parse --verify refs/stash &> /dev/null; then
result+="$ZSH_THEME_GIT_PROMPT_STASHED"
fi
@ -64,21 +67,22 @@ bureau_git_status() {
}
bureau_git_prompt() {
local gitbranch=$(bureau_git_branch)
local gitstatus=$(bureau_git_status)
local info
if [[ -z "$gitbranch" ]]; then
# check git information
local gitinfo=$(bureau_git_info)
if [[ -z "$gitinfo" ]]; then
return
fi
info="${gitbranch:gs/%/%%}"
# quote % in git information
local output="${gitinfo:gs/%/%%}"
# check git status
local gitstatus=$(bureau_git_status)
if [[ -n "$gitstatus" ]]; then
info+=" $gitstatus"
output+=" $gitstatus"
fi
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${output}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
@ -99,19 +103,14 @@ get_space () {
local STR=$1$2
local zero='%([BSUbfksu]|([FB]|){*})'
local LENGTH=${#${(S%%)STR//$~zero/}}
local SPACES=""
(( LENGTH = ${COLUMNS} - $LENGTH - 1))
local SPACES=$(( COLUMNS - LENGTH - ${ZLE_RPROMPT_INDENT:-1} ))
for i in {0..$LENGTH}
do
SPACES="$SPACES "
done
echo $SPACES
(( SPACES > 0 )) || return
printf ' %.0s' {1..$SPACES}
}
_1LEFT="$_USERNAME $_PATH"
_1RIGHT="[%*] "
_1RIGHT="[%*]"
bureau_precmd () {
_1SPACES=`get_space $_1LEFT $_1RIGHT`

View file

@ -46,6 +46,16 @@
# is shown (see vcs_action_glyph variable, default: chevron).
# ------------------------------------------------------------------------------
(( ${+functions[emotty]} )) || {
echo "error: the emotty theme requires the emotty plugin" >&2
return 1
}
(( ${+emoji} )) || {
echo "error: the emotty theme requires the emoji plugin" >&2
return 1
}
user_prompt="$(emotty)"
root_prompt="$emoji[skull]"
warn_prompt="$emoji[collision_symbol]"

View file

@ -30,6 +30,6 @@ function mygit() {
function retcode() {}
# alternate prompt with git & hg
PROMPT=$'%{$fg_bold[blue]%}┌─[%{$fg_bold[green]%}%n%b%{$fg[black]%}@%{$fg[cyan]%}%m%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%{$fg_bold[white]%}%~%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%b%{$fg[yellow]%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{$fg_bold[blue]%}]
PROMPT=$'%{$fg_bold[blue]%}┌─[%{$fg_bold[green]%}%n%b%{$fg[black]%}@%{$fg[cyan]%}%m%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%{$fg_bold[default]%}%~%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%b%{$fg[yellow]%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{$fg_bold[blue]%}]
%{$fg_bold[blue]%}└─[%{$fg_bold[magenta]%}%?$(retcode)%{$fg_bold[blue]%}] <$(mygit)$(hg_prompt_info)>%{$reset_color%} '
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '

View file

@ -49,7 +49,7 @@ local venv_info='$(virtenv_prompt)'
YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}"
YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%"
virtenv_prompt() {
[[ -n ${VIRTUAL_ENV} ]] || return
[[ -n "${VIRTUAL_ENV:-}" ]] || return
echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}"
}

View file

@ -23,8 +23,7 @@ TYPES=(
test "Testing"
)
#* Types that will be displayed in their own section,
#* in the order specified here.
#* Types that will be displayed in their own section, in the order specified here.
local -a MAIN_TYPES
MAIN_TYPES=(feat fix perf docs)
@ -34,7 +33,8 @@ OTHER_TYPES=(refactor style other)
#* Commit types that don't appear in $MAIN_TYPES nor $OTHER_TYPES
#* will not be displayed and will simply be ignored.
local -a IGNORED_TYPES
IGNORED_TYPES=(${${${(@k)TYPES}:|MAIN_TYPES}:|OTHER_TYPES})
############################
# COMMIT PARSING UTILITIES #
@ -139,7 +139,7 @@ function parse-commit {
# [BREAKING CHANGE: warning]
# commits holds the commit type
commits[$hash]="$(commit:type "$subject")"
types[$hash]="$(commit:type "$subject")"
# scopes holds the commit scope
scopes[$hash]="$(commit:scope "$subject")"
# subjects holds the commit subject
@ -164,26 +164,32 @@ function parse-commit {
function display-release {
# This function uses the following globals: output, version,
# commits (A), subjects (A), scopes (A), breaking (A) and reverts (A).
# types (A), subjects (A), scopes (A), breaking (A) and reverts (A).
#
# - output is the output format to use when formatting (raw|text|md)
# - version is the version in which the commits are made
# - commits, subjects, scopes, breaking, and reverts are associative arrays
# - types, subjects, scopes, breaking, and reverts are associative arrays
# with commit hashes as keys
# Remove commits that were reverted
local hash rhash
for hash rhash in ${(kv)reverts}; do
if (( ${+commits[$rhash]} )); then
if (( ${+types[$rhash]} )); then
# Remove revert commit
unset "commits[$hash]" "subjects[$hash]" "scopes[$hash]" "breaking[$hash]"
unset "types[$hash]" "subjects[$hash]" "scopes[$hash]" "breaking[$hash]"
# Remove reverted commit
unset "commits[$rhash]" "subjects[$rhash]" "scopes[$rhash]" "breaking[$rhash]"
unset "types[$rhash]" "subjects[$rhash]" "scopes[$rhash]" "breaking[$rhash]"
fi
done
# Remove commits from ignored types unless it has breaking change information
for hash in ${(k)types[(R)${(j:|:)IGNORED_TYPES}]}; do
(( ! ${+breaking[$hash]} )) || continue
unset "types[$hash]" "subjects[$hash]" "scopes[$hash]"
done
# If no commits left skip displaying the release
if (( $#commits == 0 )); then
if (( $#types == 0 )); then
return
fi
@ -313,7 +319,7 @@ function display-release {
local hash type="$1"
local -a hashes
hashes=(${(k)commits[(R)$type]})
hashes=(${(k)types[(R)$type]})
# If no commits found of type $type, go to next type
(( $#hashes != 0 )) || return 0
@ -330,7 +336,7 @@ function display-release {
# Commits made under types considered other changes
local -A changes
changes=(${(kv)commits[(R)${(j:|:)OTHER_TYPES}]})
changes=(${(kv)types[(R)${(j:|:)OTHER_TYPES}]})
# If no commits found under "other" types, don't display anything
(( $#changes != 0 )) || return 0
@ -388,7 +394,7 @@ function main {
fi
# Commit classification arrays
local -A commits subjects scopes breaking reverts
local -A types subjects scopes breaking reverts
local truncate=0 read_commits=0
local version tag
local hash refs subject body
@ -441,7 +447,7 @@ function main {
# Output previous release
display-release
# Reinitialize commit storage
commits=()
types=()
subjects=()
scopes=()
breaking=()

View file

@ -89,6 +89,23 @@ function update_ohmyzsh() {
fi
}
function has_typed_input() {
# Created by Philippe Troin <phil@fifi.org>
# https://zsh.org/mla/users/2022/msg00062.html
emulate -L zsh
zmodload zsh/zselect
{
local termios=$(stty --save)
stty -icanon
zselect -t 0 -r 0
return $?
} always {
stty $termios
}
}
() {
emulate -L zsh
@ -146,26 +163,35 @@ function update_ohmyzsh() {
return
fi
# Ask for confirmation before updating unless in auto mode
# Don't ask for confirmation before updating if in auto mode
if [[ "$update_mode" = auto ]]; then
update_ohmyzsh
elif [[ "$update_mode" = reminder ]]; then
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
else
# input sink to swallow all characters typed before the prompt
# and add a newline if there wasn't one after characters typed
while read -t -k 1 option; do true; done
[[ "$option" != ($'\n'|"") ]] && echo
echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
read -r -k 1 option
[[ "$option" != $'\n' ]] && echo
case "$option" in
[yY$'\n']) update_ohmyzsh ;;
[nN]) update_last_updated_file ;&
*) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
esac
return $?
fi
# If in reminder mode show reminder and exit
if [[ "$update_mode" = reminder ]]; then
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
return 0
fi
# If user has typed input, show reminder and exit
if has_typed_input; then
echo
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
return 0
fi
# Ask for confirmation and only update on 'y', 'Y' or Enter
# Otherwise just show a reminder for how to update
echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
read -r -k 1 option
[[ "$option" = $'\n' ]] || echo
case "$option" in
[yY$'\n']) update_ohmyzsh ;;
[nN]) update_last_updated_file ;&
*) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
esac
}
unset update_mode

View file

@ -37,6 +37,13 @@
#
set -e
# Make sure important variables exist if not already defined
#
# $USER is defined by login(1) which is not always executed (e.g. containers)
# POSIX: https://pubs.opengroup.org/onlinepubs/009695299/utilities/id.html
USER=${USER:-$(id -u -n)}
# Track if $ZSH was provided
custom_zsh=${ZSH:+yes}
@ -51,9 +58,6 @@ CHSH=${CHSH:-yes}
RUNZSH=${RUNZSH:-yes}
KEEP_ZSHRC=${KEEP_ZSHRC:-no}
# Sane defaults
USER=${USER:-$(whoami)}
command_exists() {
command -v "$@" >/dev/null 2>&1
@ -263,13 +267,19 @@ setup_ohmyzsh() {
exit 1
fi
git clone -c core.eol=lf -c core.autocrlf=false \
-c fsck.zeroPaddedFilemode=ignore \
-c fetch.fsck.zeroPaddedFilemode=ignore \
-c receive.fsck.zeroPaddedFilemode=ignore \
-c oh-my-zsh.remote=origin \
-c oh-my-zsh.branch="$BRANCH" \
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
# Manual clone with git config options to support git < v1.7.2
git init "$ZSH" && cd "$ZSH" \
&& git config core.eol lf \
&& git config core.autocrlf false \
&& git config fsck.zeroPaddedFilemode ignore \
&& git config fetch.fsck.zeroPaddedFilemode ignore \
&& git config receive.fsck.zeroPaddedFilemode ignore \
&& git config oh-my-zsh.remote origin \
&& git config oh-my-zsh.branch "$BRANCH" \
&& git remote add origin "$REMOTE" \
&& git fetch --depth=1 origin \
&& git checkout -b "$BRANCH" "origin/$BRANCH" || {
rm -rf "$ZSH"
fmt_error "git clone of oh-my-zsh repo failed"
exit 1
}