Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions zsh/.zgen-setup
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
# BSD licensed, see LICENSE.txt

# Clone zgenom if you haven't already
if [[ -z "$ZGENOM_PARENT_DIR" ]]; then
ZGENOM_PARENT_DIR=$HOME
ZGENOM_SOURCE_FILE=$ZGENOM_PARENT_DIR/.zqs-zgenom/zgenom.zsh
if [[ -z ${ZGENOM_PARENT_DIR-} ]]; then
ZGENOM_PARENT_DIR=${ZDOTDIR:-$HOME}
ZGENOM_SOURCE_FILE="$ZGENOM_PARENT_DIR/.zqs-zgenom/zgenom.zsh"

# Set ZGENOM_SOURCE_FILE to the old directory if it already exists
if [[ -f "$ZGENOM_PARENT_DIR/zgenom/zgenom.zsh" ]] ; then
ZGENOM_SOURCE_FILE=$ZGENOM_PARENT_DIR/zgenom/zgenom.zsh
ZGENOM_SOURCE_FILE="$ZGENOM_PARENT_DIR/zgenom/zgenom.zsh"
fi
fi

# zgenom stores the clones plugins & themes in $ZGEN_DIR when it
# is set. Otherwise it stuffs everything in the source tree, which
# is unclean.
ZGEN_DIR=${ZGEN_DIR:-$HOME/.zgenom}
ZGEN_DIR=${ZGEN_DIR:-${ZDOTDIR:-$HOME}/.zgenom}

if [[ ! -f "$ZGENOM_SOURCE_FILE" ]] ; then
if [[ ! -d "$ZGENOM_PARENT_DIR" ]]; then
Expand All @@ -42,7 +42,7 @@ fi
unset ZGENOM_PARENT_DIR ZGENOM_SOURCE_FILE

