Reformat using shfmt
This commit is contained in:
parent
09324bb670
commit
e1ba38a16d
@ -19,8 +19,8 @@ zplug "junegunn/fzf", use:"shell/*.zsh"
|
|||||||
if ! zplug check --verbose; then
|
if ! zplug check --verbose; then
|
||||||
printf "Install? [y/N]: "
|
printf "Install? [y/N]: "
|
||||||
if read -q; then
|
if read -q; then
|
||||||
echo; zplug install
|
echo
|
||||||
|
zplug install
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
zplug load
|
zplug load
|
||||||
|
|
||||||
|
|||||||
49
zshrc
49
zshrc
@ -15,11 +15,11 @@ autoload -Uz add-zsh-hook
|
|||||||
LAST_RETURN_VALUE=0
|
LAST_RETURN_VALUE=0
|
||||||
|
|
||||||
# Characters
|
# Characters
|
||||||
if [[ -n $(echo '\u2603' 2>/dev/null) ]] then
|
if [[ -n $(echo '\u2603' 2>/dev/null) ]]; then
|
||||||
MULTIBYTE_SUPPORTED="\u2603"
|
MULTIBYTE_SUPPORTED="\u2603"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $MULTIBYTE_SUPPORTED ]] then
|
if [[ -n $MULTIBYTE_SUPPORTED ]]; then
|
||||||
UNSTAGED_CHARACTER="\ue168"
|
UNSTAGED_CHARACTER="\ue168"
|
||||||
CHANGES_CHARACTER="\ue16b"
|
CHANGES_CHARACTER="\ue16b"
|
||||||
UNTRACKED_CHARACTER="\ue16c"
|
UNTRACKED_CHARACTER="\ue16c"
|
||||||
@ -55,7 +55,6 @@ else
|
|||||||
SEGMENT_SEPARATOR_BACKWARD=""
|
SEGMENT_SEPARATOR_BACKWARD=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------- Helpers -----------------------------------
|
#---------------------------------- Helpers -----------------------------------
|
||||||
|
|
||||||
# Search file up in directory tree. Either print path to found file or nothing
|
# Search file up in directory tree. Either print path to found file or nothing
|
||||||
@ -64,14 +63,14 @@ find_up () {
|
|||||||
while [[ "$path" != "" ]]; do
|
while [[ "$path" != "" ]]; do
|
||||||
if [[ -e "$path/$1" ]]; then
|
if [[ -e "$path/$1" ]]; then
|
||||||
echo "$path/$1"
|
echo "$path/$1"
|
||||||
return;
|
return
|
||||||
fi
|
fi
|
||||||
path=${path%/*}
|
path=${path%/*}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
command-exists() {
|
command-exists() {
|
||||||
return $(command -v $1 >/dev/null);
|
return $(command -v $1 >/dev/null)
|
||||||
}
|
}
|
||||||
NEWLINE=$'\n'
|
NEWLINE=$'\n'
|
||||||
ZDOTDIR=${ZDOTDIR:-$HOME/.zsh}
|
ZDOTDIR=${ZDOTDIR:-$HOME/.zsh}
|
||||||
@ -86,7 +85,7 @@ if command-exists exa; then
|
|||||||
else
|
else
|
||||||
LSOPTS="-lAvF --color=auto" # long mode, show all, natural sort, type squiggles, friendly sizes
|
LSOPTS="-lAvF --color=auto" # long mode, show all, natural sort, type squiggles, friendly sizes
|
||||||
alias ls="ls $LSOPTS"
|
alias ls="ls $LSOPTS"
|
||||||
fi;
|
fi
|
||||||
|
|
||||||
#---------------------------------- Tab completion ----------------------------
|
#---------------------------------- Tab completion ----------------------------
|
||||||
|
|
||||||
@ -245,7 +244,7 @@ prompt_root() {
|
|||||||
# Different username
|
# Different username
|
||||||
prompt_user() {
|
prompt_user() {
|
||||||
local user=$USER
|
local user=$USER
|
||||||
if command-exists whoami && [[ -z $user ]] then
|
if command-exists whoami && [[ -z $user ]]; then
|
||||||
user=$(whoami)
|
user=$(whoami)
|
||||||
fi
|
fi
|
||||||
if [[ "$user" != "$DEFAULT_USER" && $UID -ne 0 ]]; then
|
if [[ "$user" != "$DEFAULT_USER" && $UID -ne 0 ]]; then
|
||||||
@ -267,7 +266,6 @@ prompt_makefile() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Status:
|
# Status:
|
||||||
# - was there an error
|
# - was there an error
|
||||||
# - are there background jobs?
|
# - are there background jobs?
|
||||||
@ -368,7 +366,7 @@ function +vi-git-additional() {
|
|||||||
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
|
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
|
||||||
(($behind)) && branchstatus+=(" $BEHIND_CHARACTER${behind}")
|
(($behind)) && branchstatus+=(" $BEHIND_CHARACTER${behind}")
|
||||||
hook_com[misc]="${(j::)branchstatus}"
|
hook_com[misc]="${(j::)branchstatus}"
|
||||||
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \
|
if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == 'true' &&
|
||||||
-n $(git status --porcelain | grep -E '^\?\?' 2>/dev/null | tail -n1) ]]; then
|
-n $(git status --porcelain | grep -E '^\?\?' 2>/dev/null | tail -n1) ]]; then
|
||||||
hook_com[unstaged]+=" $UNTRACKED_CHARACTER"
|
hook_com[unstaged]+=" $UNTRACKED_CHARACTER"
|
||||||
fi
|
fi
|
||||||
@ -393,7 +391,6 @@ function title {
|
|||||||
print -n "\ek$prefix$1\e\\"
|
print -n "\ek$prefix$1\e\\"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Prefix the xterm title with the current machine name, but only if I'm not
|
# Prefix the xterm title with the current machine name, but only if I'm not
|
||||||
# on a local machine. This is tricky, because screen won't reliably know
|
# on a local machine. This is tricky, because screen won't reliably know
|
||||||
# whether I'm using SSH right now! So just assume I'm local iff I'm not
|
# whether I'm using SSH right now! So just assume I'm local iff I'm not
|
||||||
@ -518,15 +515,15 @@ alias bd=". bd -si"
|
|||||||
#---------------------------------- VIM pager --------------------------------
|
#---------------------------------- VIM pager --------------------------------
|
||||||
|
|
||||||
vim_pager() {
|
vim_pager() {
|
||||||
local source_file;
|
local source_file
|
||||||
if [ ! -t 1 ]; then
|
if [ ! -t 1 ]; then
|
||||||
echo "Cannot use vim pager with non-terminal output" 1>&2
|
echo "Cannot use vim pager with non-terminal output" 1>&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
source_file="$@";
|
source_file="$@"
|
||||||
elif [ ! -t 0 ]; then
|
elif [ ! -t 0 ]; then
|
||||||
source_file="-";
|
source_file="-"
|
||||||
else
|
else
|
||||||
echo "Input stream or file name missing" 1>&2
|
echo "Input stream or file name missing" 1>&2
|
||||||
return 2
|
return 2
|
||||||
@ -543,20 +540,20 @@ maven_read_project() {
|
|||||||
location=$(find_up pom.xml)
|
location=$(find_up pom.xml)
|
||||||
if [[ ! -r "$location" || -z $commands[xmllint] ]]; then
|
if [[ ! -r "$location" || -z $commands[xmllint] ]]; then
|
||||||
MAVEN_PROJECT=""
|
MAVEN_PROJECT=""
|
||||||
return 1;
|
return 1
|
||||||
fi
|
fi
|
||||||
# executing xmllint takes some time, so this does it in single execution
|
# executing xmllint takes some time, so this does it in single execution
|
||||||
parts=($(echo "cat /*[local-name()='project']/*[local-name()='artifactId']/text()\n" \
|
parts=($(echo "cat /*[local-name()='project']/*[local-name()='artifactId']/text()\n" \
|
||||||
"cat /*[local-name()='project']/*[local-name()='version']/text()\n" \
|
"cat /*[local-name()='project']/*[local-name()='version']/text()\n" \
|
||||||
"cat /*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']/text()\n" | \
|
"cat /*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']/text()\n" |
|
||||||
xmllint --shell $location 2>/dev/null | \
|
xmllint --shell $location 2>/dev/null |
|
||||||
sed '/^\/ >/d' | \
|
sed '/^\/ >/d' |
|
||||||
sed '/^ -------/d'))
|
sed '/^ -------/d'))
|
||||||
if [[ "${#parts}" > 1 ]]; then
|
if [[ "${#parts}" > 1 ]]; then
|
||||||
MAVEN_PROJECT="${parts[1]}@${parts[2]}"
|
MAVEN_PROJECT="${parts[1]}@${parts[2]}"
|
||||||
else
|
else
|
||||||
MAVEN_PROJECT="pom!"
|
MAVEN_PROJECT="pom!"
|
||||||
fi;
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
add-zsh-hook chpwd maven_read_project
|
add-zsh-hook chpwd maven_read_project
|
||||||
@ -569,7 +566,7 @@ package_json_read_project() {
|
|||||||
location=$(find_up package.json)
|
location=$(find_up package.json)
|
||||||
if [[ ! -r "$location" || -z $commands[jq] ]]; then
|
if [[ ! -r "$location" || -z $commands[jq] ]]; then
|
||||||
PACKAGE_JSON_PROJECT=""
|
PACKAGE_JSON_PROJECT=""
|
||||||
return 1;
|
return 1
|
||||||
fi
|
fi
|
||||||
PACKAGE_JSON_PROJECT=$(jq -r '.name + "@" + .version' $location)
|
PACKAGE_JSON_PROJECT=$(jq -r '.name + "@" + .version' $location)
|
||||||
}
|
}
|
||||||
@ -593,7 +590,7 @@ unsetopt auto_remove_slash # (dont) remove last slash when next character is del
|
|||||||
unsetopt csh_junkie_quotes # (dont) complain if a quoted expression runs off the end of a line; prevent quoted expressions from containing un-escaped newlines.
|
unsetopt csh_junkie_quotes # (dont) complain if a quoted expression runs off the end of a line; prevent quoted expressions from containing un-escaped newlines.
|
||||||
|
|
||||||
# Don't count common path separators as word characters
|
# Don't count common path separators as word characters
|
||||||
WORDCHARS=${WORDCHARS//[&.;\/]}
|
WORDCHARS=${WORDCHARS//[&.;\/]/}
|
||||||
|
|
||||||
# Report time if command takes too long
|
# Report time if command takes too long
|
||||||
REPORTTIME=5
|
REPORTTIME=5
|
||||||
@ -601,8 +598,9 @@ REPORTTIME=5
|
|||||||
TIMEFMT=$(echo "$fg[green]${SEGMENT_SEPARATOR_BACKWARD}$bg[green]$fg[black] %*Es $fg[yellow]$SEGMENT_SEPARATOR_BACKWARD$bg[yellow]$fg[black] %P $reset_color")
|
TIMEFMT=$(echo "$fg[green]${SEGMENT_SEPARATOR_BACKWARD}$bg[green]$fg[black] %*Es $fg[yellow]$SEGMENT_SEPARATOR_BACKWARD$bg[yellow]$fg[black] %P $reset_color")
|
||||||
|
|
||||||
# Don't glob with commands that expects glob patterns
|
# Don't glob with commands that expects glob patterns
|
||||||
for command in find wget git; \
|
for command in find wget git; do
|
||||||
alias $command="noglob $command"
|
alias $command="noglob $command"
|
||||||
|
done
|
||||||
|
|
||||||
# load zsh extended move
|
# load zsh extended move
|
||||||
autoload -Uz zmv
|
autoload -Uz zmv
|
||||||
@ -617,7 +615,7 @@ fi
|
|||||||
|
|
||||||
# at last initialize completion
|
# at last initialize completion
|
||||||
autoload -Uz compinit
|
autoload -Uz compinit
|
||||||
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
|
if [[ -n "${ZDOTDIR}/.zcompdump(#qN.mh+24)" ]]; then
|
||||||
compinit
|
compinit
|
||||||
else
|
else
|
||||||
compinit -C
|
compinit -C
|
||||||
@ -634,19 +632,19 @@ precmd_functions=(store_last_return_value $precmd_functions)
|
|||||||
# If kubectl is present, load completions from it.
|
# If kubectl is present, load completions from it.
|
||||||
# This must be done after compinit was called
|
# This must be done after compinit was called
|
||||||
if [[ $commands[kubectl] ]]; then
|
if [[ $commands[kubectl] ]]; then
|
||||||
source <(kubectl completion zsh);
|
source <(kubectl completion zsh)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If k3s is present, load completions from it.
|
# If k3s is present, load completions from it.
|
||||||
# This must be done after compinit was called
|
# This must be done after compinit was called
|
||||||
if [[ $commands[k3s] ]]; then
|
if [[ $commands[k3s] ]]; then
|
||||||
source <(k3s completion zsh);
|
source <(k3s completion zsh)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If minikube is present, load completions from it.
|
# If minikube is present, load completions from it.
|
||||||
# This must be done after compinit was called
|
# This must be done after compinit was called
|
||||||
if [[ $commands[minikube] ]]; then
|
if [[ $commands[minikube] ]]; then
|
||||||
source <(minikube completion zsh);
|
source <(minikube completion zsh)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
zmodload zsh/complist
|
zmodload zsh/complist
|
||||||
@ -671,4 +669,3 @@ function br {
|
|||||||
return "$code"
|
return "$code"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user