Fix static analysis and lint errors

This commit is contained in:
Marty Oehme 2019-07-24 11:32:04 +02:00
parent 8494eda973
commit d7e8831423
9 changed files with 116 additions and 117 deletions

View file

@ -74,7 +74,7 @@ test_agent_socket() {
_KEY_COUNT=0 _KEY_COUNT=0
fi fi
if [[ (($result -eq 0) || ($result -eq 1)) ]]; then if [ $result -eq 0 ] || [ $result -eq 1 ]; then
if [[ -n "$_LIVE_AGENT_LIST" ]]; then if [[ -n "$_LIVE_AGENT_LIST" ]]; then
_LIVE_AGENT_LIST="${_LIVE_AGENT_LIST} ${SOCKET}:$_KEY_COUNT" _LIVE_AGENT_LIST="${_LIVE_AGENT_LIST} ${SOCKET}:$_KEY_COUNT"
else else

View file

@ -2,11 +2,11 @@
# #
# Expand aliases inline - see http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html # Expand aliases inline - see http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html
globalias() { globalias() {
if [[ $LBUFFER =~ [A-Z0-9]+$ ]]; then if [[ $LBUFFER =~ [A-Z0-9]+$ ]]; then
zle _expand_alias zle _expand_alias
zle expand-word zle expand-word
fi fi
zle self-insert zle self-insert
} }
zle -N globalias zle -N globalias

View file

@ -2,127 +2,127 @@
# Clone zgen if you haven't already # Clone zgen if you haven't already
check_zgen_installation() { check_zgen_installation() {
if [[ -z "$ZGEN_PARENT_DIR" ]]; then if [[ -z "$ZGEN_PARENT_DIR" ]]; then
ZGEN_PARENT_DIR=${${XDG_CONFIG_HOME}:="$HOME/.config/"} ZGEN_PARENT_DIR=${XDG_CONFIG_HOME:="$HOME/.config/"}
ZGEN_DIR="$ZGEN_PARENT_DIR/zgen" ZGEN_DIR="$ZGEN_PARENT_DIR/zgen"
fi fi
if [[ ! -f $ZGEN_DIR/zgen.zsh ]]; then if [[ ! -f $ZGEN_DIR/zgen.zsh ]]; then
if [[ ! -d "$ZGEN_PARENT_DIR" ]]; then if [[ ! -d "$ZGEN_PARENT_DIR" ]]; then
mkdir -p "$ZGEN_PARENT_DIR" mkdir -p "$ZGEN_PARENT_DIR"
fi fi
cd $ZGEN_PARENT_DIR || return cd "$ZGEN_PARENT_DIR" || return
git clone https://github.com/tarjoilija/zgen.git $ZGEN_DIR git clone https://github.com/tarjoilija/zgen.git "$ZGEN_DIR"
fi fi
# shellcheck source=/home/marty/.config/zgen/zgen.zsh # shellcheck source=/home/marty/.config/zgen/zgen.zsh
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source $ZGEN_DIR/zgen.zsh source "$ZGEN_DIR"/zgen.zsh
unset ZGEN_PARENT_DIR unset ZGEN_PARENT_DIR
} }
load_plugins() { load_plugins() {
ZGEN_LOADED=() ZGEN_LOADED=()
ZGEN_COMPLETIONS=() ZGEN_COMPLETIONS=()
zgen oh-my-zsh zgen oh-my-zsh
# If you want to customize your plugin list, create a file named # If you want to customize your plugin list, create a file named
# .zgen-local-plugins in your home directory. That file will be sourced # .zgen-local-plugins in your home directory. That file will be sourced
# during startup *instead* of running this load-starter-plugin-list function, # during startup *instead* of running this load-starter-plugin-list function,
# so make sure to include everything from this function that you want to keep. # so make sure to include everything from this function that you want to keep.
# If zsh-syntax-highlighting is bundled after zsh-history-substring-search, # If zsh-syntax-highlighting is bundled after zsh-history-substring-search,
# they break, so get the order right. # they break, so get the order right.
zgen load zdharma/fast-syntax-highlighting zgen load zdharma/fast-syntax-highlighting
zgen load zsh-users/zsh-history-substring-search zgen load zsh-users/zsh-history-substring-search
# Set keystrokes for substring searching # Set keystrokes for substring searching
zmodload zsh/terminfo zmodload zsh/terminfo
bindkey "${terminfo[kcuu1]:?}" history-substring-search-up bindkey "${terminfo[kcuu1]:?}" history-substring-search-up
bindkey "${terminfo[kcud1]:?}" history-substring-search-down bindkey "${terminfo[kcud1]:?}" history-substring-search-down
# Automatically run zgen update and zgen selfupdate every 7 days. # Automatically run zgen update and zgen selfupdate every 7 days.
zgen load unixorn/autoupdate-zgen zgen load unixorn/autoupdate-zgen
# Warn you when you run a command that you've set an alias for without # Warn you when you run a command that you've set an alias for without
# using the alias. # using the alias.
zgen load djui/alias-tips zgen load djui/alias-tips
# Colorize the things if you have grc installed. Well, some of the # Colorize the things if you have grc installed. Well, some of the
# things, anyway. # things, anyway.
zgen load unixorn/warhol.plugin.zsh zgen load unixorn/warhol.plugin.zsh
zgen load chrissicool/zsh-256color zgen load chrissicool/zsh-256color
# Add Fish-like autosuggestions to your ZSH. # Add Fish-like autosuggestions to your ZSH.
zgen load zsh-users/zsh-autosuggestions zgen load zsh-users/zsh-autosuggestions
# k is a zsh script / plugin to make directory listings more readable, # k is a zsh script / plugin to make directory listings more readable,
# adding a bit of color and some git status information on files and # adding a bit of color and some git status information on files and
# directories. # directories.
zgen load supercrabtree/k zgen load supercrabtree/k
# Bullet train prompt setup. # Bullet train prompt setup.
zgen load bhilburn/powerlevel9k powerlevel9k zgen load bhilburn/powerlevel9k powerlevel9k
# automatically sources (known/whitelisted) .autoenv.zsh files # automatically sources (known/whitelisted) .autoenv.zsh files
# as long as you're in the folder (and can optionally 'unsource' on leaving) # as long as you're in the folder (and can optionally 'unsource' on leaving)
zgen load Tarrasch/zsh-autoenv zgen load Tarrasch/zsh-autoenv
# radically enhanced cd command, all sorts of options # radically enhanced cd command, all sorts of options
zgen load b4b4r07/enhancd zgen load b4b4r07/enhancd
# set up nvm, the npm version manager # set up nvm, the npm version manager
zgen load lukechilds/zsh-nvm zgen load lukechilds/zsh-nvm
# Add git helper scripts. # Add git helper scripts.
zgen load unixorn/git-extra-commands zgen load unixorn/git-extra-commands
# Tom Limoncelli's tooling for storing private information (keys, etc) # Tom Limoncelli's tooling for storing private information (keys, etc)
# in a repository securely by encrypting them with gnupg. # in a repository securely by encrypting them with gnupg.
zgen load StackExchange/blackbox zgen load StackExchange/blackbox
# Load some oh-my-zsh plugins # Load some oh-my-zsh plugins
zgen oh-my-zsh plugins/pip zgen oh-my-zsh plugins/pip
zgen oh-my-zsh plugins/sudo zgen oh-my-zsh plugins/sudo
zgen oh-my-zsh plugins/aws zgen oh-my-zsh plugins/aws
zgen oh-my-zsh plugins/chruby zgen oh-my-zsh plugins/chruby
zgen oh-my-zsh plugins/colored-man-pages zgen oh-my-zsh plugins/colored-man-pages
zgen oh-my-zsh plugins/git zgen oh-my-zsh plugins/git
zgen oh-my-zsh plugins/github zgen oh-my-zsh plugins/github
zgen oh-my-zsh plugins/python zgen oh-my-zsh plugins/python
zgen oh-my-zsh plugins/rsync zgen oh-my-zsh plugins/rsync
zgen oh-my-zsh plugins/screen zgen oh-my-zsh plugins/screen
zgen oh-my-zsh plugins/vagrant zgen oh-my-zsh plugins/vagrant
# check for autojump install before applying plugin # check for autojump install before applying plugin
if type autojump >/dev/null 2>&1; then if type autojump >/dev/null 2>&1; then
zgen oh-my-zsh plugins/autojump zgen oh-my-zsh plugins/autojump
fi fi
zgen oh-my-zsh plugins/tmux zgen oh-my-zsh plugins/tmux
zgen oh-my-zsh plugins/tmuxinator zgen oh-my-zsh plugins/tmuxinator
# when in a directory with vagrant/docker files can use start, stop, up, down # when in a directory with vagrant/docker files can use start, stop, up, down
zgen load Cloudstek/zsh-plugin-appup zgen load Cloudstek/zsh-plugin-appup
# Load more completion files for zsh from the zsh-lovers github repo. # Load more completion files for zsh from the zsh-lovers github repo.
zgen load zsh-users/zsh-completions src zgen load zsh-users/zsh-completions src
# Docker completion # Docker completion
zgen load srijanshetty/docker-zsh zgen load srijanshetty/docker-zsh
# Very cool plugin that generates zsh completion functions for commands # Very cool plugin that generates zsh completion functions for commands
# if they have getopt-style help text. It doesn't generate them on the fly, # if they have getopt-style help text. It doesn't generate them on the fly,
# you'll have to explicitly generate a completion, but it's still quite cool. # you'll have to explicitly generate a completion, but it's still quite cool.
zgen load RobSis/zsh-completion-generator zgen load RobSis/zsh-completion-generator
# Tab complete rakefile targets. # Tab complete rakefile targets.
zgen load unixorn/rake-completion.zshplugin zgen load unixorn/rake-completion.zshplugin
# Load me last # Load me last
GENCOMPL_FPATH=$HOME/.zsh/complete GENCOMPL_FPATH=$HOME/.zsh/complete
zgen save zgen save
} }
check_zgen_installation check_zgen_installation
if ! zgen saved; then if ! zgen saved; then
load_plugins load_plugins
fi fi

View file

@ -13,7 +13,7 @@ POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{blue}\u256D\u2500%F{white}"
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}\u2570\uf460%F{white} " POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}\u2570\uf460%F{white} "
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir dir_writable_joined) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir dir_writable_joined)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time
vcs background_jobs_joined time_joined) vcs background_jobs_joined time_joined)
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND="clear" POWERLEVEL9K_VCS_MODIFIED_BACKGROUND="clear"
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND="clear" POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND="clear"
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND="yellow" POWERLEVEL9K_VCS_MODIFIED_FOREGROUND="yellow"