warn-about-prompt-change() {
if [[ ! -f ~/.zsh-quickstart-kit-prompt-switch-warning ]]; then
if [[ ! -f ${ZDOTDIR:-$HOME}/.zsh-quickstart-kit-prompt-switch-warning ]]; then
echo
echo "The default ZSH prompt in the quickstart kit has changed from"
echo "bullet-train to powerlevel10k."
Expand All @@ -53,7 +53,7 @@ warn-about-prompt-change() {
echo
echo "If you do nothing, you will be switched to powerlevel10k"
echo
touch ~/.zsh-quickstart-kit-prompt-switch-warning
touch ${ZDOTDIR:-$HOME}/.zsh-quickstart-kit-prompt-switch-warning
fi
}

Expand All @@ -62,7 +62,7 @@ load-starter-plugin-list() {
ZGEN_LOADED=()
ZGEN_COMPLETIONS=()

if [[ ! -f ~/.zsh-quickstart-no-omz ]] || [[ $(_zqs-get-setting load-omz-plugins true) == 'true' ]]; then
if [[ ! -f ${ZDOTDIR:-$HOME}/.zsh-quickstart-no-omz ]] || [[ $(_zqs-get-setting load-omz-plugins true) == 'true' ]]; then
zgenom oh-my-zsh
fi

Expand Down Expand Up @@ -136,15 +136,15 @@ load-starter-plugin-list() {
# in a repository securely by encrypting them with gnupg.
zgenom load StackExchange/blackbox

if [[ -f ~/.zqs-add-plugins ]]; then
source ~/.zqs-add-plugins
if [[ -f ${ZDOTDIR:-$HOME}/.zqs-add-plugins ]]; then
source ${ZDOTDIR:-$HOME}/.zqs-add-plugins
fi

if [[ -d ~/.zshrc.add-plugins.d ]]; then
load-shell-fragments ~/.zshrc.add-plugins.d
if [[ -d ${ZDOTDIR:-$HOME}/.zshrc.add-plugins.d ]]; then
load-shell-fragments ${ZDOTDIR:-$HOME}/.zshrc.add-plugins.d
fi

if [[ ! -f ~/.zsh-quickstart-no-omz ]] || [[ $(_zqs-get-setting load-omz-plugins false) == 'true' ]]; then
if [[ ! -f ${ZDOTDIR:-$HOME}/.zsh-quickstart-no-omz ]] || [[ $(_zqs-get-setting load-omz-plugins false) == 'true' ]]; then
# Load some oh-my-zsh plugins
zgenom oh-my-zsh plugins/pip
zgenom oh-my-zsh plugins/sudo
Expand Down Expand Up @@ -184,7 +184,7 @@ load-starter-plugin-list() {
zgenom load unixorn/1password-op.plugin.zsh

# Load me last
GENCOMPL_FPATH=$HOME/.zsh/complete
GENCOMPL_FPATH=${ZDOTDIR:-$HOME}/.zsh/complete

# 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,
Expand All @@ -200,7 +200,7 @@ load-starter-plugin-list() {
zgenom load supercrabtree/k

# Be compatible with the old settings files for now
if [[ -f ~/.zsh-quickstart-use-bullet-train ]] || [[ $(_zqs-get-setting bullet-train false) == 'true' ]]; then
if [[ -f ${ZDOTDIR:-$HOME}/.zsh-quickstart-use-bullet-train ]] || [[ $(_zqs-get-setting bullet-train false) == 'true' ]]; then
# Bullet train prompt setup.
zgenom load https://github.com/caiogondim/bullet-train.zsh
else
Expand All @@ -216,12 +216,12 @@ load-starter-plugin-list() {
setup-zgen-repos() {
ZQS_override_plugin_list=''
# Check the old name for backward compatibility
if [[ -r $HOME/.zgen-local-plugins ]]; then
ZQS_override_plugin_list="$HOME/.zgen-local-plugins"
if [[ -r ${ZDOTDIR:-$HOME}/.zgen-local-plugins ]]; then
ZQS_override_plugin_list="${ZDOTDIR:-$HOME}/.zgen-local-plugins"
fi
# If they have both, the new name takes precedence
if [[ -r $HOME/.zsh-quickstart-local-plugins ]]; then
ZQS_override_plugin_list="$HOME/.zsh-quickstart-local-plugins"
if [[ -r ${ZDOTDIR:-$HOME}/.zsh-quickstart-local-plugins ]]; then
ZQS_override_plugin_list="${ZDOTDIR:-$HOME}/.zsh-quickstart-local-plugins"
fi

if [[ -r "$ZQS_override_plugin_list" ]]; then
Expand Down Expand Up @@ -266,11 +266,11 @@ fi
# Unfortunately, stat will return the modification time of the
# symlink instead of the target file, so construct a full path to hand off
# to stat so it returns the modification time of the actual .zgen-setup file.
if [[ -f ~/.zgen-setup ]]; then
REAL_ZGEN_SETUP=~/.zgen-setup
if [[ -f ${ZDOTDIR:-$HOME}/.zgen-setup ]]; then
REAL_ZGEN_SETUP=${ZDOTDIR:-$HOME}/.zgen-setup
fi
if [[ -L ~/.zgen-setup ]]; then
REAL_ZGEN_SETUP="$(readlink ~/.zgen-setup)"
if [[ -L ${ZDOTDIR:-$HOME}/.zgen-setup ]]; then
REAL_ZGEN_SETUP="$(readlink ${ZDOTDIR:-$HOME}/.zgen-setup)"
fi

# If you don't want my standard starter set of plugins, create a file named
Expand All @@ -282,43 +282,43 @@ fi
#
# Use readlink in case the user is symlinking from another repo checkout, so
# they can use a personal dotfiles repository cleanly.
if [[ -f ~/.zgen-local-plugins ]]; then
REAL_ZGEN_SETUP=~/.zgen-local-plugins
if [[ -f ${ZDOTDIR:-$HOME}/.zgen-local-plugins ]]; then
REAL_ZGEN_SETUP=${ZDOTDIR:-$HOME}/.zgen-local-plugins
fi
if [[ -L ~/.zgen-local-plugins ]]; then
REAL_ZGEN_SETUP="${HOME}/$(readlink ~/.zgen-local-plugins)"
if [[ -L ${ZDOTDIR:-$HOME}/.zgen-local-plugins ]]; then
REAL_ZGEN_SETUP="${ZDOTDIR:-$HOME}/$(readlink ${ZDOTDIR:-$HOME}/.zgen-local-plugins)"
fi
# Old file still works for backward compatibility, but we want the new file
# to take precedence when both exist.
if [[ -f ~/.zsh-quickstart-local-plugins ]]; then
REAL_ZGEN_SETUP=~/.zsh-quickstart-local-plugins
if [[ -f ${ZDOTDIR:-$HOME}/.zsh-quickstart-local-plugins ]]; then
REAL_ZGEN_SETUP=${ZDOTDIR:-$HOME}/.zsh-quickstart-local-plugins
fi
if [[ -L ~/.zsh-quickstart-local-plugins ]]; then
REAL_ZGEN_SETUP="${HOME}/$(readlink ~/.zsh-quickstart-local-plugins)"
if [[ -L ${ZDOTDIR:-$HOME}/.zsh-quickstart-local-plugins ]]; then
REAL_ZGEN_SETUP="${ZDOTDIR:-$HOME}/$(readlink ${ZDOTDIR:-$HOME}/.zsh-quickstart-local-plugins)"
fi

# If .zgen-setup is newer than init.zsh, regenerate init.zsh
if [ $(get_file_modification_time ${REAL_ZGEN_SETUP}) -gt $(get_file_modification_time ~/.zgenom/init.zsh) ]; then
if [ $(get_file_modification_time ${REAL_ZGEN_SETUP}) -gt $(get_file_modification_time ${ZDOTDIR:-$HOME}/.zgenom/init.zsh) ]; then
echo "$(basename ${REAL_ZGEN_SETUP}) ($REAL_ZGEN_SETUP) updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP}"
setup-zgen-repos
elif [ -d ~/.zshrc.add-plugins.d ]; then
init_timestamp=$(get_file_modification_time ~/.zgenom/init.zsh)
plugins_dir_timestamp=$(get_file_modification_time ~/.zshrc.add-plugins.d)
elif [ -d ${ZDOTDIR:-$HOME}/.zshrc.add-plugins.d ]; then
init_timestamp=$(get_file_modification_time ${ZDOTDIR:-$HOME}/.zgenom/init.zsh)
plugins_dir_timestamp=$(get_file_modification_time ${ZDOTDIR:-$HOME}/.zshrc.add-plugins.d)
if [ "$plugins_dir_timestamp" -gt "$init_timestamp" ]; then
need_update="true"
need_update="true"
fi

if [[ -n "$("ls" -A ~/.zshrc.add-plugins.d)" ]] && [[ -z $need_update ]]; then
for file in ~/.zshrc.add-plugins.d/*; do
if [[ -n "$("ls" -A ${ZDOTDIR:-$HOME}/.zshrc.add-plugins.d)" ]] && [[ -z ${need_update-} ]]; then
for file in ${ZDOTDIR:-$HOME}/.zshrc.add-plugins.d/*; do
if [[ $(get_file_modification_time "${file}") -gt ${init_timestamp} ]]; then
need_update="true"
break
fi
done
fi

if [[ -n $need_update ]]; then
echo "Some files in ~/.zshrc.add-plugins.d updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP} and plugins dir"
if [[ -n ${need_update-} ]]; then
echo "Some files in ${ZDOTDIR:-$HOME}/.zshrc.add-plugins.d updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP} and plugins dir"
setup-zgen-repos
fi
unset init_timestamp
Expand Down
36 changes: 19 additions & 17 deletions zsh/.zsh_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,40 @@ export CVS_RSH=ssh
alias historysummary="history | awk '{a[\$2]++} END{for(i in a){printf \"%5d\t%s\n\",a[i],i}}' | sort -rn | head"

if [ -x /bin/vim ]; then
alias vi="/bin/vim"
alias vim="/bin/vim"
export EDITOR="/bin/vim"
alias vi="/bin/vim"
alias vim="/bin/vim"
export EDITOR="/bin/vim"
fi

if [ -x /usr/bin/vim ]; then
alias vi="/usr/bin/vim"
alias vim="/usr/bin/vim"
export EDITOR="/usr/bin/vim"
alias vi="/usr/bin/vim"
alias vim="/usr/bin/vim"
export EDITOR="/usr/bin/vim"
fi

# MacPorts has a newer vim than Apple ships
if [ -x /opt/local/bin/vim ]; then
alias vim="/opt/local/bin/vim"
alias vi="/opt/local/bin/vim"
export EDITOR="/opt/local/bin/vim"
alias vim="/opt/local/bin/vim"
alias vi="/opt/local/bin/vim"
export EDITOR="/opt/local/bin/vim"
fi

# So does brew
if can_haz brew; then
brew_prefix="$(brew --prefix)/bin"
if [[ -x "$brew_prefix/vim" ]]; then
alias vim="$brew_prefix/vim"
alias vi="$brew_prefix/vim"
export EDITOR="$brew_prefix/vim"
alias vim="$brew_prefix/vim"
alias vi="$brew_prefix/vim"
export EDITOR="$brew_prefix/vim"
fi
unset brew_prefix
fi

# Clearly, I really like vim.

export VISUAL=${EDITOR}
if (( ${+EDITOR} )); then
export VISUAL="${EDITOR}"
fi

# Clean up files that have the wrong line endings
alias mac2unix="tr '\015' '\012'"
Expand Down Expand Up @@ -120,9 +122,9 @@ alias wget="wget -c"
alias zh="fc -l -d -D"

# My typical tyops.
alias grep='GREP_COLORS="1;37;41" LANG=C grep --color=auto'
alias gerp='grep'
alias grep-i='grep -i'
alias grep='GREP_COLORS="1;37;41" LANG=C grep --color=auto'
alias grepi='grep -i'
alias knfie='knife'
alias maek='make'
Expand Down Expand Up @@ -160,9 +162,9 @@ alias ..="cd .."
alias ...="cd ../.."

# Honor old .zsh_aliases.local customizations, but print depecation warning.
if [ -f ~/.zsh_aliases.local ]; then
if [ -f ${ZDOTDIR:-$HOME}/.zsh_aliases.local ]; then
# shellcheck disable=SC1090
source ~/.zsh_aliases.local
source ${ZDOTDIR:-$HOME}/.zsh_aliases.local
echo ".zsh_aliases.local is deprecated and will stop working after June 1st, 2022."
echo "Make entries in ~/.zshrc.d instead. See https://github.com/unixorn/zsh-quickstart-kit#zshrcd for more details."
echo "Make entries in ${ZDOTDIR:-$HOME}/.zshrc.d instead. See https://github.com/unixorn/zsh-quickstart-kit#zshrcd for more details."
fi
16 changes: 8 additions & 8 deletions zsh/.zsh_functions
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function man() {
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
man "$@"
}

if ! can_haz watch; then
Expand Down Expand Up @@ -97,10 +97,10 @@ alias mtr_url="mtr-url"
function fix_tmux_ssh_agent() {
if can_haz tmux; then
for key in SSH_AUTH_SOCK SSH_CONNECTION SSH_CLIENT; do
if (tmux show-environment | grep "^${key}" > /dev/null); then
value=$(tmux show-environment | grep "^${key}" | sed -e "s/^[A-Z_]*=//")
export ${key}="${value}"
fi
if (tmux show-environment | grep "^${key}" > /dev/null); then
value=$(tmux show-environment | grep "^${key}" | sed -e "s/^[A-Z_]*=//")
export ${key}="${value}"
fi
done
else
echo "Can't find tmux in your PATH. Install it and try again."
Expand Down Expand Up @@ -158,8 +158,8 @@ function httpserver() {
}

# Honor old .zsh_functions.local customizations, but print depecation warning.
if [ -f ~/.zsh_functions.local ]; then
source .zsh_functions.local
if [ -f ${ZDOTDIR:-$HOME}/.zsh_functions.local ]; then
source ${ZDOTDIR:-$HOME}/.zsh_functions.local
echo ".zsh_functions.local is deprecated and will stop working after June 1st, 2022."
echo "Make entries in ~/.zshrc.d instead. See https://github.com/unixorn/zsh-quickstart-kit#zshrcd for more details."
echo "Make entries in ${ZDOTDIR:-$HOME}/.zshrc.d instead. See https://github.com/unixorn/zsh-quickstart-kit#zshrcd for more details."
fi
Loading
Loading