From b30489fa6326f17d0204c1e510ca675077bcba67 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Sat, 29 Oct 2022 11:35:57 +0000 Subject: [PATCH] Update dotfiles/.zshrc, dotfiles/.profile, dotfiles/.bashrc, dotfiles/.local/share/bash-completion/generate.sh, dotfiles/.local/share/bash-completion/completions/fzf.bash, dotfiles/.local/share/bash-completion/completions/fzf-key-bindings.bash --- dotfiles/.bashrc | 220 +----------------- .../completions/fzf-key-bindings.bash} | 0 .../bash-completion/completions/fzf.bash} | 0 .../.local/share/bash-completion/generate.sh | 49 ++++ dotfiles/.profile | 152 ++++++++++++ dotfiles/.zshrc | 140 ++++------- 6 files changed, 258 insertions(+), 303 deletions(-) rename dotfiles/.local/{fzf/key-bindings.bash => share/bash-completion/completions/fzf-key-bindings.bash} (100%) rename dotfiles/.local/{fzf/completion.bash => share/bash-completion/completions/fzf.bash} (100%) create mode 100644 dotfiles/.local/share/bash-completion/generate.sh diff --git a/dotfiles/.bashrc b/dotfiles/.bashrc index 02438bd5..9a5f8166 100644 --- a/dotfiles/.bashrc +++ b/dotfiles/.bashrc @@ -19,54 +19,6 @@ if [ -f "$HOME/.profile" ]; then . "$HOME/.profile" fi -COLOR_SCHEME=dark - -alias ..='cd ..' -alias cp='cp -v' -alias rm='rm -I' -alias mv='mv -iv' -alias ln='ln -sriv' -alias xclip='xclip -selection c' -command -v vim >/dev/null && alias vi='vim' - -### Colorize commands -alias ls='ls --color=auto' -alias grep='grep --color=auto' -alias fgrep='fgrep --color=auto' -alias egrep='egrep --color=auto' -alias diff='diff --color=auto' -alias ip='ip --color=auto' -alias pacman='pacman --color=auto' - -### LS & TREE -alias ll='ls -la' -alias la='ls -A' -alias l='ls -F' -command -v lsd >/dev/null && alias ls='lsd --group-dirs first' && - alias tree='lsd --tree' -command -v colorls >/dev/null && alias ls='colorls --sd --gs' && - alias tree='colorls --tree' - -### CAT & LESS -command -v bat >/dev/null && - alias bat='bat --theme=ansi' && - alias cat='bat --pager=never' && - alias less='bat' -# in debian the command is batcat -command -v batcat >/dev/null && - alias batcat='batcat --theme=ansi' && - alias cat='batcat --pager=never' && - alias less='batcat' - -### TOP -command -v htop >/dev/null && alias top='htop' -command -v gotop >/dev/null && alias top='gotop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' -command -v ytop >/dev/null && alias top='ytop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' -command -v btm >/dev/null && alias top='btm $([ "$COLOR_SCHEME" = "light" ] && echo "--color default-light")' -# themes for light/dark color-schemes inside ~/.config/bashtop; Press ESC to open the menu and change the theme -command -v bashtop >/dev/null && alias top='bashtop' -command -v bpytop >/dev/null && alias top='bpytop' - ### Settings if command -v shopt >/dev/null; then shopt -s globstar @@ -74,193 +26,43 @@ if command -v shopt >/dev/null; then shopt -s checkwinsize fi +### History HISTCONTROL=ignoreboth HISTSIZE=5000 HISTFILESIZE=5000 -HISTFILE=~/.bash_history - -# Bash Completion -if [ "$0" = 'bash' ] || [ "$0" = '/bin/bash' ]; then - if [ -f /usr/share/bash-completion/bash_completion ]; then - . /usr/share/bash-completion/bash_completion - elif [ -f /etc/bash_completion ]; then - . /etc/bash_completion - fi -fi +HISTFILE=~/.local/bash_history # Prompt (on bash only) -if { [ "$0" = 'bash' ] || [ "$0" = '/bin/bash' ]; } && [[ "$(hostname)" != *'-minimal' ]]; then +if { [ "$0" = 'bash' ] || [ "$0" = '/bin/bash' ] || [ "$SHELL" = '/bin/bash' ]; } && [[ "$(hostname)" != *'-minimal' ]]; then # Add new line before prompt PROMPT_COMMAND="PROMPT_COMMAND=echo" - if [ -f /etc/os-release ]; then - . /etc/os-release - if [ -d /Applications ] && [ -d /Library ] && [ -d /System ]; then - # macOS - OS_ICON="" - elif [ "$ID" = 'alpine' ]; then - OS_ICON="" - elif [ "$ID" = 'archlinux' ]; then - OS_ICON="" - elif [ "$ID" = 'centos' ]; then - OS_ICON="" - elif [ "$ID" = 'coreos' ]; then - OS_ICON="" - elif [ "$ID" = 'debian' ]; then - OS_ICON="" - elif [ "$ID" = 'deepin' ]; then - OS_ICON="" - elif [ "$ID" = 'elementary' ]; then - OS_ICON="" - elif [ "$ID" = 'endeavour' ]; then - OS_ICON="" - elif [ "$ID" = 'freebsd' ]; then - OS_ICON="" - elif [ "$ID" = 'gentoo' ]; then - OS_ICON="" - elif [ "$ID" = 'kali' ]; then - OS_ICON="" - elif [ "$ID" = 'linuxmint' ]; then - OS_ICON="" - elif [ "$ID" = 'manjaro' ]; then - OS_ICON="" - elif [ "$ID" = 'nixos' ]; then - OS_ICON="" - elif [ "$ID" = 'openbsd' ]; then - OS_ICON="" - elif [ "$ID" = 'opensuse' ]; then - OS_ICON="" - elif [ "$ID" = 'parrot' ]; then - OS_ICON="" - elif [ "$ID" = 'pop_os' ]; then - OS_ICON="" - elif [ "$ID" = 'raspberry_pi' ]; then - OS_ICON="" - elif [ "$ID" = 'redhat' ]; then - OS_ICON="" - elif [ "$ID" = 'fedora' ]; then - OS_ICON="" - elif [ "$ID" = 'ubuntu' ]; then - OS_ICON="" - else - OS_ICON="" - fi - else - OS_ICON="" - fi - # Set styled terminal prompt + ### Styled Terminal case "$TERM" in xterm* | rxvt* | Eterm | aterm | kterm | gnome* | alacritty) PS1="\n \[\033[0;34m\]╭─\[\033[0;31m\]\[\033[0;37m\]\[\033[41m\] $OS_ICON \u \[\033[0m\]\[\033[0;31m\]\[\033[44m\]\[\033[0;34m\]\[\033[44m\]\[\033[0;30m\]\[\033[44m\] \w \[\033[0m\]\[\033[0;34m\] \n \[\033[0;34m\]╰ \[\033[1;36m\]\$ \[\033[0m\]" ;; esac - # https://github.com/trapd00r/LS_COLORS - command -v gdircolors >/dev/null 2>&1 || gdircolors() { dircolors "$@"; } - if type gdircolors &>/dev/null && [ -f "$HOME/.config/dircolors" ]; then + ### Directory Colors (https://github.com/trapd00r/LS_COLORS) + command -v gdircolors > /dev/null 2>&1 || gdircolors() { dircolors "$@"; } + if command -v gdircolors > /dev/null && [ -f "$HOME/.config/dircolors" ]; then eval "$(gdircolors -b "$HOME/.config/dircolors")" fi fi -### Miscellaneous -export VISUAL=vim -export EDITOR=$VISUAL - -# enable terminal linewrap -setterm -linewrap on 2>/dev/null - -# colorize man pages -export LESS_TERMCAP_mb=$'\e[1;32m' -export LESS_TERMCAP_md=$'\e[1;32m' -export LESS_TERMCAP_me=$'\e[0m' -export LESS_TERMCAP_se=$'\e[0m' -export LESS_TERMCAP_so=$'\e[01;33m' -export LESS_TERMCAP_ue=$'\e[0m' -export LESS_TERMCAP_us=$'\e[1;4;31m' -export LESSHISTFILE=- - -### Functions - -rgafzf() { - RG_PREFIX="rga --files-with-matches" - local file - file="$( - FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \ - fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \ - --phony -q "$1" \ - --bind "change:reload:$RG_PREFIX {q}" \ - --preview-window="70%:wrap" - )" && - echo "opening $file" && - xdg-open "$file" -} - -# Bash completions -if [ "$0" = 'bash' ] || [ "$0" = '/bin/bash' ]; then - ### fd - [ -e /usr/local/src/fd/fd ] && source /usr/local/src/fd/autocomplete/fd.bash-completion - - ### Hyperfine - [ -e /usr/local/src/hyperfine/hyperfine ] && source /usr/local/src/hyperfine/autocomplete/hyperfine.bash-completion - - ### mcfly - export MCFLY_KEY_SCHEME=vim - [ -e /usr/local/src/mcfly/mcfly ] && eval "$(mcfly init bash)" - - ### wp-cli - [ -e /usr/local/bin/wp ] && source /usr/local/src/wp-cli/wp-completion.bash - - ### direnv - [ -e /usr/local/bin/direnv ] && eval "$(direnv hook bash)" - - ### Googler - [ -e /usr/local/bin/googler ] && source /usr/local/src/googler/googler-completion.bash - [ -e /usr/local/bin/googler ] && source /usr/local/src/googler/googler_at - - ### FZF - if [ -e fzf ]; then - if [ -f ~/.local/fzf/completion.bash ]; then - source ~/.local/fzf/completion.bash 2>/dev/null - fi - if [ -f ~/.local/fzf/key-bindings.bash ]; then - source ~/.local/fzf/key-bindings.bash - fi - fi - +### Bash Completions +if [ "$0" = 'bash' ] || [ "$0" = '/bin/bash' ] || [ "$SHELL" = '/bin/bash' ]; then ### Google Cloud SDK if command -v brew >/dev/null; then if [ -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc" ]; then . "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc" fi - if [ -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" ]; then - . "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" - fi fi ### Java (asdf) - if [ -f "$HOME/.asdf/plugins/java/set-java-home.bash" ]; then - . "$HOME/.asdf/plugins/java/set-java-home.bash" - fi - - ### zoxide - command -v zoxide >/dev/null && eval "$(zoxide init bash)" - - ### MOTD - if [ -f "$HOME/.local/motd.sh" ] && { [ -n "$SSH_CONNECTION" ] && [ "$SHLVL" -eq 1 ] && [[ $- == *i* ]]; } || type qubes-vmexec &>/dev/null || type qubes-dom0-update &>/dev/null; then - if { [ -z "$MOTD" ] || [ "$MOTD" -ne 0 ]; } && [[ "$(hostname)" != *'-minimal' ]]; then - . "$HOME/.local/motd.sh" - - # TODO - -- services - if [ -n "$SSH_CONNECTION" ]; then - bash_motd --banner --processor --memory --diskspace --services --docker --updates --letsencrypt --login - elif type qubes-vmexec &>/dev/null; then - bash_motd --banner --memory --diskspace --docker - elif type qubes-dom0-update &>/dev/null; then - bash_motd --banner --updates - else - bash_motd --banner --processor --memory --diskspace --services --docker --updates --letsencrypt --login - fi - fi + if [ -f "$HOME/.local/asdf/plugins/java/set-java-home.bash" ]; then + . "$HOME/.local/asdf/plugins/java/set-java-home.bash" fi ### Fig diff --git a/dotfiles/.local/fzf/key-bindings.bash b/dotfiles/.local/share/bash-completion/completions/fzf-key-bindings.bash similarity index 100% rename from dotfiles/.local/fzf/key-bindings.bash rename to dotfiles/.local/share/bash-completion/completions/fzf-key-bindings.bash diff --git a/dotfiles/.local/fzf/completion.bash b/dotfiles/.local/share/bash-completion/completions/fzf.bash similarity index 100% rename from dotfiles/.local/fzf/completion.bash rename to dotfiles/.local/share/bash-completion/completions/fzf.bash diff --git a/dotfiles/.local/share/bash-completion/generate.sh b/dotfiles/.local/share/bash-completion/generate.sh new file mode 100644 index 00000000..1aad828f --- /dev/null +++ b/dotfiles/.local/share/bash-completion/generate.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +### direnv +if command -v direnv > /dev/null; then + direnv hook bash > "$HOME/.local/share/bash-completion/completions/direnv.bash" +fi + +### fd +if command -v fd > /dev/null && [ -f /usr/local/src/fd/autocomplete/fd.bash-completion ]; then + cp /usr/local/src/fd/autocomplete/fd.bash-completion "$HOME/.local/share/bash-completion/completions/fd.bash" +fi + +### Google Cloud SDK +if command -v brew >/dev/null; then + if [ -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" ]; then + cat "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" > "$HOME/.local/share/bash-completion/completions/google-cloud-sdk.bash" + fi +fi + +### Googler +if command -v googler > /dev/null; then + if [ -f /usr/local/src/googler/googler-completion.bash ]; then + cp /usr/local/src/googler/googler-completion.bash "$HOME/.local/share/bash-completion/completions/googler.bash" + fi + if [ -f /usr/local/src/googler/googler_at ]; then + cp /usr/local/src/googler/googler_at "$HOME/.local/share/bash-completion/completions/googler-at.bash" + fi +fi + +### Hyperfine +if command -v hyperfine > /dev/null && [ -f /usr/local/src/hyperfine/autocomplete/hyperfine.bash-completion ]; then + cp /usr/local/src/hyperfine/autocomplete/hyperfine.bash-completion "$HOME/.local/share/bash-completion/completions/hyperfine.bash" +fi + +### mcfly +export MCFLY_KEY_SCHEME=vim +if command -v mcfly > /dev/null; then + echo "$(mcfly init bash)" > "$HOME/.local/share/bash-completion/completions/mcfly.bash" +fi + +### wp-cli (only bash available) +if command -v wp > /dev/null && [ -f /usr/local/src/wp-cli/wp-completion.bash ]; then + cp /usr/local/src/wp-cli/wp-completion.bash "$HOME/.local/share/bash-completion/completions/wp.bash" +fi + +### zoxide +if command -v zoxide >/dev/null; then + echo "$(zoxide init bash)" > "$HOME/.local/share/bash-completion/completions/zoxide.bash" +fi diff --git a/dotfiles/.profile b/dotfiles/.profile index a07a05b1..3a9847b2 100644 --- a/dotfiles/.profile +++ b/dotfiles/.profile @@ -1,5 +1,111 @@ # shellcheck disable=SC1090,SC1091 +### Miscellaneous +export VISUAL=vim +export EDITOR=$VISUAL + +### Theme +COLOR_SCHEME=dark + +### Colorize man pages +export LESS_TERMCAP_mb=$'\e[1;32m' +export LESS_TERMCAP_md=$'\e[1;32m' +export LESS_TERMCAP_me=$'\e[0m' +export LESS_TERMCAP_se=$'\e[0m' +export LESS_TERMCAP_so=$'\e[01;33m' +export LESS_TERMCAP_ue=$'\e[0m' +export LESS_TERMCAP_us=$'\e[1;4;31m' +export LESSHISTFILE=- + +### Line Wrap +setterm -linewrap on 2>/dev/null + +### Bash / ZSH +if [ "$0" = 'bash' ] || [ "$0" = '/bin/bash' ] || [ "$SHELL" = '/bin/bash' ] || [ "$0" = 'zsh' ] || [ "$0" = '/bin/zsh' ] || [ "$SHELL" = '/bin/zsh' ]; then + ### OS Detection + if [ -f /etc/os-release ]; then + . /etc/os-release + if [ "$ID" = 'alpine' ]; then + OS_ICON="" + elif [ "$ID" = 'archlinux' ]; then + OS_ICON="" + elif [ "$ID" = 'centos' ]; then + OS_ICON="" + elif [ "$ID" = 'coreos' ]; then + OS_ICON="" + elif [ "$ID" = 'debian' ]; then + OS_ICON="" + elif [ "$ID" = 'deepin' ]; then + OS_ICON="" + elif [ "$ID" = 'elementary' ]; then + OS_ICON="" + elif [ "$ID" = 'endeavour' ]; then + OS_ICON="" + elif [ "$ID" = 'freebsd' ]; then + OS_ICON="" + elif [ "$ID" = 'gentoo' ]; then + OS_ICON="" + elif [ "$ID" = 'kali' ]; then + OS_ICON="" + elif [ "$ID" = 'linuxmint' ]; then + OS_ICON="" + elif [ "$ID" = 'manjaro' ]; then + OS_ICON="" + elif [ "$ID" = 'nixos' ]; then + OS_ICON="" + elif [ "$ID" = 'openbsd' ]; then + OS_ICON="" + elif [ "$ID" = 'opensuse' ]; then + OS_ICON="" + elif [ "$ID" = 'parrot' ]; then + OS_ICON="" + elif [ "$ID" = 'pop_os' ]; then + OS_ICON="" + elif [ "$ID" = 'raspberry_pi' ]; then + OS_ICON="" + elif [ "$ID" = 'redhat' ]; then + OS_ICON="" + elif [ "$ID" = 'fedora' ]; then + OS_ICON="" + elif [ "$ID" = 'ubuntu' ]; then + OS_ICON="" + else + OS_ICON="" + fi + else + if [ -d /Applications ] && [ -d /Library ] && [ -d /System ]; then + # macOS + OS_ICON="" + else + OS_ICON="" + fi + fi + + ### MOTD + if [ -f "$HOME/.local/motd.sh" ] && { [ -n "$SSH_CONNECTION" ] && [ "$SHLVL" -eq 1 ] && [[ $- == *i* ]]; } || command -v qubes-vmexec > /dev/null || command -v qubes-dom0-update > /dev/null || { [ -d /Applications ] && [ -d /System ]; }; then + if { [ -z "$MOTD" ] || [ "$MOTD" -ne 0 ]; } && [[ "$(hostname)" != *'-minimal' ]]; then + . "$HOME/.local/motd.sh" + + # TODO - -- services + if [ -n "$SSH_CONNECTION" ]; then + # SSH + bash_motd --banner --processor --memory --diskspace --services --docker --updates --letsencrypt --login + elif command -v qubes-vmexec > /dev/null; then + # Qubes AppVM + bash_motd --banner --memory --diskspace --docker + elif command -v qubes-dom0-update > /dev/null; then + # Qubes dom0 + bash_motd --banner --updates + elif [ -d /Applications ] && [ -d /System ]; then + # macOS + bash_motd --banner + else + bash_motd --banner --processor --memory --diskspace --services --docker --updates --letsencrypt --login + fi + fi + fi +fi + # Easy file sharing from the command line, using transfer.sh transfer() { if [ $# -eq 0 ]; then @@ -112,6 +218,52 @@ resetdocker() { ### Aliases +### Colorize +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' +alias diff='diff --color=auto' +alias ip='ip --color=auto' +alias pacman='pacman --color=auto' + +### Aliases +alias cp='cp -v' +alias rm='rm -I' +alias mv='mv -iv' +alias ln='ln -sriv' +alias xclip='xclip -selection c' +command -v vim > /dev/null && alias vi='vim' + +### LS & TREE +alias ll='ls -la' +alias la='ls -A' +alias l='ls -F' +command -v lsd > /dev/null && alias ls='lsd --group-dirs first' && \ + alias tree='lsd --tree' +command -v colorls > /dev/null && alias ls='colorls --sd --gs' && \ + alias tree='colorls --tree' + +### CAT & LESS +command -v bat > /dev/null && \ + alias bat='bat --theme=ansi' && \ + alias cat='bat --pager=never' && \ + alias less='bat' +# in debian the command is batcat +command -v batcat > /dev/null && \ + alias batcat='batcat --theme=ansi' && \ + alias cat='batcat --pager=never' && \ + alias less='batcat' + +### TOP +command -v htop > /dev/null && alias top='htop' +command -v gotop > /dev/null && alias top='gotop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' +command -v ytop > /dev/null && alias top='ytop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' +command -v btm > /dev/null && alias top='btm $([ "$COLOR_SCHEME" = "light" ] && echo "--color default-light")' +# themes for light/dark color-schemes inside ~/.config/bashtop; Press ESC to open the menu and change the theme +command -v bashtop > /dev/null && alias top='bashtop' +command -v bpytop > /dev/null && alias top='bpytop' + # Create an Authelia password hash alias autheliapassword='docker run authelia/authelia:latest authelia hash-password' diff --git a/dotfiles/.zshrc b/dotfiles/.zshrc index 92210d97..b031b7b3 100644 --- a/dotfiles/.zshrc +++ b/dotfiles/.zshrc @@ -1,10 +1,20 @@ #!/usr/bin/env zsh # shellcheck disable=SC1090,SC1091,SC2034,SC2154,SC2296 -# Prefer US English +### Language / Fonts export LANG="en_US" export LC_ALL="en_US.UTF-8" +### Misc. +HISTFILE=~/.local/zsh_history +HIST_STAMPS=mm/dd/yyyy +HISTSIZE=5000 +SAVEHIST=5000 +ZLE_RPROMPT_INDENT=0 +WORDCHARS=${WORDCHARS//\/} +PROMPT_EOL_MARK= +TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S\ncpu\t%P' + ### Powerline if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" @@ -16,55 +26,6 @@ fi ### ~/.profile [[ -f "$HOME/.profile" ]] && . "$HOME/.profile" -# Configure color-scheme -COLOR_SCHEME=dark # dark/light - -### Aliases -alias cp='cp -v' -alias rm='rm -I' -alias mv='mv -iv' -alias ln='ln -sriv' -alias xclip='xclip -selection c' -command -v vim > /dev/null && alias vi='vim' - -### Colorize -alias ls='ls --color=auto' -alias grep='grep --color=auto' -alias fgrep='fgrep --color=auto' -alias egrep='egrep --color=auto' -alias diff='diff --color=auto' -alias ip='ip --color=auto' -alias pacman='pacman --color=auto' - -### LS & TREE -alias ll='ls -la' -alias la='ls -A' -alias l='ls -F' -command -v lsd > /dev/null && alias ls='lsd --group-dirs first' && \ - alias tree='lsd --tree' -command -v colorls > /dev/null && alias ls='colorls --sd --gs' && \ - alias tree='colorls --tree' - -### CAT & LESS -command -v bat > /dev/null && \ - alias bat='bat --theme=ansi' && \ - alias cat='bat --pager=never' && \ - alias less='bat' -# in debian the command is batcat -command -v batcat > /dev/null && \ - alias batcat='batcat --theme=ansi' && \ - alias cat='batcat --pager=never' && \ - alias less='batcat' - -### TOP -command -v htop > /dev/null && alias top='htop' -command -v gotop > /dev/null && alias top='gotop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' -command -v ytop > /dev/null && alias top='ytop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' -command -v btm > /dev/null && alias top='btm $([ "$COLOR_SCHEME" = "light" ] && echo "--color default-light")' -# themes for light/dark color-schemes inside ~/.config/bashtop; Press ESC to open the menu and change the theme -command -v bashtop > /dev/null && alias top='bashtop' -command -v bpytop > /dev/null && alias top='bpytop' - # --------------------------------- SETTINGS ---------------------------------- setopt AUTO_CD setopt BEEP @@ -86,15 +47,6 @@ setopt NUMERIC_GLOB_SORT setopt PROMPT_SUBST setopt SHARE_HISTORY -HISTFILE=~/.zsh_history -HIST_STAMPS=mm/dd/yyyy -HISTSIZE=5000 -SAVEHIST=5000 -ZLE_RPROMPT_INDENT=0 -WORDCHARS=${WORDCHARS//\/} -PROMPT_EOL_MARK= -TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S\ncpu\t%P' - # ZSH completion system autoload -Uz compinit @@ -136,22 +88,6 @@ PROMPT=$'%F{%(#.blue.green)}┌──(%B%F{%(#.red.blue)}%n@%m%b%F{%(#.blue.gree RPROMPT=$'%(?.. %? %F{red}%Bx%b%F{reset})%(1j. %j %F{yellow}%Bbg %b%F{reset}.)' # ----------------------------------- MISC ----------------------------------- -export VISUAL=vim -export EDITOR=$VISUAL - -# enable terminal linewrap -setterm -linewrap on 2> /dev/null - -# colorize man pages -export LESS_TERMCAP_mb=$'\e[1;32m' -export LESS_TERMCAP_md=$'\e[1;32m' -export LESS_TERMCAP_me=$'\e[0m' -export LESS_TERMCAP_se=$'\e[0m' -export LESS_TERMCAP_so=$'\e[01;33m' -export LESS_TERMCAP_ue=$'\e[0m' -export LESS_TERMCAP_us=$'\e[1;4;31m' -export LESSHISTFILE=- - # If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty) @@ -317,8 +253,9 @@ zle -N switch_powerlevel_multiline_prompt bindkey ^P switch_powerlevel_multiline_prompt ### Antigen -[[ ! -f ~/.local/antigen.zsh ]] || source ~/.local/antigen.zsh - +if [ -f "$HOME/.local/antigen.zsh" ]; then + source "$HOME/.local/antigen.zsh" +fi if command -v antigen > /dev/null; then antigen use oh-my-zsh antigen bundle git @@ -333,38 +270,53 @@ if command -v antigen > /dev/null; then antigen apply fi -## TODO -# source /Users/bzalewski/.config/broot/launcher/bash/br - ### FZF -if [ -e fzf ]; then - if [ -f ~/.local/fzf/completion.zsh ]; then - source ~/.local/fzf/completion.zsh 2> /dev/null +if command -v fzf > /dev/null; then + if [ -f "$HOME/.local/fzf/completion.zsh" ]; then + source "$HOME/.local/fzf/completion.zsh" fi - if [ -f ~/.local/fzf/key-bindings.zsh ]; then - source ~/.local/fzf/key-bindings.zsh + if [ -f "$HOME/.local/fzf/key-bindings.zsh" ]; then + source "$HOME/.local/fzf/key-bindings.zsh" fi fi ### Google Cloud SDK if command -v brew > /dev/null; then - [[ ! -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc" ]] || source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc" - [[ ! -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc" ]] || source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc" + if [ -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc" ]; then + source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc" + fi + if [ -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc" ]; then + source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc" + fi +fi + +### Hyperfine +if command -v hyperfine > /dev/null && [ -f /usr/local/src/hyperfine/autocomplete/hyperfine.zsh-completion ]; then + source /usr/local/src/hyperfine/autocomplete/hyperfine.zsh-completion fi ### Java (asdf) -if [ -f "$HOME/.asdf/plugins/java/set-java-home.zsh" ]; then - . "$HOME/.asdf/plugins/java/set-java-home.zsh" +if [ -f "$HOME/.local/asdf/plugins/java/set-java-home.zsh" ]; then + . "$HOME/.local/asdf/plugins/java/set-java-home.zsh" fi -## TODO: What is this line? -fpath+=~/.zfunc +### mcfly +export MCFLY_KEY_SCHEME=vim +if command -v mcfly > /dev/null; then + eval "$(mcfly init zsh)" +fi ### zoxide -command -v zoxide > /dev/null && eval "$(zoxide init zsh)" +if command -v zoxide > /dev/null; then + eval "$(zoxide init zsh)" +fi ### Fig -[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && . "$HOME/.fig/shell/zshrc.post.zsh" +if [ -f "$HOME/.fig/shell/zshrc.post.zsh" ]; then + source "$HOME/.fig/shell/zshrc.post.zsh" +fi ### Powerline -[[ ! -f ~/.config/p10k.zsh ]] || source ~/.p10k.zsh +if [ -f ~/.config/p10k.zsh ]; then + source ~/.config/p10k.zsh +fi