1
0
mirror of https://github.com/DazAh/dotfiles synced 2026-05-21 18:25:46 +01:00

upgradeohmyzsh

This commit is contained in:
DazAh
2020-12-13 21:56:15 +00:00
parent d70caf476c
commit d997f114fa
52 changed files with 2509 additions and 1831 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ ZSH_THEME="agnoster"
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git npm fd docker-compose docker zsh-autosuggestions)
plugins=(git npm fd zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh
# User configuration
+2 -4
View File
@@ -4,7 +4,5 @@ root = true
end_of_line = lf
insert_final_newline = true
charset = utf-8
[*.sh]
indent_size = 4
indent_style = tab
indent_size = 2
indent_style = space
@@ -1 +1 @@
LAST_EPOCH=18360
LAST_EPOCH=18558
+1 -1
View File
@@ -1 +1 @@
3b1699b59527ee8095397b9909a37d55689a0481 branch 'master' of https://github.com/ohmyzsh/ohmyzsh
2a0ae3315db98d137de547e2cb9adfbc38263e6c branch 'master' of https://github.com/ohmyzsh/ohmyzsh
+1 -1
View File
@@ -1 +1 @@
fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0
db4fc1fcfe07b7bbc882e3850d9c94c88181374b
+2
View File
@@ -17,3 +17,5 @@
zeroPaddedFilemode = ignore
[receive "fsck"]
zeroPaddedFilemode = ignore
[oh-my-zsh]
lastVersion = b81dd43a0baf3d3984955a6547a7a6b4ac4757c0
@@ -29,3 +29,12 @@ e38099de96e8b62976354b468da1b21ec2d57f68 52f58785645c18aa88ea515d070a42bcfe97508
486857f709aa2fa229391097651e043b62d316e5 fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 DazAh <9095216+DazAh@users.noreply.github.com> 1587285078 +0100 rebase (pick): commit message
fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 DazAh <9095216+DazAh@users.noreply.github.com> 1587285078 +0100 rebase (finish): returning to refs/heads/master
fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 b4c49847e4ac5e235056165350c3a4be46244ce3 DazAh <9095216+DazAh@users.noreply.github.com> 1603487324 +0100 pull: Merge made by the 'recursive' strategy.
b4c49847e4ac5e235056165350c3a4be46244ce3 3b1699b59527ee8095397b9909a37d55689a0481 DazAh <9095216+DazAh@users.noreply.github.com> 1603488161 +0100 pull --rebase --stat origin master (start): checkout 3b1699b59527ee8095397b9909a37d55689a0481
3b1699b59527ee8095397b9909a37d55689a0481 e196f4412dc9a2216df1418b662ad4b07cd71ff8 DazAh <9095216+DazAh@users.noreply.github.com> 1603488162 +0100 pull --rebase --stat origin master (pick): deleted: cache/.gitkeep
e196f4412dc9a2216df1418b662ad4b07cd71ff8 db4fc1fcfe07b7bbc882e3850d9c94c88181374b DazAh <9095216+DazAh@users.noreply.github.com> 1603488162 +0100 pull --rebase --stat origin master (pick): commit message
db4fc1fcfe07b7bbc882e3850d9c94c88181374b db4fc1fcfe07b7bbc882e3850d9c94c88181374b DazAh <9095216+DazAh@users.noreply.github.com> 1603488162 +0100 pull --rebase --stat origin master (finish): returning to refs/heads/master
db4fc1fcfe07b7bbc882e3850d9c94c88181374b b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 DazAh <9095216+DazAh@users.noreply.github.com> 1607896397 +0000 pull: Merge made by the 'recursive' strategy.
b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 2a0ae3315db98d137de547e2cb9adfbc38263e6c DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (start): checkout 2a0ae3315db98d137de547e2cb9adfbc38263e6c
2a0ae3315db98d137de547e2cb9adfbc38263e6c b4ec9d8125e9ec565706ed32ab82434dd8f8d7dc DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (pick): deleted: cache/.gitkeep
b4ec9d8125e9ec565706ed32ab82434dd8f8d7dc 9366d477c4e361a30c32b9210db378cbe83a9f86 DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (pick): commit message
9366d477c4e361a30c32b9210db378cbe83a9f86 9366d477c4e361a30c32b9210db378cbe83a9f86 DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (finish): returning to refs/heads/master
@@ -22,3 +22,6 @@ e38099de96e8b62976354b468da1b21ec2d57f68 52f58785645c18aa88ea515d070a42bcfe97508
11ccf2bbf21a52536b408095af0e25574c7e62f5 5fc3c3fca4eb259cbb2a68435a11a8fffec6539f DazAh <9095216+DazAh@users.noreply.github.com> 1587285072 +0100 commit: commit message
5fc3c3fca4eb259cbb2a68435a11a8fffec6539f fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 DazAh <9095216+DazAh@users.noreply.github.com> 1587285078 +0100 rebase (finish): refs/heads/master onto 31eca46ee3b94ca84a038628e0bf6089a7488908
fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 b4c49847e4ac5e235056165350c3a4be46244ce3 DazAh <9095216+DazAh@users.noreply.github.com> 1603487324 +0100 pull: Merge made by the 'recursive' strategy.
b4c49847e4ac5e235056165350c3a4be46244ce3 db4fc1fcfe07b7bbc882e3850d9c94c88181374b DazAh <9095216+DazAh@users.noreply.github.com> 1603488162 +0100 pull --rebase --stat origin master (finish): refs/heads/master onto 3b1699b59527ee8095397b9909a37d55689a0481
db4fc1fcfe07b7bbc882e3850d9c94c88181374b b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 DazAh <9095216+DazAh@users.noreply.github.com> 1607896397 +0000 pull: Merge made by the 'recursive' strategy.
b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 9366d477c4e361a30c32b9210db378cbe83a9f86 DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (finish): refs/heads/master onto 2a0ae3315db98d137de547e2cb9adfbc38263e6c
@@ -19,3 +19,4 @@ e38099de96e8b62976354b468da1b21ec2d57f68 52f58785645c18aa88ea515d070a42bcfe97508
3e4d10c4f17b2fe57090a524d5d78781beda204a 05a38c8b99ea5bc54e7fdfc1cc1ea6d2729c05e5 DazAh <9095216+DazAh@users.noreply.github.com> 1580316594 +0000 pull --rebase --stat origin master: fast-forward
05a38c8b99ea5bc54e7fdfc1cc1ea6d2729c05e5 31eca46ee3b94ca84a038628e0bf6089a7488908 DazAh <9095216+DazAh@users.noreply.github.com> 1587285078 +0100 pull --rebase --stat origin master: fast-forward
31eca46ee3b94ca84a038628e0bf6089a7488908 3b1699b59527ee8095397b9909a37d55689a0481 DazAh <9095216+DazAh@users.noreply.github.com> 1603487324 +0100 pull: fast-forward
3b1699b59527ee8095397b9909a37d55689a0481 2a0ae3315db98d137de547e2cb9adfbc38263e6c DazAh <9095216+DazAh@users.noreply.github.com> 1607896397 +0000 pull: fast-forward
@@ -1 +1 @@
b4c49847e4ac5e235056165350c3a4be46244ce3
9366d477c4e361a30c32b9210db378cbe83a9f86
@@ -1 +1 @@
3b1699b59527ee8095397b9909a37d55689a0481
2a0ae3315db98d137de547e2cb9adfbc38263e6c
Binary file not shown.
@@ -1,4 +1,7 @@
# Plugin owners
plugins/aws/ @maksyms
plugins/genpass/ @atoponce
plugins/git-lfs/ @vietduc01100001
plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg
plugins/git-lfs/ @vietduc01100001
plugins/wp-cli/ @joshmedeski
@@ -1,7 +1,7 @@
---
name: Feature request
about: Suggest a feature for Oh My Zsh
labels: 'feature'
labels: 'Feature'
---
@@ -1,7 +1,7 @@
---
name: Support
about: Request support for any problem you're having with Oh My Zsh
labels: 'support'
labels: 'Support'
---
+2 -10
View File
@@ -9,17 +9,8 @@ function uninstall_oh_my_zsh() {
}
function upgrade_oh_my_zsh() {
if (( $+functions[_omz::update] )); then
echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
fi
# Run update script
env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
# Update last updated file
zmodload zsh/datetime
echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
# Remove update lock if it exists
command rm -rf "$ZSH/log/update.lock"
omz update
}
function take() {
@@ -134,6 +125,7 @@ zmodload zsh/langinfo
# -P causes spaces to be encoded as '%20' instead of '+'
function omz_urlencode() {
emulate -L zsh
local -a opts
zparseopts -D -E -a opts r m P
local in_str=$1
+19 -6
View File
@@ -9,14 +9,27 @@ function __git_prompt_git() {
GIT_OPTIONAL_LOCKS=0 command git "$@"
}
# Outputs current branch info in prompt format
function git_prompt_info() {
local ref
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then
ref=$(__git_prompt_git symbolic-ref HEAD 2> /dev/null) || \
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
# If we are on a folder not tracked by git, get out.
# Otherwise, check for hide-info at global and local repository level
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
return 0
fi
local ref
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|| return 0
# Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info
local upstream
if (( ${+ZSH_THEME_GIT_SHOW_UPSTREAM} )); then
upstream=$(__git_prompt_git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" 2>/dev/null) \
&& upstream=" -> ${upstream}"
fi
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref}${upstream}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
# Checks if working tree is dirty
+3 -1
View File
@@ -6,7 +6,8 @@ function omz_history {
if [[ -n "$clear" ]]; then
# if -c provided, clobber the history file
echo -n >| "$HISTFILE"
echo >&2 History file deleted. Reload the session to see its effects.
fc -p "$HISTFILE"
echo >&2 History file deleted.
elif [[ -n "$list" ]]; then
# if -l provided, run as if calling `fc' directly
builtin fc "$@"
@@ -36,3 +37,4 @@ setopt hist_expire_dups_first # delete duplicates first when HISTFILE size excee
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
setopt share_history # share command history data
@@ -171,8 +171,7 @@ function paclist() {
}
function pacdisowned() {
emulate -L zsh
local tmp db fs
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
@@ -189,15 +188,14 @@ function pacdisowned() {
}
function pacmanallkeys() {
emulate -L zsh
curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \
awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \
xargs sudo pacman-key --recv-keys
}
function pacmansignkeys() {
emulate -L zsh
for key in $*; do
local key
for key in $@; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
@@ -207,13 +205,13 @@ function pacmansignkeys() {
if (( $+commands[xdg-open] )); then
function pacweb() {
pkg="$1"
infos="$(LANG=C pacman -Si "$pkg")"
local pkg="$1"
local infos="$(LANG=C pacman -Si "$pkg")"
if [[ -z "$infos" ]]; then
return
fi
repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
}
fi
@@ -15,6 +15,13 @@ plugins=(... aws)
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
Run `asp` without arguments to clear the profile.
* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by
assuming the role specified in the `<profile>` configuration. It supports MFA and sets
`$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It
requires the roles to be configured as per the
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
Run `acp` without arguments to clear the profile.
* `agp`: gets the current value of `$AWS_PROFILE`.
* `aws_change_access_key`: changes the AWS access key of a profile.
@@ -33,6 +40,36 @@ plugins=(... aws)
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
* ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
- ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
* ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
## Configuration
[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
### Scenario: IAM roles with a source profile and MFA authentication
Source profile credentials in `~/.aws/credentials`:
```
[source-profile-name]
aws_access_key_id = ...
aws_secret_access_key = ...
```
Role configuration in `~/.aws/config`:
```
[profile source-profile-name]
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
region = us-east-1
output = json
[profile profile-with-role]
role_arn = arn:aws:iam::9999999999999:role/myrole
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
source_profile = source-profile-name
region = us-east-1
output = json
```
@@ -23,31 +23,131 @@ function asp() {
export AWS_EB_PROFILE=$1
}
# AWS profile switch
function acp() {
if [[ -z "$1" ]]; then
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
echo AWS profile cleared.
return
fi
local -a available_profiles
available_profiles=($(aws_profiles))
if [[ -z "${available_profiles[(r)$1]}" ]]; then
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
return 1
fi
local profile="$1"
# Get fallback credentials for if the aws command fails or no command is run
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
local aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $profile)"
local aws_session_token="$(aws configure get aws_session_token --profile $profile)"
# First, if the profile has MFA configured, lets get the token and session duration
local mfa_serial="$(aws configure get mfa_serial --profile $profile)"
local sess_duration="$(aws configure get duration_seconds --profile $profile)"
if [[ -n "$mfa_serial" ]]; then
local -a mfa_opt
local mfa_token
echo -n "Please enter your MFA token for $mfa_serial: "
read -r mfa_token
if [[ -z "$sess_duration" ]]; then
echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
read -r sess_duration
fi
mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}")
# Now see whether we need to just MFA for the current role, or assume a different one
local role_arn="$(aws configure get role_arn --profile $profile)"
local sess_name="$(aws configure get role_session_name --profile $profile)"
if [[ -n "$role_arn" ]]; then
# Means we need to assume a specified role
aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
# Check whether external_id is configured to use while assuming the role
local external_id="$(aws configure get external_id --profile $profile)"
if [[ -n "$external_id" ]]; then
aws_command+=(--external-id "$external_id")
fi
# Get source profile to use to assume role
local source_profile="$(aws configure get source_profile --profile $profile)"
if [[ -z "$sess_name" ]]; then
sess_name="${source_profile:-profile}"
fi
aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}")
echo "Assuming role $role_arn using profile ${source_profile:-profile}"
else
# Means we only need to do MFA
aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
echo "Obtaining session token for profile $profile"
fi
# Format output of aws command for easier processing
aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
# Run the aws command to obtain credentials
local -a credentials
credentials=(${(ps:\t:)"$(${aws_command[@]})"})
if [[ -n "$credentials" ]]; then
aws_access_key_id="${credentials[1]}"
aws_secret_access_key="${credentials[2]}"
aws_session_token="${credentials[3]}"
fi
fi
# Switch to AWS profile
if [[ -n "${aws_access_key_id}" && -n "$aws_secret_access_key" ]]; then
export AWS_DEFAULT_PROFILE="$profile"
export AWS_PROFILE="$profile"
export AWS_EB_PROFILE="$profile"
export AWS_ACCESS_KEY_ID="$aws_access_key_id"
export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key"
if [[ -n "$aws_session_token" ]]; then
export AWS_SESSION_TOKEN="$aws_session_token"
else
unset AWS_SESSION_TOKEN
fi
echo "Switched to AWS Profile: $profile"
fi
}
function aws_change_access_key() {
if [[ -z "$1" ]]; then
echo "usage: $0 <profile>"
return 1
fi
echo Insert the credentials when asked.
echo "Insert the credentials when asked."
asp "$1" || return 1
AWS_PAGER="" aws iam create-access-key
AWS_PAGER="" aws configure --profile "$1"
echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`
echo Your current keys are:
echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
echo "Your current keys are:"
AWS_PAGER="" aws iam list-access-keys
}
function aws_profiles() {
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9@_\.-]*\).*/\1/'
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g'
}
function _aws_profiles() {
reply=($(aws_profiles))
}
compctl -K _aws_profiles asp aws_change_access_key
compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt
function aws_prompt_info() {
@@ -55,7 +155,7 @@ function aws_prompt_info() {
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
}
if [ "$SHOW_AWS_PROMPT" != false ]; then
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
fi
@@ -18,10 +18,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
}
function battery_pct() {
local battery_status="$(ioreg -rc AppleSmartBattery)"
local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status)
local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status)
echo $(( current * 100 / capacity ))
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
}
function battery_pct_remaining() {
@@ -16,3 +16,17 @@ You can also try to color other pages by prefixing the respective command with `
```zsh
colored git help clone
```
## Customization
The plugin declares global associative array `less_termcap`, which maps termcap capabilities to escape
sequences for the `less` pager. This mapping can be further customized by the user after the plugin is
loaded. Check out sources for more.
For example: `less_termcap[md]` maps to `LESS_TERMCAP_md` which is the escape sequence that tells `less`
how to print something in bold. It's currently shown in bold red, but if you want to change it, you
can redefine `less_termcap[md]` in your zshrc file, after OMZ is sourced:
```zsh
less_termcap[md]="${fg_bold[blue]}" # this tells less to print bold text in bold blue
```
@@ -1,34 +1,43 @@
if [[ "$OSTYPE" = solaris* ]]
then
if [[ ! -x "$HOME/bin/nroff" ]]
then
mkdir -p "$HOME/bin"
cat > "$HOME/bin/nroff" <<EOF
#!/bin/sh
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
shift
exec /usr/bin/nroff -u\$_NROFF_U "\$@"
fi
#-- Some other invocation of nroff
exec /usr/bin/nroff "\$@"
EOF
chmod +x "$HOME/bin/nroff"
fi
fi
# Requires colors autoload.
# See termcap(5).
# Set up once, and then reuse. This way it supports user overrides after the
# plugin is loaded.
typeset -AHg less_termcap
# bold & blinking mode
less_termcap[mb]="${fg_bold[red]}"
less_termcap[md]="${fg_bold[red]}"
less_termcap[me]="${reset_color}"
# standout mode
less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
less_termcap[se]="${reset_color}"
# underlining
less_termcap[us]="${fg_bold[green]}"
less_termcap[ue]="${reset_color}"
# Absolute path to this file's directory.
typeset __colored_man_pages_dir="${0:A:h}"
function colored() {
command env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER="${commands[less]:-$PAGER}" \
_NROFF_U=1 \
PATH="$HOME/bin:$PATH" \
"$@"
local -a environment
# Convert associative array to plain array of NAME=VALUE items.
local k v
for k v in "${(@kv)less_termcap}"; do
environment+=( "LESS_TERMCAP_${k}=${v}" )
done
# Prefer `less` whenever available, since we specifically configured
# environment for it.
environment+=( PAGER="${commands[less]:-$PAGER}" )
# See ./nroff script.
if [[ "$OSTYPE" = solaris* ]]; then
environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
fi
command env $environment "$@"
}
# Colorize man and dman/debman (from debian-goodies)
@@ -6,7 +6,8 @@ alias cless="colorize_less"
ZSH_COLORIZE_PLUGIN_PATH=$0:A
colorize_check_requirements() {
local available_tools=("chroma" "pygmentize")
local -a available_tools
available_tools=("chroma" "pygmentize")
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
if (( $+commands[pygmentize] )); then
@@ -2,7 +2,22 @@
# as seen in https://www.porcheron.info/command-not-found-for-zsh/
# this is installed in Ubuntu
[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handler {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "zsh: command not found: %s\n" "$1" >&2
return 127
fi
return 0
}
fi
# Arch Linux command-not-found support, you must have package pkgfile installed
# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
@@ -15,8 +30,7 @@ if [ -f /usr/libexec/pk-command-not-found ]; then
retval=127
[ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
[ ! -x /usr/libexec/packagekitd ] && runcnf=0
if [ $runcnf -eq 1 ]
then
if [ $runcnf -eq 1 ]; then
/usr/libexec/pk-command-not-found $@
retval=$?
fi
@@ -40,11 +40,13 @@ plugins=(... common-aliases)
| Alias | Command | Description |
|-------|-----------------------------------------------------|-----------------------------------------|
| fd | `find . -type d -name` | Find a directory with the given name |
| fd\* | `find . -type d -name` | Find a directory with the given name |
| ff | `find . -type f -name` | Find a file with the given name |
| grep | `grep --color` | Searches for a query string |
| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files |
\* Only if the [`fd`](https://github.com/sharkdp/fd) command isn't installed.
### Other Aliases
| Alias | Command | Description |
@@ -34,7 +34,7 @@ alias -g P="2>&1| pygmentize -l pytb"
alias dud='du -d 1 -h'
alias duf='du -sh *'
alias fd='find . -type d -name'
(( $+commands[fd] )) || alias fd='find . -type d -name'
alias ff='find . -type f -name'
alias h='history'
@@ -51,7 +51,7 @@ alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH, using Composer if available.
if (( $+commands[composer] )); then
autoload -Uz _store_cache _retrieve_cache
autoload -Uz _store_cache _retrieve_cache _cache_invalid
_retrieve_cache composer
@@ -154,10 +154,10 @@ unset -f setup_using_opensuse_package setup_using_debian_package setup_using_bas
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
if (( $+commands[rg] )); then
export FZF_DEFAULT_COMMAND='rg --files --hidden'
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
elif (( $+commands[fd] )); then
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
elif (( $+commands[ag] )); then
export FZF_DEFAULT_COMMAND='ag -l --hidden -g ""'
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
fi
fi
@@ -1,26 +1,29 @@
# Git auto-fetch
Automatically fetches all changes from all remotes while you are working in git-initialized directory.
Automatically fetches all changes from all remotes while you are working in a git-initialized directory.
#### Usage
Add `git-auto-fetch` to the plugins array in your zshrc file:
To use it, add `git-auto-fetch` to the plugins array in your zshrc file:
```shell
plugins=(... git-auto-fetch)
```
Every time you launch a command in your shell all remotes will be fetched in background.
By default autofetch will be triggered only if last fetch was done at least 60 seconds ago.
You can change fetch interval in your .zshrc:
```
## Usage
Every time the command prompt is shown all remotes will be fetched in the background. By default,
`git-auto-fetch` will be triggered only if the last auto-fetch was done at least 60 seconds ago.
You can change the fetch interval in your .zshrc:
```sh
GIT_AUTO_FETCH_INTERVAL=1200 # in seconds
```
Log of `git fetch --all` will be saved into `.git/FETCH_LOG`
A log of `git fetch --all` will be saved in `.git/FETCH_LOG`.
#### Toggle auto fetch per folder
If you are using mobile connection or for any other reason you can disable git-auto-fetch for any folder:
## Toggle auto-fetch per folder
If you are using a mobile connection or for any other reason you can disable git-auto-fetch
for any folder:
```shell
$ cd to/your/project
@@ -29,3 +32,19 @@ disabled
$ git-auto-fetch
enabled
```
## Caveats
Automatically fetching all changes defeats the purpose of `git push --force-with-lease`,
and makes it behave like `git push --force` in some cases. For example:
Consider that you made some changes and possibly rebased some stuff, which means you'll
need to use `--force-with-lease` to overwrite the remote history of a branch. Between the
time when you make the changes (maybe do a `git log`) and the time when you `git push`,
it's possible that someone else updates the branch you're working on.
If `git-auto-fetch` triggers then, you'll have fetched the remote changes without knowing
it, and even though you're running the push with `--force-with-lease`, git will overwrite
the recent changes because you already have them in your local repository. The
[`git push --force-with-lease` docs](https://git-scm.com/docs/git-push) talk about possible
solutions to this problem.
@@ -1,36 +1,61 @@
GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60}
# Default auto-fetch interval: 60 seconds
: ${GIT_AUTO_FETCH_INTERVAL:=60}
# Necessary for the git-fetch-all function
zmodload zsh/datetime zsh/stat
function git-fetch-all {
(`command git rev-parse --is-inside-work-tree 2>/dev/null` &&
dir=`command git rev-parse --git-dir` &&
[[ ! -f $dir/NO_AUTO_FETCH ]] &&
(( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) &&
(
# Get git root directory
if ! gitdir="$(command git rev-parse --git-dir 2>/dev/null)"; then
return 0
fi
# Do nothing if auto-fetch disabled
if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; then
return 0
fi
# Get time (seconds) when auto-fetch was last run
lastrun="$(zstat +mtime "$gitdir/FETCH_LOG" 2>/dev/null || echo 0)"
# Do nothing if not enough time has passed since last auto-fetch
if (( EPOCHSECONDS - lastrun < $GIT_AUTO_FETCH_INTERVAL )); then
return 0
fi
# Fetch all remotes (avoid ssh passphrase prompt)
GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
command git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &)
command git fetch --all 2>/dev/null &>! "$gitdir/FETCH_LOG"
) &|
}
function git-auto-fetch {
`command git rev-parse --is-inside-work-tree 2>/dev/null` || return
guard="`command git rev-parse --git-dir`/NO_AUTO_FETCH"
# Do nothing if not in a git repository
command git rev-parse --is-inside-work-tree &>/dev/null || return 0
(rm $guard 2>/dev/null &&
echo "${fg_bold[green]}enabled${reset_color}") ||
(touch $guard &&
echo "${fg_bold[red]}disabled${reset_color}")
}
# Override zle-line-init if it exists
if (( $+functions[zle-line-init] )); then
eval "override-git-auto-fetch-$(declare -f zle-line-init)"
function zle-line-init () {
git-fetch-all
override-git-auto-fetch-zle-line-init
}
# Remove or create guard file depending on its existence
local guard="$(command git rev-parse --git-dir)/NO_AUTO_FETCH"
if [[ -f "$guard" ]]; then
command rm "$guard" && echo "${fg_bold[green]}enabled${reset_color}"
else
function zle-line-init () {
git-fetch-all
}
command touch "$guard" && echo "${fg_bold[red]}disabled${reset_color}"
fi
}
zle -N zle-line-init
# zle-line-init widget (don't redefine if already defined)
(( ! ${+functions[_git-auto-fetch_zle-line-init]} )) || return 0
case "$widgets[zle-line-init]" in
# Simply define the function if zle-line-init doesn't yet exist
builtin|"") function _git-auto-fetch_zle-line-init() {
git-fetch-all
} ;;
# Override the current zle-line-init widget, calling the old one
user:*) zle -N _git-auto-fetch_orig_zle-line-init "${widgets[zle-line-init]#user:}"
function _git-auto-fetch_zle-line-init() {
git-fetch-all
zle _git-auto-fetch_orig_zle-line-init -- "$@"
} ;;
esac
zle -N zle-line-init _git-auto-fetch_zle-line-init
@@ -11,11 +11,11 @@ def get_tagname_or_hash():
"""return tagname if exists else hash"""
# get hash
hash_cmd = ['git', 'rev-parse', '--short', 'HEAD']
hash_ = check_output(hash_cmd).strip()
hash_ = check_output(hash_cmd).decode('utf-8').strip()
# get tagname
tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags']
tags = check_output(tags_cmd).split()
tags = check_output(tags_cmd).decode('utf-8').split()
if tags:
return tags[0] + ('+' if len(tags) > 1 else '')
@@ -31,11 +31,15 @@ function work_in_progress() {
# Check if main exists and use instead of master
function git_main_branch() {
if [[ -n "$(git branch --list main)" ]]; then
echo main
else
echo master
command git rev-parse --git-dir &>/dev/null || return
local branch
for branch in main trunk; do
if command git show-ref -q --verify refs/heads/$branch; then
echo $branch
return
fi
done
echo master
}
#
@@ -2,25 +2,24 @@
# zsh completion wrapper for git
#
# Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com>
# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
#
# You need git's bash completion script installed somewhere, by default it
# would be the location bash-completion uses.
# The recommended way to install this script is to make a copy of it as a
# file named '_git' inside any directory in your fpath.
#
# If your script is somewhere else, you can configure it on your ~/.zshrc:
#
# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
#
# The recommended way to install this script is to copy to '~/.zsh/_git', and
# then add the following to your ~/.zshrc file:
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
# and then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh $fpath)
complete ()
{
# do nothing
return 0
}
#
# You need git's bash completion script installed. By default bash-completion's
# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
#
# If your bash completion script is somewhere else, you can specify the
# location in your ~/.zshrc:
#
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
#
zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
@@ -28,18 +27,32 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle -s ":completion:*:*:git:*" script script
if [ -z "$script" ]; then
local -a locations
local e
local e bash_completion
bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) ||
bash_completion='/usr/share/bash-completion/completions/'
locations=(
"$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
'/etc/bash_completion.d/git' # fedora, old debian
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
'/usr/share/bash-completion/git' # gentoo
"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
"$HOME/.local/share/bash-completion/completions/git"
"$bash_completion/git"
'/etc/bash_completion.d/git' # old debian
)
for e in $locations; do
test -f $e && script="$e" && break
done
fi
ZSH_VERSION='' . "$script"
local old_complete="$functions[complete]"
functions[complete]=:
COMP_WORDBREAKS=':'
GIT_SOURCING_ZSH_COMPLETION=y . "$script"
functions[complete]="$old_complete"
__gitcompadd ()
{
compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
}
__gitcomp ()
{
@@ -47,59 +60,85 @@ __gitcomp ()
local cur_="${3-$cur}"
case "$cur_" in
--*=)
;;
*)
local c IFS=$' \t\n'
local -a array
[[ "$cur_" == *= ]] && return
local c IFS=$' \t\n' sfx
for c in ${=1}; do
c="$c${4-}"
if [[ $c == "--" ]]; then
[[ "$cur_" == --no-* ]] && continue
__gitcompadd "--no-..."
break
fi
if [[ -z "${4-}" ]]; then
case $c in
--*=*|*.) ;;
*) c="$c " ;;
*=) c="${c%=}"; sfx="=" ;;
*.) sfx="" ;;
*) sfx=" " ;;
esac
array+=("$c")
else
sfx="$4"
fi
__gitcompadd "$c" "${2-}" "$sfx" -q
done
compset -P '*[=:]'
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
;;
esac
}
__gitcomp_direct ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -Q -- ${=1} && _ret=0
}
__gitcomp_nl ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
}
__gitcomp_nl_append ()
{
emulate -L zsh
local IFS=$'\n'
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
}
__gitcomp_file ()
{
emulate -L zsh
local IFS=$'\n'
compadd -f -p "${2-}" -- ${(f)1} && _ret=0
}
__gitcomp_direct ()
{
__gitcomp_nl "$1" "" "" ""
}
__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
compset -P '*[=:]'
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
local command="$1"
local completion_func="_git_${command//-/_}"
if (( $+functions[$completion_func] )); then
emulate ksh -c $completion_func
return 0
elif emulate ksh -c "__git_support_parseopt_helper $command"; then
emulate ksh -c "__git_complete_common $command"
return 0
else
return 1
fi
}
__git_zsh_bash_func ()
@@ -108,14 +147,12 @@ __git_zsh_bash_func ()
local command=$1
local completion_func="_git_${command//-/_}"
declare -f $completion_func >/dev/null && $completion_func && return
__git_complete_command "$command" && return
local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then
words[1]=$expansion
completion_func="_git_${expansion//-/_}"
declare -f $completion_func >/dev/null && $completion_func
__git_complete_command "$expansion"
fi
}
@@ -140,9 +177,11 @@ __git_zsh_cmd_common ()
push:'update remote refs along with associated objects'
rebase:'forward-port local commits to the updated upstream head'
reset:'reset current HEAD to the specified state'
restore:'restore working tree files'
rm:'remove files from the working tree and from the index'
show:'show various types of objects'
status:'show the working tree status'
switch:'switch branches'
tag:'create, list, delete or verify a tag object signed with GPG')
_describe -t common-commands 'common commands' list && _ret=0
}
@@ -150,8 +189,9 @@ __git_zsh_cmd_common ()
__git_zsh_cmd_alias ()
{
local -a list
list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*})
_describe -t alias-commands 'aliases' list $* && _ret=0
list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.})
list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"})
_describe -t alias-commands 'aliases' list && _ret=0
}
__git_zsh_cmd_all ()
@@ -166,33 +206,43 @@ __git_zsh_main ()
{
local curcontext="$curcontext" state state_descr line
typeset -A opt_args
local -a orig_words
local -a orig_words __git_C_args
orig_words=( ${words[@]} )
_arguments -C \
'(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
'(-p --paginate)--no-pager[do not pipe git output into a pager]' \
'--git-dir=-[set the path to the repository]: :_directories' \
'--bare[treat the repository as a bare repository]' \
'(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
'(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \
'(--bare)--git-dir=[set the path to the repository]: :_directories' \
'(--git-dir)--bare[treat the repository as a bare repository]' \
'(- :)--version[prints the git suite version]' \
'--exec-path=-[path to where your core git programs are installed]:: :_directories' \
'--html-path[print the path where git''s HTML documentation is installed]' \
'--info-path[print the path where the Info files are installed]' \
'--man-path[print the manpath (see `man(1)`) for the man pages]' \
'--work-tree=-[set the path to the working tree]: :_directories' \
'--namespace=-[set the git namespace]' \
'--exec-path=[path to where your core git programs are installed]: :_directories' \
'(- :)--exec-path[print the path where your core git programs are installed]' \
'(- :)--html-path[print the path where git''s HTML documentation is installed]' \
'(- :)--info-path[print the path where the Info files are installed]' \
'(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \
'--work-tree=[set the path to the working tree]: :_directories' \
'--namespace=[set the git namespace]:' \
'--no-replace-objects[do not use replacement refs to replace git objects]' \
'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
'*-C[run as if git was started in the given path]: :_directories' \
'*-c[pass a configuration parameter to the command]: :->config' \
'(-): :->command' \
'(-)*:: :->arg' && return
case $state in
(command)
_alternative \
'alias-commands:alias:__git_zsh_cmd_alias' \
'common-commands:common:__git_zsh_cmd_common' \
'all-commands:all:__git_zsh_cmd_all' && _ret=0
_tags common-commands alias-commands all-commands
while _tags; do
_requested common-commands && __git_zsh_cmd_common
_requested alias-commands && __git_zsh_cmd_alias
_requested all-commands && __git_zsh_cmd_all
let _ret || break
done
;;
(config)
compset -P '*[=:]'
emulate ksh -c __git_complete_config_variable_name_and_value
;;
(arg)
local command="${words[1]}" __git_dir
@@ -200,9 +250,13 @@ __git_zsh_main ()
if (( $+opt_args[--bare] )); then
__git_dir='.'
else
__git_dir=${opt_args[--git-dir]}
__git_dir=${~opt_args[--git-dir]}
fi
for x in ${(s.:.)opt_args[-C]}; do
__git_C_args+=('-C' ${~x})
done
(( $+opt_args[--help] )) && command='help'
words=( ${orig_words[@]} )
@@ -227,6 +281,8 @@ _git ()
emulate ksh -c __${service}_main
elif (( $+functions[_${service}] )); then
emulate ksh -c _${service}
elif (( $+functions[_${service//-/_}] )); then
emulate ksh -c _${service//-/_}
fi
let _ret && _default && _ret=0
@@ -1,9 +1,8 @@
#!/bin/sh
url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion"
version="2.16.0"
url="https://raw.githubusercontent.com/felipec/git-completion"
version="1.2"
curl -s -o _git "${url}/git-completion.zsh?h=v${version}" &&
curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" &&
curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" &&
git apply updates.patch
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-prompt.sh "${url}/v${version}/git-prompt.sh"
File diff suppressed because it is too large Load Diff
@@ -70,6 +70,15 @@
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
# is SP.
#
# When there is an in-progress operation such as a merge, rebase,
# revert, cherry-pick, or bisect, the prompt will include information
# related to the operation, often in the form "|<OPERATION-NAME>".
#
# When the repository has a sparse-checkout, a notification of the form
# "|SPARSE" will be included in the prompt. This can be shortened to a
# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
# by setting GIT_PS1_OMITSPARSESTATE.
#
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
# find one, or @{upstream} otherwise. Once you have set
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
@@ -88,7 +97,8 @@
# If you would like a colored hint about the current dirty state, set
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
# the colored output of "git status -sb" and are available only when
# using __git_ps1 for PROMPT_COMMAND or precmd.
# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
# but always available in Zsh.
#
# If you would like __git_ps1 to do nothing in the case when the current
# directory is set up to be ignored by git, then set
@@ -286,6 +296,37 @@ __git_eread ()
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
}
# see if a cherry-pick or revert is in progress, if the user has committed a
# conflict resolution with 'git commit' in the middle of a sequence of picks or
# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
# the todo file.
__git_sequencer_status ()
{
local todo
if test -f "$g/CHERRY_PICK_HEAD"
then
r="|CHERRY-PICKING"
return 0;
elif test -f "$g/REVERT_HEAD"
then
r="|REVERTING"
return 0;
elif __git_eread "$g/sequencer/todo" todo
then
case "$todo" in
p[\ \ ]|pick[\ \ ]*)
r="|CHERRY-PICKING"
return 0
;;
revert[\ \ ]*)
r="|REVERTING"
return 0
;;
esac
fi
return 1
}
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# when called from PS1 using command substitution
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
@@ -390,6 +431,13 @@ __git_ps1 ()
return $exit
fi
local sparse=""
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
[ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
sparse="|SPARSE"
fi
local r=""
local b=""
local step=""
@@ -398,11 +446,7 @@ __git_ps1 ()
__git_eread "$g/rebase-merge/head-name" b
__git_eread "$g/rebase-merge/msgnum" step
__git_eread "$g/rebase-merge/end" total
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
else
r="|REBASE-m"
fi
r="|REBASE"
else
if [ -d "$g/rebase-apply" ]; then
__git_eread "$g/rebase-apply/next" step
@@ -417,10 +461,8 @@ __git_ps1 ()
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
r="|CHERRY-PICKING"
elif [ -f "$g/REVERT_HEAD" ]; then
r="|REVERTING"
elif __git_sequencer_status; then
:
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
@@ -467,6 +509,7 @@ __git_ps1 ()
local i=""
local s=""
local u=""
local h=""
local c=""
local p=""
@@ -499,6 +542,11 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}"
fi
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
h="?"
fi
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
__git_ps1_show_upstream
fi
@@ -519,8 +567,8 @@ __git_ps1 ()
b="\${__git_ps1_branch_name}"
fi
local f="$w$i$s$u"
local gitstring="$c$b${f:+$z$f}$r$p"
local f="$h$w$i$s$u"
local gitstring="$c$b${f:+$z$f}${sparse}$r$p"
if [ $pcmode = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then
@@ -1,32 +1,45 @@
# Hanami Plugin #
This plugin adds convenient ways to work with [Hanami](https://hanamirb.org/) via console.
# Hanami Plugin
This plugin adds convenient aliases to work with [Hanami](https://hanamirb.org/) via console.
It's inspired by Rails plugin, so if you've used it, you'll feel like home.
## Usage ##
To use it, add `hanami` to the plugins array in your zshrc file:
```zsh
plugins=(... hanami)
```
## Usage
For example, type `hc` into your console when you're within Hanami project directory to run
the application console. Have a look at available shortcuts below. You can read more about
these commands [on the official website](https://hanamirb.org/guides/command-line/applications/).
## Aliases ##
## Aliases
| Alias | Command | Description |
|-------|---------------------------|---------------------------------------------------------|
| HED | HANAMI_ENV=development | Set environment variable HANAMI_ENV to development |
| HEP | HANAMI_ENV=production | Set environment variable HANAMI_ENV to production |
| HET | HANAMI_ENV=test | Set environment variable HANAMI_ENV to test |
| hc | hanami console | Run application console |
| hd | hanami destroy | Remove specified hanami resource |
| hg | hanami generate | Create specified hanami resource |
| hgm | hanami generate migration | Create migration file |
| hs | hanami server | Launch server with hanami application |
| hsp | hanami server -p | Launch server with specified port |
| hr | hanami routes | List application routes |
| hdc | hanami db create | Create application database |
| hdd | hanami db drop | Delete application database |
| hdp | hanami db prepare | Prepare database for the current environment |
| hda | hanami db apply | Recreates a fresh schema after migrations (destructive) |
| hdv | hanami db version | Print current database version |
| hdrs | hdd && hdp | Drop and recreate application database |
| hdtp | HET hdp | Actualize test environment database |
| hrg | hr &#124; grep | Grep hanami routes with specified pattern |
|-------|-----------------------------|---------------------------------------------------------|
| HED\* | `HANAMI_ENV=development` | Set environment variable HANAMI_ENV to development |
| HEP\* | `HANAMI_ENV=production` | Set environment variable HANAMI_ENV to production |
| HET\* | `HANAMI_ENV=test` | Set environment variable HANAMI_ENV to test |
| hc | `hanami console` | Run application console |
| hd | `hanami destroy` | Remove specified hanami resource |
| hg | `hanami generate` | Create specified hanami resource |
| hgm | `hanami generate migration` | Create migration file |
| hs | `hanami server` | Launch server with hanami application |
| hsp | `hanami server -p` | Launch server with specified port |
| hr | `hanami routes` | List application routes |
| hdc | `hanami db create` | Create application database |
| hdd | `hanami db drop` | Delete application database |
| hdp | `hanami db prepare` | Prepare database for the current environment |
| hda | `hanami db apply` | Recreates a fresh schema after migrations (destructive) |
| hdv | `hanami db version` | Print current database version |
| hdrs | `hdd && hdp` | Drop and recreate application database |
| hdtp | `HET hdp` | Actualize test environment database |
| hrg | `hr | grep` | Grep hanami routes with specified pattern |
\* You should use these at the beginning of a command, for example:
```console
$ HED hdd # equivalent to 'HANAMI_ENV=development hanami db drop'
```
@@ -1,6 +1,6 @@
alias -g HED='HANAMI_ENV=development'
alias -g HEP='HANAMI_ENV=production'
alias -g HET='HANAMI_ENV=test'
alias HED='HANAMI_ENV=development '
alias HEP='HANAMI_ENV=production '
alias HET='HANAMI_ENV=test '
alias hc='hanami console'
alias hd='hanami destroy'
@@ -1,27 +1,38 @@
# Bind quick stuff to enter!
#
# Pressing enter in a git directory runs `git status`
# in other directories `ls`
magic-enter () {
# If commands are not already set, use the defaults
[ -z "$MAGIC_ENTER_GIT_COMMAND" ] && MAGIC_ENTER_GIT_COMMAND="git status -u ."
[ -z "$MAGIC_ENTER_OTHER_COMMAND" ] && MAGIC_ENTER_OTHER_COMMAND="ls -lh ."
# Default commands
: ${MAGIC_ENTER_GIT_COMMAND:="git status -u ."} # run when in a git repository
: ${MAGIC_ENTER_OTHER_COMMAND:="ls -lh ."} # run anywhere else
if [[ -z $BUFFER ]]; then
echo ""
if git rev-parse --is-inside-work-tree &>/dev/null; then
eval "$MAGIC_ENTER_GIT_COMMAND"
else
eval "$MAGIC_ENTER_OTHER_COMMAND"
magic-enter() {
# Only run MAGIC_ENTER commands when in PS1 and command line is empty
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#User_002dDefined-Widgets
if [[ -n "$BUFFER" || "$CONTEXT" != start ]]; then
return
fi
zle redisplay
if command git rev-parse --is-inside-work-tree &>/dev/null; then
BUFFER="$MAGIC_ENTER_GIT_COMMAND"
else
zle accept-line
BUFFER="$MAGIC_ENTER_OTHER_COMMAND"
fi
}
zle -N magic-enter
# Wrapper for the accept-line zle widget (run when pressing Enter)
bindkey -M emacs "^M" magic-enter
bindkey -M vicmd "^M" magic-enter
bindkey -M viins "^M" magic-enter
# If the wrapper already exists don't redefine it
(( ! ${+functions[_magic-enter_accept-line]} )) || return 0
case "$widgets[accept-line]" in
# Override the current accept-line widget, calling the old one
user:*) zle -N _magic-enter_orig_accept-line "${widgets[accept-line]#user:}"
function _magic-enter_accept-line() {
magic-enter
zle _magic-enter_orig_accept-line -- "$@"
} ;;
# If no user widget defined, call the original accept-line widget
builtin) function _magic-enter_accept-line() {
magic-enter
zle .accept-line
} ;;
esac
zle -N accept-line _magic-enter_accept-line
@@ -9,40 +9,48 @@
# -------
#
# * Dongweiming <ciici123@gmail.com>
# * Subhaditya Nath <github.com/subnut>
# * Marc Cornellà <github.com/mcornella>
#
# ------------------------------------------------------------------------------
__sudo-replace-buffer() {
local old=$1 new=$2 space=${2:+ }
if [[ ${#LBUFFER} -le ${#old} ]]; then
RBUFFER="${space}${BUFFER#$old }"
LBUFFER="${new}"
else
LBUFFER="${new}${space}${LBUFFER#$old }"
fi
}
sudo-command-line() {
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
# Save beginning space
local WHITESPACE=""
if [[ ${LBUFFER:0:1} == " " ]] ; then
if [[ ${LBUFFER:0:1} = " " ]]; then
WHITESPACE=" "
LBUFFER="${LBUFFER:1}"
fi
if [[ -n $EDITOR && $BUFFER == $EDITOR\ * ]]; then
if [[ ${#LBUFFER} -le ${#EDITOR} ]]; then
RBUFFER=" ${BUFFER#$EDITOR }"
LBUFFER="sudoedit"
else
LBUFFER="sudoedit ${LBUFFER#$EDITOR }"
# Get the first part of the typed command and check if it's an alias to $EDITOR
# If so, locally change $EDITOR to the alias so that it matches below
if [[ -n "$EDITOR" ]]; then
local cmd="${${(Az)BUFFER}[1]}"
if [[ "${aliases[$cmd]} " = (\$EDITOR|$EDITOR)\ * ]]; then
local EDITOR="$cmd"
fi
elif [[ $BUFFER == sudoedit\ * ]]; then
if [[ ${#LBUFFER} -le 8 ]]; then
RBUFFER=" ${BUFFER#sudoedit }"
LBUFFER="$EDITOR"
else
LBUFFER="$EDITOR ${LBUFFER#sudoedit }"
fi
elif [[ $BUFFER == sudo\ * ]]; then
if [[ ${#LBUFFER} -le 4 ]]; then
RBUFFER="${BUFFER#sudo }"
LBUFFER=""
else
LBUFFER="${LBUFFER#sudo }"
fi
if [[ -n $EDITOR && $BUFFER = $EDITOR\ * ]]; then
__sudo-replace-buffer "$EDITOR" "sudoedit"
elif [[ -n $EDITOR && $BUFFER = \$EDITOR\ * ]]; then
__sudo-replace-buffer "\$EDITOR" "sudoedit"
elif [[ $BUFFER = sudoedit\ * ]]; then
__sudo-replace-buffer "sudoedit" "$EDITOR"
elif [[ $BUFFER = sudo\ * ]]; then
__sudo-replace-buffer "sudo" ""
else
LBUFFER="sudo $LBUFFER"
fi
@@ -50,7 +58,9 @@ sudo-command-line() {
# Preserve beginning space
LBUFFER="${WHITESPACE}${LBUFFER}"
}
zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc]
bindkey -M emacs '\e\e' sudo-command-line
bindkey -M vicmd '\e\e' sudo-command-line
@@ -6,14 +6,16 @@ _terraform_cmds=(
'console:Interactive console for Terraform interpolations'
'destroy:Destroy Terraform-managed infrastructure'
'fmt:Rewrites config files to canonical format'
'force-unlock:Manually unlock the terraform state'
'get:Download and install modules for the configuration'
'graph:Create a visual graph of Terraform resources'
'import:Import existing infrastructure into Terraform'
'init:Initialize a Terraform working directory'
'login:Obtain and save credentials for a remote host'
'logout:Remove locally-stored credentials for a remote host'
'output:Read an output from a state file'
'plan:Generate and show an execution plan'
'providers:Prints a tree of the providers used in the configuration'
'push:Upload this Terraform module to Atlas to run'
'refresh:Update local state file against real resources'
'show:Inspect Terraform state or plan'
'state:Advanced state management'
@@ -23,6 +25,7 @@ _terraform_cmds=(
'version:Prints the Terraform version'
'workspace:Workspace management'
'0.12upgrade:Rewrites pre-0.12 module source code for v0.12'
'0.13upgrade:Rewrites pre-0.13 module source code for v0.13'
)
__012upgrade() {
@@ -31,45 +34,51 @@ __012upgrade() {
'-force[ Override the heuristic that attempts to detect if a configuration is already written for v0.12 or later. Some of the transformations made by this command are not idempotent, so re-running against the same module may change the meanings expressions in the module.]'
}
__013upgrade() {
_arguments \
'-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]'
}
__apply() {
_arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-auto-approve[Skip interactive approval of plan before applying.]' \
'-lock=[(true) Lock the state file when locking is supported.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
'-no-color[If specified, output wil be colorless.]' \
'-parallelism=[(10) Limit the number of parallel resource operations.]' \
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__console() {
_arguments \
'-state=[(terraform.tfstate) Path to read state.]' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__destroy() {
_arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
'-auto-approve[Skip interactive approval before destroying.]' \
'-force[Deprecated: same as auto-approve.]' \
'-lock=[(true) Lock the state file when locking is supported.]' \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-no-color[If specified, output will contain no color.]' \
'-parallelism=[(10) Limit the number of concurrent operations.]' \
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__fmt() {
@@ -81,33 +90,36 @@ __fmt() {
'-recursive=[(false) Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]'
}
__force_unlock() {
_arguments \
"-force[Don't ask for input for unlock confirmation.]"
}
__get() {
_arguments \
'-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \
'-no-color[If specified, output will contain no color.]'
'-no-color[Disable text coloring in the output.]'
}
__graph() {
_arguments \
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
'-no-color[If specified, output will contain no color.]' \
'-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]'
}
__import() {
_arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
'-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \
'-allow-missing-config[Allow import when no resource configuration block exists.]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
'-lock=[(true) Lock the state file when locking is supported.]' \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-no-color[If specified, output will contain no color.]' \
'-provider=[(provider) Specific provider to use for import. This is used for specifying aliases, such as "aws.eu". Defaults to the normal provider prefix of the resource being imported.]' \
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]' \
'-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
'-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
'-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__init() {
@@ -115,80 +127,94 @@ __init() {
'-backend=[(true) Configure the backend for this configuration.]' \
'-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \
'-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \
'-from-module=[Copy the contents of the given module into the target directory before initialization.]' \
'-from-module=[(SOURCE) Copy the contents of the given module into the target directory before initialization.]' \
'-get=[(true) Download any modules for this configuration.]' \
'-get-plugins=[(true) Download any missing plugins for this configuration.]' \
'-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \
'-lock=[(true) Lock the state file when locking is supported.]' \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-no-color[If specified, output will contain no color.]' \
'-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]' \
'-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -/' \
'-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \
'-upgrade=[(false) If installing modules (-get) or plugins (-get-plugins), ignore previously-downloaded objects and install the latest version allowed within configured constraints.]' \
'-verify-plugins=[(true) Verify the authenticity and integrity of automatically downloaded plugins.]'
}
__login() {
_arguments \
}
__logout() {
_arguments \
}
__output() {
_arguments \
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]' \
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
'-no-color[If specified, output will contain no color.]' \
'-module=[(name) If specified, returns the outputs for a specific module]' \
'-json[If specified, machine readable output will be printed in JSON format]'
}
__plan() {
_arguments \
'-destroy[() If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
'-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
'-detailed-exitcode[() Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
'-lock=[(true) Lock the state file when locking is supported.]' \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-module-depth=[(n) Specifies the depth of modules to show in the output. This does not affect the plan itself, only the output shown. By default, this is -1, which will expand all.]' \
'-no-color[() If specified, output will contain no color.]' \
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
'-parallelism=[(10) Limit the number of concurrent operations.]' \
'-refresh=[(true) Update state prior to checking for differences.]' \
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' \
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__providers() {
_arguments \
local -a __providers_cmds
__providers_cmds=(
'mirror:Mirrors the provider plugins needed for the current configuration'
'schema:Prints the schemas of the providers used in the configuration'
)
_describe -t providers "providers commands" __providers_cmds
}
__push() {
__providers_mirror() {
_arguments \
'-atlas-address=[(url) An alternate address to an Atlas instance. Defaults to https://atlas.hashicorp.com.]' \
'-upload-modules=[(true) If true (default), then the modules being used are all locked at their current checkout and uploaded completely to Atlas. This prevents Atlas from running terraform get for you.]' \
'-name=[(name) Name of the infrastructure configuration in Atlas. The format of this is: "username/name" so that you can upload configurations not just to your account but to other accounts and organizations. This setting can also be set in the configuration in the Atlas section.]' \
'-no-color[Disables output with coloring]' \
'-overwrite=[(foo) Marks a specific variable to be updated on Atlas. Normally, if a variable is already set in Atlas, Terraform will not send the local value (even if it is different). This forces it to send the local value to Atlas. This flag can be repeated multiple times.]' \
'-token=[(token) Atlas API token to use to authorize the upload. If blank or unspecified, the ATLAS_TOKEN environmental variable will be used.]' \
'-var=[("foo=bar") Set the value of a variable for the Terraform configuration.]' \
'-var-file=[(foo) Set the value of variables using a variable file.]' \
'-vcs=[(true) If true (default), then Terraform will detect if a VCS is in use, such as Git, and will only upload files that are committed to version control. If no version control system is detected, Terraform will upload all files in path (parameter to the command).]'
'-platform=[(os_arch) Choose which target platform to build a mirror for.]' \
"*:target_dir:_files -/"
}
__providers_schema() {
_arguments \
'-json[]' \
'::'
}
__refresh() {
_arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -g "*.backup"' \
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
'-lock=[(true) Lock the state file when locking is supported.]' \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-no-color[If specified, output will not contain any color.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
'*-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__show() {
_arguments \
'-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \
'-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
'-no-color[If specified, output will not contain any color.]'
}
@@ -199,6 +225,7 @@ __state() {
'mv:Move an item in the state'
'pull:Pull current state and output to stdout'
'push:Update remote state from a local state file'
'replace-provider:Replace provider for resources in the Terraform state'
'rm:Remove instances from the state'
'show:Show a resource in the state'
)
@@ -207,7 +234,7 @@ __state() {
__state_list() {
_arguments \
'-state=[(path) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]' \
'-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \
"*:address:__statelist"
}
@@ -215,12 +242,12 @@ __state_list() {
__state_mv() {
_arguments \
"-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \
"-backup=[(path) Path where Terraform should write the backup for the original state. This can't be disabled. If not set, Terraform will write it to the same path as the statefile with a \".backup\" extension.]:file:_files" \
"-backup-out=[(path) Path where Terraform should write the backup for the destination state. This can't be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:file:_files" \
"-lock=[(true|false) Lock the state files when locking is supported.]:lock:(true false)" \
"-lock-timeout=[(seconds) Duration to retry a state lock.]" \
'-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:file:_files' \
"-state-out=[(path) Path to the destination state file to write to. If this isn't specified, the source state file will be used. This can be a new or existing path.]:file:_files" \
'-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
'-backup-out=[(PATH) Path where Terraform should write the backup for the destination state. This can"t be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:backupfile:_files -g "*.backup"' \
"-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
'-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
'-state-out=[(path) Path to the destination state file to write to. If this isn"t specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
"::" \
":source:__statelist" \
":destination: "
@@ -229,26 +256,37 @@ __state_mv() {
__state_push() {
_arguments \
"-force[Write the state even if lineages don't match or the remote serial is higher.]" \
'-lock=[(true|false) Lock the state file when locking is supported.]:lock:(true false)' \
"-lock-timeout=[(seconds) Duration to retry a state lock.]" \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
"::" \
":destination:_files"
}
__state_replace_provider() {
_arguments \
'-auto-approve[Skip interactive approval.]' \
'-backup=[(PATH) Path where Terraform should write the backup for the state file. This can"t be disabled. If not set, Terraform will write it to the same path as the state file with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
"-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
":from_provider_fqn:" \
":to_provider_fqn:"
}
__state_rm() {
_arguments \
"-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \
"-backup=[(path) Path where Terraform should write the backup for the original state.]:file:_files" \
"-lock=[(true|false) Lock the state files when locking is supported.]:lock:(true false)" \
"-lock-timeout=[(seconds) Duration to retry a state lock.]" \
'-state=[(path) Path to the state file to update. Defaults to the current workspace state.]:file:_files' \
'-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -g "*.backup"' \
"-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)" \
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
'-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -g "*.tfstate"' \
"*:address:__statelist"
}
__state_show() {
_arguments \
'-state=[(path) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
"*:address:__statelist"
}
@@ -259,34 +297,36 @@ __statelist() {
__taint() {
_arguments \
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-lock=[(true) Lock the state file when locking is supported.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
'-no-color[If specified, output will not contain any color.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' \
"*:address:__statelist"
}
__untaint() {
_arguments \
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-lock=[(true) Lock the state file when locking is supported.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
'-no-color[If specified, output will not contain any color.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]'
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"'
}
__validate() {
_arguments \
'-check-variables=[(true) If set to true (default), the command will check whether all required variables have been specified.]' \
'-no-color[If specified, output will not contain any color.]' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
'-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \
':dir:_files -/'
}
__version() {
_arguments \
'-json[Output the version information as a JSON object.]'
}
__workspace() {
@@ -312,6 +352,8 @@ local -a _command_args
case "$words[1]" in
0.12upgrade)
__012upgrade ;;
0.13upgrade)
__013upgrade ;;
apply)
__apply ;;
console)
@@ -320,6 +362,8 @@ case "$words[1]" in
__destroy ;;
fmt)
__fmt;;
force-unlock)
__force_unlock;;
get)
__get ;;
graph)
@@ -328,14 +372,19 @@ case "$words[1]" in
__import;;
init)
__init ;;
login)
__login ;;
logout)
__logout ;;
output)
__output ;;
plan)
__plan ;;
providers)
__providers ;;
push)
__push ;;
test $CURRENT -lt 3 && __providers
[[ $words[2] = "mirror" ]] && __providers_mirror
[[ $words[2] = "schema" ]] && __providers_schema
;;
refresh)
__refresh ;;
show)
@@ -345,6 +394,7 @@ case "$words[1]" in
[[ $words[2] = "list" ]] && __state_list
[[ $words[2] = "mv" ]] && __state_mv
[[ $words[2] = "push" ]] && __state_push
[[ $words[2] = "replace-provider" ]] && __state_replace_provider
[[ $words[2] = "rm" ]] && __state_rm
[[ $words[2] = "show" ]] && __state_show
;;
@@ -354,6 +404,8 @@ case "$words[1]" in
__untaint ;;
validate)
__validate ;;
version)
__version ;;
workspace)
test $CURRENT -lt 3 && __workspace ;;
esac
@@ -2,6 +2,10 @@
[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
To use it, add thefuck to the plugins array of your zshrc file:
plugins=(... thefuck)
## Usage
Press `ESC` twice to correct previous console command.
@@ -1,107 +1,109 @@
# WP-CLI
The [WordPress CLI](https://wp-cli.org/) is a command-line tool for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
This plugin adds [tab completion](https://wp-cli.org/#tab-completions) for `wp-cli` as well as several aliases for commonly used commands.
To use it, add `wp-cli` to the plugins array in your zshrc file:
```zsh
plugins=(... wp-cli)
```
**Maintainer:** [joshmedeski](https://github.com/joshmedeski)
WordPress Command Line Interface (https://wp-cli.org/)
## Aliases
WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
This plugin adds [tab completion](https://wp-cli.org/#tab-completions) for `wp-cli` as well as several aliases.
## List of Aliases
### Core
- wpcc='wp core config'
- wpcd='wp core download'
- wpci='wp core install'
- wpcii='wp core is-installed'
- wpcmc='wp core multisite-convert'
- wpcmi='wp core multisite-install'
- wpcu='wp core update'
- wpcudb='wp core update-db'
- wpcvc='wp core verify-checksums'
### Cron
- wpcre='wp cron event'
- wpcrs='wp cron schedule'
- wpcrt='wp cron test'
### Menu
- wpmc='wp menu create'
- wpmd='wp menu delete'
- wpmi='wp menu item'
- wpml='wp menu list'
- wpmlo='wp menu location'
### Plugin
- wppa='activate'
- wppda='deactivate'
- wppd='delete'
- wppg='get'
- wppi='install'
- wppis='is-installed'
- wppl='list'
- wppp='path'
- wpps='search'
- wppst='status'
- wppt='toggle'
- wppun='uninstall'
- wppu='update'
### Post
- wppoc='wp post create'
- wppod='wp post delete'
- wppoe='wp post edit'
- wppogen='wp post generate'
- wppog='wp post get'
- wppol='wp post list'
- wppom='wp post meta'
- wppou='wp post update'
- wppourl='wp post url'
### Sidebar
- wpsbl='wp sidebar list'
### Theme
- wpta='wp theme activate'
- wptd='wp theme delete'
- wptdis='wp theme disable'
- wpte='wp theme enable'
- wptg='wp theme get'
- wpti='wp theme install'
- wptis='wp theme is-installed'
- wptl='wp theme list'
- wptm='wp theme mod'
- wptp='wp theme path'
- wpts='wp theme search'
- wptst='wp theme status'
- wptu='wp theme update'
### User
- wpuac='wp user add-cap'
- wpuar='wp user add-role'
- wpuc='wp user create'
- wpud='wp user delete'
- wpugen='wp user generate'
- wpug='wp user get'
- wpui='wp user import-csv'
- wpul='wp user list'
- wpulc='wp user list-caps'
- wpum='wp user meta'
- wpurc='wp user remove-cap'
- wpurr='wp user remove-role'
- wpusr='wp user set-role'
- wpuu='wp user update'
### Widget
- wpwa='wp widget add'
- wpwda='wp widget deactivate'
- wpwd='wp widget delete'
- wpwl='wp widget list'
- wpwm='wp widget move'
- wpwu='wp widget update'
The entire list of wp-cli commands can be found here: https://wp-cli.org/commands/
I only included the commands that are most used. Please feel free to contribute to this project if you want more commands.
The entire list of `wp-cli` commands can be found here: https://developer.wordpress.org/cli/commands/
| Alias | Command |
|-----------|-----------------------------|
| **Core** |
| `wpcc` | `wp core config` |
| `wpcd` | `wp core download` |
| `wpci` | `wp core install` |
| `wpcii` | `wp core is-installed` |
| `wpcmc` | `wp core multisite-convert` |
| `wpcmi` | `wp core multisite-install` |
| `wpcu` | `wp core update` |
| `wpcudb` | `wp core update-db` |
| `wpcvc` | `wp core verify-checksums` |
| **Cron** |
| `wpcre` | `wp cron event` |
| `wpcrs` | `wp cron schedule` |
| `wpcrt` | `wp cron test` |
| **Database** |
| `wpdbe` | `wp db export` |
| `wpdbi` | `wp db import` |
| `wpdbcr` | `wp db create` |
| `wpdbs` | `wp db search` |
| `wpdbch` | `wp db check` |
| `wpdbr` | `wp db repair` |
| **Menu** |
| `wpmc` | `wp menu create` |
| `wpmd` | `wp menu delete` |
| `wpmi` | `wp menu item` |
| `wpml` | `wp menu list` |
| `wpmlo` | `wp menu location` |
| **Plugin** |
| `wppa` | `wp plugin activate` |
| `wppda` | `wp plugin deactivate` |
| `wppd` | `wp plugin delete` |
| `wppg` | `wp plugin get` |
| `wppi` | `wp plugin install` |
| `wppis` | `wp plugin is-installed` |
| `wppl` | `wp plugin list` |
| `wppp` | `wp plugin path` |
| `wpps` | `wp plugin search` |
| `wppst` | `wp plugin status` |
| `wppt` | `wp plugin toggle` |
| `wppun` | `wp plugin uninstall` |
| `wppu` | `wp plugin update` |
| **Post** |
| `wppoc` | `wp post create` |
| `wppod` | `wp post delete` |
| `wppoe` | `wp post edit` |
| `wppogen` | `wp post generate` |
| `wppog` | `wp post get` |
| `wppol` | `wp post list` |
| `wppom` | `wp post meta` |
| `wppou` | `wp post update` |
| `wppourl` | `wp post url` |
| **Sidebar** |
| `wpsbl` | `wp sidebar list` |
| **Theme** |
| `wpta` | `wp theme activate` |
| `wptd` | `wp theme delete` |
| `wptdis` | `wp theme disable` |
| `wpte` | `wp theme enable` |
| `wptg` | `wp theme get` |
| `wpti` | `wp theme install` |
| `wptis` | `wp theme is-installed` |
| `wptl` | `wp theme list` |
| `wptm` | `wp theme mod` |
| `wptp` | `wp theme path` |
| `wpts` | `wp theme search` |
| `wptst` | `wp theme status` |
| `wptu` | `wp theme update` |
| **User** |
| `wpuac` | `wp user add-cap` |
| `wpuar` | `wp user add-role` |
| `wpuc` | `wp user create` |
| `wpud` | `wp user delete` |
| `wpugen` | `wp user generate` |
| `wpug` | `wp user get` |
| `wpui` | `wp user import-csv` |
| `wpul` | `wp user list` |
| `wpulc` | `wp user list-caps` |
| `wpum` | `wp user meta` |
| `wpurc` | `wp user remove-cap` |
| `wpurr` | `wp user remove-role` |
| `wpusr` | `wp user set-role` |
| `wpuu` | `wp user update` |
| **Widget** |
| `wpwa` | `wp widget add` |
| `wpwda` | `wp widget deactivate` |
| `wpwd` | `wp widget delete` |
| `wpwl` | `wp widget list` |
| `wpwm` | `wp widget move` |
| `wpwu` | `wp widget update` |
@@ -2,14 +2,6 @@
# A command line interface for WordPress
# https://wp-cli.org/
# Cache
# Cap
# CLI
# Comment
# Core
alias wpcc='wp core config'
alias wpcd='wp core download'
@@ -27,18 +19,12 @@ alias wpcrs='wp cron schedule'
alias wpcrt='wp cron test'
# Db
# Eval
# Eval-File
# Export
# Help
# Import
# Media
alias wpdbe='wp db export'
alias wpdbi='wp db import'
alias wpdbcr='wp db create'
alias wpdbs='wp db search'
alias wpdbch='wp db check'
alias wpdbr='wp db repair'
# Menu
alias wpmc='wp menu create'
@@ -47,10 +33,6 @@ alias wpmi='wp menu item'
alias wpml='wp menu list'
alias wpmlo='wp menu location'
# Network
# Option
# Plugin
alias wppa='wp plugin activate'
alias wppda='wp plugin deactivate'
@@ -77,25 +59,9 @@ alias wppom='wp post meta'
alias wppou='wp post update'
alias wppourl='wp post url'
# Rewrite
# Role
# Scaffold
# Search-Replace
# Shell
# Sidebar
alias wpsbl='wp sidebar list'
# Site
# Super-Admin
# Term
# Theme
alias wpta='wp theme activate'
alias wptd='wp theme delete'
@@ -111,8 +77,6 @@ alias wpts='wp theme search'
alias wptst='wp theme status'
alias wptu='wp theme update'
# Transient
# User
alias wpuac='wp user add-cap'
alias wpuar='wp user add-role'
@@ -138,9 +102,8 @@ alias wpwm='wp widget move'
alias wpwu='wp widget update'
# Completion for wp
autoload -U +X bashcompinit && bashcompinit
# bash completion for the `wp` command
_wp_complete() {
local cur=${COMP_WORDS[COMP_CWORD]}
@@ -24,7 +24,7 @@ function update_last_updated_file() {
}
function update_ohmyzsh() {
ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
update_last_updated_file
}
@@ -51,7 +51,11 @@ function update_ohmyzsh() {
# The return status from the function is handled specially. If it is zero, the signal is
# assumed to have been handled, and execution continues normally. Otherwise, the shell
# will behave as interrupted except that the return status of the trap is retained.
trap "command rm -rf '$ZSH/log/update.lock'; return 1" EXIT INT QUIT
trap "
unset -f current_epoch update_last_updated_file update_ohmyzsh
command rm -rf '$ZSH/log/update.lock'
return 1
" EXIT INT QUIT
# Create or update .zsh-update file if missing or malformed
if ! source "${ZSH_CACHE_DIR}/.zsh-update" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then
@@ -84,5 +88,3 @@ function update_ohmyzsh() {
esac
fi
}
unset -f current_epoch update_last_updated_file update_ohmyzsh
@@ -37,6 +37,9 @@
#
set -e
# Track if $ZSH was provided
custom_zsh=${ZSH:+yes}
# Default settings
ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh}
@@ -53,14 +56,18 @@ command_exists() {
command -v "$@" >/dev/null 2>&1
}
error() {
fmt_error() {
echo ${RED}"Error: $@"${RESET} >&2
}
underline() {
fmt_underline() {
echo "$(printf '\033[4m')$@$(printf '\033[24m')"
}
fmt_code() {
echo "\`$(printf '\033[38;5;247m')$@${RESET}\`"
}
setup_color() {
# Only use colors if connected to a terminal
if [ -t 1 ]; then
@@ -91,13 +98,13 @@ setup_ohmyzsh() {
echo "${BLUE}Cloning Oh My Zsh...${RESET}"
command_exists git || {
error "git is not installed"
fmt_error "git is not installed"
exit 1
}
if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
error "Windows/MSYS Git is not supported on Cygwin"
error "Make sure the Cygwin git package is installed and is first on the \$PATH"
fmt_error "Windows/MSYS Git is not supported on Cygwin"
fmt_error "Make sure the Cygwin git package is installed and is first on the \$PATH"
exit 1
fi
@@ -106,7 +113,7 @@ setup_ohmyzsh() {
-c fetch.fsck.zeroPaddedFilemode=ignore \
-c receive.fsck.zeroPaddedFilemode=ignore \
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
error "git clone of oh-my-zsh repo failed"
fmt_error "git clone of oh-my-zsh repo failed"
exit 1
}
@@ -130,8 +137,8 @@ setup_zshrc() {
if [ -e "$OLD_ZSHRC" ]; then
OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
if [ -e "$OLD_OLD_ZSHRC" ]; then
error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}"
error "re-run the installer again in a couple of seconds"
fmt_error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}"
fmt_error "re-run the installer again in a couple of seconds"
exit 1
fi
mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"
@@ -160,13 +167,13 @@ setup_shell() {
fi
# If this user's login shell is already "zsh", do not attempt to switch.
if [ "$(basename "$SHELL")" = "zsh" ]; then
if [ "$(basename -- "$SHELL")" = "zsh" ]; then
return
fi
# If this platform doesn't provide a "chsh" command, bail out.
if ! command_exists chsh; then
cat <<-EOF
cat <<EOF
I can't change your shell automatically because this system does not have chsh.
${BLUE}Please manually change your default shell to zsh${RESET}
EOF
@@ -197,7 +204,7 @@ setup_shell() {
elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS
shells_file=/usr/share/defaults/etc/shells
else
error "could not find /etc/shells file. Change your default shell manually."
fmt_error "could not find /etc/shells file. Change your default shell manually."
return
fi
@@ -206,8 +213,8 @@ setup_shell() {
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
error "no zsh binary found or not present in '$shells_file'"
error "change your default shell manually."
fmt_error "no zsh binary found or not present in '$shells_file'"
fmt_error "change your default shell manually."
return
fi
fi
@@ -222,7 +229,7 @@ setup_shell() {
# Actually change the default shell to zsh
if ! chsh -s "$zsh"; then
error "chsh command unsuccessful. Change your default shell manually."
fmt_error "chsh command unsuccessful. Change your default shell manually."
else
export SHELL="$zsh"
echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}"
@@ -232,7 +239,7 @@ setup_shell() {
}
main() {
# Run as unattended if stdin is closed
# Run as unattended if stdin is not a tty
if [ ! -t 0 ]; then
RUNZSH=no
CHSH=no
@@ -256,10 +263,24 @@ main() {
fi
if [ -d "$ZSH" ]; then
cat <<-EOF
${YELLOW}You already have Oh My Zsh installed.${RESET}
You'll need to remove '$ZSH' if you want to reinstall.
echo "${YELLOW}The \$ZSH folder already exists ($ZSH).${RESET}"
if [ "$custom_zsh" = yes ]; then
cat <<EOF
You ran the installer with the \$ZSH setting or the \$ZSH variable is
exported. You have 3 options:
1. Unset the ZSH variable when calling the installer:
$(fmt_code "ZSH= sh install.sh")
2. Install Oh My Zsh to a directory that doesn't exist yet:
$(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
3. (Caution) If the folder doesn't contain important information,
you can just remove it with $(fmt_code "rm -r $ZSH")
EOF
else
echo "You'll need to remove it if you want to reinstall."
fi
exit 1
fi
@@ -268,7 +289,7 @@ main() {
setup_shell
printf "$GREEN"
cat <<-'EOF'
cat <<'EOF'
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
@@ -278,12 +299,12 @@ main() {
EOF
cat <<-EOF
cat <<EOF
Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.
• Follow us on Twitter: $(underline https://twitter.com/ohmyzsh)
• Join our Discord server: $(underline https://discord.gg/ohmyzsh)
• Get stickers, shirts, coffee mugs and other swag: $(underline https://shop.planetargon.com/collections/oh-my-zsh)
• Follow us on Twitter: $(fmt_underline https://twitter.com/ohmyzsh)
• Join our Discord server: $(fmt_underline https://discord.gg/ohmyzsh)
• Get stickers, shirts, coffee mugs and other swag: $(fmt_underline https://shop.planetargon.com/collections/oh-my-zsh)
EOF
printf "$RESET"
@@ -1,82 +0,0 @@
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if [ -t 1 ]; then
RB_RED=$(printf '\033[38;5;196m')
RB_ORANGE=$(printf '\033[38;5;202m')
RB_YELLOW=$(printf '\033[38;5;226m')
RB_GREEN=$(printf '\033[38;5;082m')
RB_BLUE=$(printf '\033[38;5;021m')
RB_INDIGO=$(printf '\033[38;5;093m')
RB_VIOLET=$(printf '\033[38;5;163m')
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
YELLOW=$(printf '\033[33m')
BLUE=$(printf '\033[34m')
BOLD=$(printf '\033[1m')
UNDER=$(printf '\033[4m')
RESET=$(printf '\033[m')
else
RB_RED=""
RB_ORANGE=""
RB_YELLOW=""
RB_GREEN=""
RB_BLUE=""
RB_INDIGO=""
RB_VIOLET=""
RED=""
GREEN=""
YELLOW=""
BLUE=""
UNDER=""
BOLD=""
RESET=""
fi
cd "$ZSH"
# Set git-config values known to fix git errors
# Line endings (#4069)
git config core.eol lf
git config core.autocrlf false
# zeroPaddedFilemode fsck errors (#4963)
git config fsck.zeroPaddedFilemode ignore
git config fetch.fsck.zeroPaddedFilemode ignore
git config receive.fsck.zeroPaddedFilemode ignore
# autostash on rebase (#7172)
resetAutoStash=$(git config --bool rebase.autoStash 2>&1)
git config rebase.autoStash true
# Update upstream remote to ohmyzsh org
remote=$(git remote -v | awk '/https:\/\/github\.com\/robbyrussell\/oh-my-zsh\.git/{ print $1; exit }')
if [ -n "$remote" ]; then
git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
fi
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
if git pull --rebase --stat origin master
then
printf '%s %s__ %s %s %s %s %s__ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
printf '%s / __ \%s/ __ \ %s / __ `__ \%s/ / / / %s /_ / %s/ ___/%s __ \ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
printf '%s %s %s %s /____/ %s %s %s %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "To keep up on the latest news and updates, follow us on Twitter:" "https://twitter.com/ohmyzsh"
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Want to get involved in the community? Join our Discord:" "https://discord.gg/ohmyzsh"
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Get your Oh My Zsh swag at:" "https://shop.planetargon.com/collections/oh-my-zsh"
else
status=$?
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
fi
# Unset git-config values set just for the upgrade
case "$resetAutoStash" in
"") git config --unset rebase.autoStash ;;
*) git config rebase.autoStash "$resetAutoStash" ;;
esac
# Exit with `1` if the update failed
exit $status
+2
View File
@@ -31,6 +31,8 @@ set nobackup
set nowritebackup
set updatetime=300
set cmdheight=2
set noswapfile " disable swapfile
set number
" CoC Highlighting
autocmd FileType json syntax match Comment +\/\/.\+$+
+4 -3
View File
@@ -1,17 +1,18 @@
default-sample-format = float32le
default-sample-rate = 48000
alternate-sample-rate = 44100
default-sample-rate = 44100
alternate-sample-rate = 48000
default-sample-channels = 2
default-channel-map = front-left,front-right
default-fragments = 2
default-fragment-size-msec = 125
resample-method = soxr-vhq
resample-method = soxr-hq
enable-lfe-remixing = no
high-priority = yes
nice-level = -11
realtime-scheduling = yes
realtime-priority = 9
rlimit-rtprio = 9
#avoid-resampling = yes
daemonize = no
#Alsa config