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 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal 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. 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 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 ## Utility functions
@ -299,10 +302,8 @@ multi == 1 && length(\$0) > 0 {
# Restart the zsh session if there were no errors # Restart the zsh session if there were no errors
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}." _omz::log info "plugins disabled: ${(j:, :)dis_plugins}."
# Old zsh versions don't have ZSH_ARGZERO # Only reload zsh if run in an interactive session
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" [[ ! -o interactive ]] || _omz::reload
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
} }
function _omz::plugin::enable { function _omz::plugin::enable {
@ -375,10 +376,8 @@ multi == 1 && /^[^#]*\)/ {
# Restart the zsh session if there were no errors # Restart the zsh session if there were no errors
_omz::log info "plugins enabled: ${(j:, :)add_plugins}." _omz::log info "plugins enabled: ${(j:, :)add_plugins}."
# Old zsh versions don't have ZSH_ARGZERO # Only reload zsh if run in an interactive session
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" [[ ! -o interactive ]] || _omz::reload
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
} }
function _omz::plugin::info { function _omz::plugin::info {
@ -574,7 +573,7 @@ function _omz::pr::test {
# Rebase pull request branch against the current master # Rebase pull request branch against the current master
_omz::log info "rebasing PR #$1..." _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 command git rebase --abort &>/dev/null
_omz::log warn "could not rebase PR #$1 on top of master." _omz::log warn "could not rebase PR #$1 on top of master."
_omz::log warn "you might not see the latest stable changes." _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 # Restart the zsh session if there were no errors
_omz::log info "'$1' theme set correctly." _omz::log info "'$1' theme set correctly."
# Old zsh versions don't have ZSH_ARGZERO # Only reload zsh if run in an interactive session
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" [[ ! -o interactive ]] || _omz::reload
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
} }
function _omz::theme::use { 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) (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# Check for updates on initial load... # Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then if [[ "$DISABLE_AUTO_UPDATE" != true ]]; then
source $ZSH/tools/check_for_upgrade.sh source "$ZSH/tools/check_for_upgrade.sh"
fi fi
# Initializes Oh My Zsh # Initializes Oh My Zsh
# add a function path # 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. # Load all stock functions (from $fpath files) called below.
autoload -U compaudit compinit autoload -U compaudit compinit
@ -75,7 +75,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom" ZSH_CUSTOM="$ZSH/custom"
fi fi
is_plugin() { is_plugin() {
local base_dir=$1 local base_dir=$1
local name=$2 local name=$2
@ -86,10 +85,10 @@ is_plugin() {
# Add all defined plugins to fpath. This must be done # Add all defined plugins to fpath. This must be done
# before running compinit. # before running compinit.
for plugin ($plugins); do for plugin ($plugins); do
if is_plugin $ZSH_CUSTOM $plugin; then if is_plugin "$ZSH_CUSTOM" "$plugin"; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath) fpath=("$ZSH_CUSTOM/plugins/$plugin" $fpath)
elif is_plugin $ZSH $plugin; then elif is_plugin "$ZSH" "$plugin"; then
fpath=($ZSH/plugins/$plugin $fpath) fpath=("$ZSH/plugins/$plugin" $fpath)
else else
echo "[oh-my-zsh] plugin '$plugin' not found" echo "[oh-my-zsh] plugin '$plugin' not found"
fi fi
@ -98,14 +97,14 @@ done
# Figure out the SHORT hostname # Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then if [[ "$OSTYPE" = darwin* ]]; then
# macOS's $HOST changes with dhcp, etc. Use ComputerName if possible. # 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 else
SHORT_HOST=${HOST/.*/} SHORT_HOST="${HOST/.*/}"
fi fi
# Save the location of the current completion dump file. # Save the location of the current completion dump file.
if [ -z "$ZSH_COMPDUMP" ]; then if [[ -z "$ZSH_COMPDUMP" ]]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi fi
# Construct zcompdump OMZ metadata # Construct zcompdump OMZ metadata
@ -119,15 +118,15 @@ if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
zcompdump_refresh=1 zcompdump_refresh=1
fi fi
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
source $ZSH/lib/compfix.zsh source "$ZSH/lib/compfix.zsh"
# If completion insecurities exist, warn the user # If completion insecurities exist, warn the user
handle_completion_insecurities handle_completion_insecurities
# Load only from secure directories # Load only from secure directories
compinit -i -C -d "${ZSH_COMPDUMP}" compinit -i -C -d "$ZSH_COMPDUMP"
else else
# If the user wants it, load from all found directories # If the user wants it, load from all found directories
compinit -u -C -d "${ZSH_COMPDUMP}" compinit -u -C -d "$ZSH_COMPDUMP"
fi fi
# Append zcompdump metadata if missing # Append zcompdump metadata if missing
@ -140,40 +139,48 @@ $zcompdump_revision
$zcompdump_fpath $zcompdump_fpath
EOF EOF
fi fi
unset zcompdump_revision zcompdump_fpath zcompdump_refresh unset zcompdump_revision zcompdump_fpath zcompdump_refresh
# Load all of the config files in ~/oh-my-zsh that end in .zsh # 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 # TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do for config_file ("$ZSH"/lib/*.zsh); do
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" custom_config_file="$ZSH_CUSTOM/lib/${config_file:t}"
[ -f "${custom_config_file}" ] && config_file=${custom_config_file} [[ -f "$custom_config_file" ]] && config_file="$custom_config_file"
source $config_file source "$config_file"
done done
unset custom_config_file
# Load all of the plugins that were defined in ~/.zshrc # Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do for plugin ($plugins); do
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then if [[ -f "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh" ]]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh source "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh"
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then elif [[ -f "$ZSH/plugins/$plugin/$plugin.plugin.zsh" ]]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh source "$ZSH/plugins/$plugin/$plugin.plugin.zsh"
fi fi
done done
unset plugin
# Load all of your custom configurations from custom/ # Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do for config_file ("$ZSH_CUSTOM"/*.zsh(N)); do
source $config_file source "$config_file"
done done
unset config_file unset config_file
# Load the theme # Load the theme
if [ ! "$ZSH_THEME" = "" ]; then is_theme() {
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then 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" 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" source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else elif is_theme "$ZSH/themes" "$ZSH_THEME"; then
source "$ZSH/themes/$ZSH_THEME.zsh-theme" source "$ZSH/themes/$ZSH_THEME.zsh-theme"
else
echo "[oh-my-zsh] theme '$ZSH_THEME' not found"
fi fi
fi fi

View file

@ -4,8 +4,8 @@ if (( ${+commands[op]} )); then
fi fi
# opswd puts the password of the named service into the clipboard. If there's a # 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 # one time password, it will be copied into the clipboard after 10 seconds. The
# clipboard is cleared after another 10 seconds. # clipboard is cleared after another 20 seconds.
function opswd() { function opswd() {
if [[ $# -lt 1 ]]; then if [[ $# -lt 1 ]]; then
echo "Usage: opswd <service>" 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/' bash_completion='/usr/share/bash-completion/completions/'
locations=( locations=(
"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash "${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash
"$HOME/.local/share/bash-completion/completions/git" "$HOME/.local/share/bash-completion/completions/git"
'/usr/local/share/bash-completion/completions/git'
"$bash_completion/git" "$bash_completion/git"
'/etc/bash_completion.d/git' # old debian '/etc/bash_completion.d/git' # old debian
) )
@ -51,13 +52,20 @@ functions[complete]="$old_complete"
__gitcompadd () __gitcompadd ()
{ {
compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0 compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0
} }
__gitcomp () __gitcomp ()
{ {
emulate -L zsh emulate -L zsh
IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }"
}
__gitcomp_opts ()
{
emulate -L zsh
local cur_="${3-$cur}" local cur_="${3-$cur}"
[[ "$cur_" == *= ]] && return [[ "$cur_" == *= ]] && return
@ -70,7 +78,7 @@ __gitcomp ()
break break
fi fi
if [[ -z "${4-}" ]]; then if [[ -z "${4+set}" ]]; then
case $c in case $c in
*=) c="${c%=}"; sfx="=" ;; *=) c="${c%=}"; sfx="=" ;;
*.) sfx="" ;; *.) sfx="" ;;
@ -79,7 +87,7 @@ __gitcomp ()
else else
sfx="$4" sfx="$4"
fi fi
__gitcompadd "$c" "${2-}" "$sfx" -q __gitcompadd "$c" "${2-}" "$sfx"
done done
} }
@ -87,7 +95,10 @@ __gitcomp_nl ()
{ {
emulate -L zsh 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 () __gitcomp_file ()
@ -107,21 +118,6 @@ __gitcomp_file_direct ()
__gitcomp_file "$1" "" __gitcomp_file "$1" ""
} }
__gitcomp_nl_append ()
{
__gitcomp_nl "$@"
}
__gitcomp_direct_append ()
{
__gitcomp_direct "$@"
}
_git_zsh ()
{
__gitcomp "v1.2"
}
__git_complete_command () __git_complete_command ()
{ {
emulate -L zsh emulate -L zsh
@ -206,9 +202,7 @@ __git_zsh_main ()
{ {
local curcontext="$curcontext" state state_descr line local curcontext="$curcontext" state state_descr line
typeset -A opt_args typeset -A opt_args
local -a orig_words __git_C_args local -a __git_C_args
orig_words=( ${words[@]} )
_arguments -C \ _arguments -C \
'(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ '(-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 emulate ksh -c __git_complete_config_variable_name_and_value
;; ;;
(arg) (arg)
local command="${words[1]}" __git_dir local command="${words[1]}" __git_dir __git_cmd_idx=1
if (( $+opt_args[--bare] )); then if (( $+opt_args[--bare] )); then
__git_dir='.' __git_dir='.'
@ -259,7 +253,7 @@ __git_zsh_main ()
(( $+opt_args[--help] )) && command='help' (( $+opt_args[--help] )) && command='help'
words=( ${orig_words[@]} ) words=( git ${words[@]} )
__git_zsh_bash_func $command __git_zsh_bash_func $command
;; ;;
@ -269,7 +263,7 @@ __git_zsh_main ()
_git () _git ()
{ {
local _ret=1 local _ret=1
local cur cword prev local cur cword prev __git_cmd_idx=0
cur=${words[CURRENT]} cur=${words[CURRENT]}
prev=${words[CURRENT-1]} 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" done <<< "$output"
# parse configuration values # parse configuration values
local option
for option in ${GIT_PS1_SHOWUPSTREAM}; do for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in case "$option" in
git|svn) upstream="$option" ;; git|svn) upstream="$option" ;;
@ -432,8 +433,8 @@ __git_ps1 ()
fi fi
local sparse="" local sparse=""
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] && if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ -z "${GIT_PS1_OMITSPARSESTATE}" ] && [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
sparse="|SPARSE" sparse="|SPARSE"
fi fi
@ -542,7 +543,7 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}" u="%${ZSH_VERSION+%}"
fi fi
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] && if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
h="?" h="?"
fi fi

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
url="https://raw.githubusercontent.com/felipec/git-completion" 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 "${url}/v${version}/git-completion.zsh" &&
curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" && 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`. - `!` suffix: `--force --no-wait -y`.
- `ds` suffix: `--destroy-storage`. - `ds` suffix: `--destroy-storage`.
- `jsh` prefix means `juju show-*`.
### General ### General
| Alias | Command | Description | | Alias | Command | Description |
|--------|---------------------------------------------|--------------------------------------------------------| |---------|---------------------------------------------|--------------------------------------------------------|
| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution | | `j` | `juju` | The juju command |
| `jdlr` | `juju debug-log --ms --replay` | Replay entire log | | `jcld` | `juju clouds` | Lists all clouds with registered credentials |
| `jh` | `juju help` | Show help on a command or other topic | | `jclda` | `juju clouds --all` | Lists all clouds available to Juju |
| `jssl` | `juju juju show-status-log` | Output past statuses for the specified entity | | `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
| `jstj` | `juju status --format=json` | Show status in json format (more detailed) | | `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
| `jst` | `juju status --relations --storage --color` | Show status, including relations and storage, in color | | `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 ### Bootstrap
| Alias | Command | Description | | Alias | Command | Description |
|-------|---------------------------|-------------------------------------------| |---------|-------------------------------------|-------------------------------------------------------|
| `jb` | `juju bootstrap` | Initializing a Juju cloud environment | | `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s 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 ### Controller
| Alias | Command | Description | | 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` | Destroy a controller |
| `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | 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` | 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 | | `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 | | `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 | | `jsw` | `juju switch` | Select or identify the current controller and model |
### Model ### Model
@ -74,9 +86,9 @@ Naming convention:
| `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage | | `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 | | `jrp` | `juju refresh --path` | Upgrade charm from local charm file |
| `jsa` | `juju scale-application` | Set the desired number of application units | | `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 | | `jssh` | `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 | | `jsshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
| `jsu` | `juju show-unit` | Displays information about a unit | | `jshu` | `juju show-unit` | Displays information about a unit |
### Storage ### Storage
@ -113,5 +125,6 @@ Naming convention:
- `jaddr <app_name> [unit_num]`: display app or unit IP address. - `jaddr <app_name> [unit_num]`: display app or unit IP address.
- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data. - `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 - `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval
(default: 5s); you may pass additional arguments to `watch`. (default: 5s); you may pass additional arguments to `watch`.

View file

@ -16,12 +16,22 @@ unset completion_file
# Generally, # # Generally, #
# - `!` means --force --no-wait -y # # - `!` means --force --no-wait -y #
# - `ds` suffix means --destroy-storage # # - `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\"\ alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\
--config update-status-hook-interval=\"60m\"" --config update-status-hook-interval=\"60m\""
alias jb='juju bootstrap' 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 jbm='juju bootstrap microk8s'
alias jbmng='juju bootstrap --no-gui microk8s'
alias jc='juju config' 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'
alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y' alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y'
alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage' 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'
alias 'jrs!'='juju remove-storage --force' alias 'jrs!'='juju remove-storage --force'
alias jsa='juju scale-application' alias jsa='juju scale-application'
alias jsh='juju ssh' alias jsha='juju show-application'
alias jshc='juju ssh --container' alias jshc='juju show-controller'
alias jshm='juju show-model' 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 jstj='juju status --format=json'
alias jst='juju status --relations --storage --color' alias jst='juju status --relations --color'
alias jsu='juju show-unit' alias jsts='juju status --relations --storage --color'
alias jsw='juju switch' alias jsw='juju switch'
# ---------------------------------------------------------- # # ---------------------------------------------------------- #
@ -95,6 +108,37 @@ jaddr() {
fi 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 # Display app and unit relation data
jreld() { jreld() {
# $1 = relation name # $1 = relation name
@ -123,5 +167,6 @@ jreld() {
wjst() { wjst() {
local interval="${1:-5}" local interval="${1:-5}"
shift $(( $# > 0 )) 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' alias kaf='kubectl apply -f'
# Drop into an interactive terminal on a container # 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. # Manage configuration quickly to switch contexts between local, dev ad staging.
alias kcuc='kubectl config use-context' alias kcuc='kubectl config use-context'

View file

@ -3,7 +3,9 @@ typeset -g -A kubectx_mapping
function kubectx_prompt_info() { function kubectx_prompt_info() {
(( $+commands[kubectl] )) || return (( $+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 # use value in associative array if it exists
# otherwise fall back to the context name # 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 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.
## Deprecation ## Deprecation

View file

@ -1,7 +1,12 @@
# NPX Plugin if (( ! $+commands[npx] )); then
# https://www.npmjs.com/package/npx return
# Maintainer: Pooya Parsa <pooya@pi0.ir> fi
(( $+commands[npx] )) && { if ! npx_fallback_script="$(npx --shell-auto-fallback zsh 2>/dev/null)"; then
source <(npx --shell-auto-fallback zsh) 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 -u2 ${(%):-'%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 ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'}
(( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath) (( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath)
source "$ZSH/plugins/macos/macos.plugin.zsh" 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) 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. This plugin does not add any aliases.

View file

@ -17,3 +17,33 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
fi fi
rbw gen-completions zsh >| "$ZSH_CACHE_DIR/completions/_rbw" &| 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 ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
| ---------- | ---------------------- | -------------------------------------------------------- | | ---------- | -------------------------- | -------------------------------------------------------- |
| `ta` | tmux attach -t | Attach new tmux session to already running named session | | `ta` | tmux attach -t | Attach new tmux session to already running named session |
| `tad` | tmux attach -d -t | Detach named tmux session | | `tad` | tmux attach -d -t | Detach named tmux session |
| `ts` | tmux new-session -s | Create a new 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 | | `tl` | tmux list-sessions | Displays a list of running tmux sessions |
| `tksv` | tmux kill-server | Terminate all running tmux sessions | | `tksv` | tmux kill-server | Terminate all running tmux sessions |
| `tkss` | tmux kill-session -t | Terminate named running tmux session | | `tkss` | tmux kill-session -t | Terminate named running tmux session |
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session | | `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
| `tmuxconf` | `$EDITOR ~/.tmux.conf` | Open .tmux.conf file with an editor | | `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
## Configuration Variables ## Configuration Variables

View file

@ -3,16 +3,6 @@ if ! (( $+commands[tmux] )); then
return 1 return 1
fi 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 # CONFIGURATION VARIABLES
# Automatically start tmux # Automatically start tmux
: ${ZSH_TMUX_AUTOSTART:=false} : ${ZSH_TMUX_AUTOSTART:=false}
@ -40,6 +30,16 @@ alias tmuxconf='$EDITOR ~/.tmux.conf'
# Set -u option to support unicode # Set -u option to support unicode
: ${ZSH_TMUX_UNICODE:=false} : ${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 # Determine if the terminal supports 256 colors
if [[ $terminfo[colors] == 256 ]]; then if [[ $terminfo[colors] == 256 ]]; then
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR 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 if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then
# We've just left the repo, deactivate the environment # We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically # 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 fi
if [[ "$ENV_NAME" != "" ]]; then if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active # 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) 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 ## Aliases
| Alias | Command | Description | | Alias | Command | Description |

View file

@ -1,12 +1,14 @@
# Skip yarn call if default global bin dir exists if zstyle -T ':omz:plugins:yarn' global-path; then
[[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)" # 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 # Add yarn bin directory to $PATH if it exists and not already in $PATH
[[ $? -eq 0 ]] \ [[ $? -eq 0 ]] \
&& [[ -d "$bindir" ]] \ && [[ -d "$bindir" ]] \
&& (( ! ${path[(Ie)$bindir]} )) \ && (( ! ${path[(Ie)$bindir]} )) \
&& path+=("$bindir") && path+=("$bindir")
unset bindir unset bindir
fi
alias y="yarn" alias y="yarn"
alias ya="yarn add" 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_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
bureau_git_branch () { bureau_git_info () {
local ref local ref
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
@ -25,20 +25,21 @@ bureau_git_branch () {
bureau_git_status() { bureau_git_status() {
local result gitstatus local result gitstatus
gitstatus="$(command git status --porcelain -b 2>/dev/null)"
# check status of files # check status of files
gitstatus=$(command git status --porcelain -b 2> /dev/null) local gitfiles="$(tail -n +2 <<< "$gitstatus")"
if [[ -n "$gitstatus" ]]; then if [[ -n "$gitfiles" ]]; then
if $(echo "$gitstatus" | command grep -q '^[AMRD]. '); then if [[ "$gitfiles" =~ $'(^|\n)[AMRD]. ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_STAGED" result+="$ZSH_THEME_GIT_PROMPT_STAGED"
fi fi
if $(echo "$gitstatus" | command grep -q '^.[MTD] '); then if [[ "$gitfiles" =~ $'(^|\n).[MTD] ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED" result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi fi
if $(echo "$gitstatus" | command grep -q -E '^\?\? '); then if [[ "$gitfiles" =~ $'(^|\n)\\?\\? ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED" result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi fi
if $(echo "$gitstatus" | command grep -q '^UU '); then if [[ "$gitfiles" =~ $'(^|\n)UU ' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_UNMERGED" result+="$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi fi
else else
@ -46,17 +47,19 @@ bureau_git_status() {
fi fi
# check status of local repository # 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" result+="$ZSH_THEME_GIT_PROMPT_AHEAD"
fi fi
if $(echo "$gitstatus" | command grep -q '^## .*behind'); then if [[ "$gitbranch" =~ '^## .*behind' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_BEHIND" result+="$ZSH_THEME_GIT_PROMPT_BEHIND"
fi fi
if $(echo "$gitstatus" | command grep -q '^## .*diverged'); then if [[ "$gitbranch" =~ '^## .*diverged' ]]; then
result+="$ZSH_THEME_GIT_PROMPT_DIVERGED" result+="$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi 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" result+="$ZSH_THEME_GIT_PROMPT_STASHED"
fi fi
@ -64,21 +67,22 @@ bureau_git_status() {
} }
bureau_git_prompt() { bureau_git_prompt() {
local gitbranch=$(bureau_git_branch) # check git information
local gitstatus=$(bureau_git_status) local gitinfo=$(bureau_git_info)
local info if [[ -z "$gitinfo" ]]; then
if [[ -z "$gitbranch" ]]; then
return return
fi fi
info="${gitbranch:gs/%/%%}" # quote % in git information
local output="${gitinfo:gs/%/%%}"
# check git status
local gitstatus=$(bureau_git_status)
if [[ -n "$gitstatus" ]]; then if [[ -n "$gitstatus" ]]; then
info+=" $gitstatus" output+=" $gitstatus"
fi 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 STR=$1$2
local zero='%([BSUbfksu]|([FB]|){*})' local zero='%([BSUbfksu]|([FB]|){*})'
local LENGTH=${#${(S%%)STR//$~zero/}} local LENGTH=${#${(S%%)STR//$~zero/}}
local SPACES="" local SPACES=$(( COLUMNS - LENGTH - ${ZLE_RPROMPT_INDENT:-1} ))
(( LENGTH = ${COLUMNS} - $LENGTH - 1))
for i in {0..$LENGTH} (( SPACES > 0 )) || return
do printf ' %.0s' {1..$SPACES}
SPACES="$SPACES "
done
echo $SPACES
} }
_1LEFT="$_USERNAME $_PATH" _1LEFT="$_USERNAME $_PATH"
_1RIGHT="[%*] " _1RIGHT="[%*]"
bureau_precmd () { bureau_precmd () {
_1SPACES=`get_space $_1LEFT $_1RIGHT` _1SPACES=`get_space $_1LEFT $_1RIGHT`

View file

@ -46,6 +46,16 @@
# is shown (see vcs_action_glyph variable, default: chevron). # 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)" user_prompt="$(emotty)"
root_prompt="$emoji[skull]" root_prompt="$emoji[skull]"
warn_prompt="$emoji[collision_symbol]" warn_prompt="$emoji[collision_symbol]"

View file

@ -30,6 +30,6 @@ function mygit() {
function retcode() {} function retcode() {}
# alternate prompt with git & hg # 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%} ' %{$fg_bold[blue]%}└─[%{$fg_bold[magenta]%}%?$(retcode)%{$fg_bold[blue]%}] <$(mygit)$(hg_prompt_info)>%{$reset_color%} '
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' 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_PREFIX=" %{$fg[green]%}"
YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%" YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%"
virtenv_prompt() { virtenv_prompt() {
[[ -n ${VIRTUAL_ENV} ]] || return [[ -n "${VIRTUAL_ENV:-}" ]] || return
echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}" echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}"
} }

View file

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

View file

@ -89,6 +89,23 @@ function update_ohmyzsh() {
fi 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 emulate -L zsh
@ -146,26 +163,35 @@ function update_ohmyzsh() {
return return
fi 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 if [[ "$update_mode" = auto ]]; then
update_ohmyzsh update_ohmyzsh
elif [[ "$update_mode" = reminder ]]; then return $?
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
fi 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 unset update_mode

View file

@ -37,6 +37,13 @@
# #
set -e 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 # Track if $ZSH was provided
custom_zsh=${ZSH:+yes} custom_zsh=${ZSH:+yes}
@ -51,9 +58,6 @@ CHSH=${CHSH:-yes}
RUNZSH=${RUNZSH:-yes} RUNZSH=${RUNZSH:-yes}
KEEP_ZSHRC=${KEEP_ZSHRC:-no} KEEP_ZSHRC=${KEEP_ZSHRC:-no}
# Sane defaults
USER=${USER:-$(whoami)}
command_exists() { command_exists() {
command -v "$@" >/dev/null 2>&1 command -v "$@" >/dev/null 2>&1
@ -263,13 +267,19 @@ setup_ohmyzsh() {
exit 1 exit 1
fi fi
git clone -c core.eol=lf -c core.autocrlf=false \ # Manual clone with git config options to support git < v1.7.2
-c fsck.zeroPaddedFilemode=ignore \ git init "$ZSH" && cd "$ZSH" \
-c fetch.fsck.zeroPaddedFilemode=ignore \ && git config core.eol lf \
-c receive.fsck.zeroPaddedFilemode=ignore \ && git config core.autocrlf false \
-c oh-my-zsh.remote=origin \ && git config fsck.zeroPaddedFilemode ignore \
-c oh-my-zsh.branch="$BRANCH" \ && git config fetch.fsck.zeroPaddedFilemode ignore \
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { && 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" fmt_error "git clone of oh-my-zsh repo failed"
exit 1 exit 1
} }