View file

@ -1,5 +1,5 @@
#!/bin/zsh #!/bin/zsh
# mkdir & cd # mkdir & cd
function mkcd { function mkcd() {
mkdir -p "$@" && cd "$_" || return mkdir -p "$@" && cd "$_" || return
} }

View file

@ -1,10 +1,10 @@
#!/bin/zsh #!/bin/zsh
# show newest files # show newest files
# http://www.commandlinefu.com/commands/view/9015/find-the-most-recently-changed-files-recursively # http://www.commandlinefu.com/commands/view/9015/find-the-most-recently-changed-files-recursively
newest (){ newest() {
find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | \ find . -type f -printf '%TY-%Tm-%Td %TT %p\n' |
grep -v cache | \ grep -v cache |
grep -v '.hg' | grep -v '.git' | \ grep -v '.hg' | grep -v '.git' |
sort -r | \ sort -r |
less less
} }

View file

@ -1,6 +1,6 @@
#!/bin/zsh #!/bin/zsh
# automatically use tmux whenever we ssh to a server # automatically use tmux whenever we ssh to a server
function ssht(){ function ssht() {
ssh "$@" -t 'tmux a || tmux || /bin/bash' ssh "$@" -t 'tmux a || tmux || /bin/bash'
} }

View file

@ -1,14 +1,15 @@
#!/bin/zsh
#
# Speed up autocomplete, force prefix mapping # Speed up autocomplete, force prefix mapping
zstyle ':completion:*' accept-exact '*(N)' zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache zstyle ':completion:*' cache-path ~/.zsh/cache
# shellcheck disable=SC2016 # shellcheck disable=SC2016
zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)*==34=34}:${(s.:.)LS_COLORS}")'; zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)*==34=34}:${(s.:.)LS_COLORS}")'
# Load any custom zsh completions we've installed # Load any custom zsh completions we've installed
if [ -d ~/.zsh-completions ]; then if [ -d ~/.zsh-completions ]; then
for completion in ~/.zsh-completions/* for completion in ~/.zsh-completions/*; do
do
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "$completion" source "$completion"
done done

View file

@ -5,20 +5,18 @@
# In case a plugin adds a redundant path entry, remove duplicate entries # In case a plugin adds a redundant path entry, remove duplicate entries
# from PATH # from PATH
# # from: https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command
# This snippet is from Mislav Marohnić <mislav.marohnic@gmail.com>'s get_var() {
# dotfiles repo at https://github.com/mislav/dotfiles eval 'printf "%s\n" "${'"$1"'}"'
dedupe_path() {
typeset -a paths result
paths=($path)
while [[ ${#paths} -gt 0 ]]; do
p="${paths[1]}"
shift paths
[[ -z ${paths[(r)$p]} ]] && result+="$p"
done
export PATH=${(j+:+)result}
} }
set_var() {
dedupe_path eval "$1=\"\$2\""
}
dedup_pathvar() {
pathvar_name="$1"
pathvar_value="$(get_var "$pathvar_name")"
deduped_path="$(perl -e 'print join(":",grep { not $seen{$_}++ } split(/:/, $ARGV[0]))' "$pathvar_value")"
set_var "$pathvar_name" "$deduped_path"
}
dedup_pathvar PATH
dedup_pathvar MANPATH