Add zshrc and refactor shell configration
This commit is contained in:
parent
e23e66f801
commit
660a6e8eb5
4 changed files with 149 additions and 11 deletions
5
.bash_aliases
Normal file
5
.bash_aliases
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
alias k9=k9s
|
||||||
|
alias rsync="rsync -e 'ssh -o RemoteCommand=none'"
|
||||||
|
alias sudosu="sudo bash --rcfile ~/.bashrc"
|
||||||
|
alias bell="echo -e '\a'"
|
||||||
|
|
15
.bashrc
15
.bashrc
|
@ -147,6 +147,10 @@ fi
|
||||||
|
|
||||||
# Customizations
|
# Customizations
|
||||||
|
|
||||||
|
if [ -f ~/.profile ]; then
|
||||||
|
. ~/.profile
|
||||||
|
fi
|
||||||
|
|
||||||
# Use tmux for local unelevated shells
|
# Use tmux for local unelevated shells
|
||||||
if [ -z "${SUDO_USER}" ] && [ -z "${SSH_CONNECTION}" ] && [ -z "${TERM_PROGRAM}" ]; then
|
if [ -z "${SUDO_USER}" ] && [ -z "${SSH_CONNECTION}" ] && [ -z "${TERM_PROGRAM}" ]; then
|
||||||
tmux new -A -s local_tmux
|
tmux new -A -s local_tmux
|
||||||
|
@ -161,15 +165,10 @@ if [ $(which nvim) ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Kubernetes
|
# Kubernetes
|
||||||
alias k9=k9s
|
|
||||||
which kubectl 1> /dev/null && source <(kubectl completion bash)
|
which kubectl 1> /dev/null && source <(kubectl completion bash)
|
||||||
which helm 1> /dev/null && source <(helm completion bash)
|
which helm 1> /dev/null && source <(helm completion bash)
|
||||||
[ -d "${KREW_ROOT:-$HOME/.krew}/bin" ] && export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
|
|
||||||
|
|
||||||
# Helpful Aliases
|
# Helpful Aliases
|
||||||
alias rsync="rsync -e 'ssh -o RemoteCommand=none'"
|
|
||||||
alias sudosu="sudo bash --rcfile ~/.bashrc"
|
|
||||||
|
|
||||||
if [ -n "${SUDO_USER}" ]; then
|
if [ -n "${SUDO_USER}" ]; then
|
||||||
alias nano="nano --rcfile \"/home/${SUDO_USER}/.nanorc\""
|
alias nano="nano --rcfile \"/home/${SUDO_USER}/.nanorc\""
|
||||||
fi
|
fi
|
||||||
|
@ -178,12 +177,6 @@ fi
|
||||||
shopt -s histverify
|
shopt -s histverify
|
||||||
PROMPT_COMMAND="${PROMPT_COMMAND};history -a"
|
PROMPT_COMMAND="${PROMPT_COMMAND};history -a"
|
||||||
|
|
||||||
# Cargo binary path
|
|
||||||
[ -d "${HOME}/.cargo/bin" ] && export PATH="${PATH}:${HOME}/.cargo/bin"
|
|
||||||
|
|
||||||
# Funciton to notify after a long-running command
|
|
||||||
alias bell="echo -e '\a'"
|
|
||||||
|
|
||||||
# Apply local .bashrc to remote ssh session
|
# Apply local .bashrc to remote ssh session
|
||||||
ssh-custom() {
|
ssh-custom() {
|
||||||
remote_file=$(mktemp)
|
remote_file=$(mktemp)
|
||||||
|
|
33
.profile
Normal file
33
.profile
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# ~/.profile: executed by the command interpreter for login shells.
|
||||||
|
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
|
||||||
|
# exists.
|
||||||
|
# see /usr/share/doc/bash/examples/startup-files for examples.
|
||||||
|
# the files are located in the bash-doc package.
|
||||||
|
|
||||||
|
# the default umask is set in /etc/profile; for setting the umask
|
||||||
|
# for ssh logins, install and configure the libpam-umask package.
|
||||||
|
#umask 022
|
||||||
|
|
||||||
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
if [ -d "$HOME/bin" ] ; then
|
||||||
|
PATH="$HOME/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
if [ -d "$HOME/.local/bin" ] ; then
|
||||||
|
PATH="$HOME/.local/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "$HOME/.cargo/bin" ] ; then
|
||||||
|
PATH="$HOME/.cargo/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "${KREW_ROOT:-$HOME/.krew}/bin" ] ; then
|
||||||
|
PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set nvim as the preferred editor if available
|
||||||
|
if [ $(which nvim) ]; then
|
||||||
|
export EDITOR=nvim
|
||||||
|
fi
|
||||||
|
|
107
.zshrc
Normal file
107
.zshrc
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
# Lines configured by zsh-newuser-install
|
||||||
|
HISTFILE=~/.histfile
|
||||||
|
HISTSIZE=1000
|
||||||
|
SAVEHIST=1000
|
||||||
|
setopt autocd notify
|
||||||
|
unsetopt beep
|
||||||
|
bindkey -v
|
||||||
|
# End of lines configured by zsh-newuser-install
|
||||||
|
|
||||||
|
# SSH completion
|
||||||
|
zstyle ':completion:*:(ssh|scp|ftp|sftp|rsync):*' hosts $hosts
|
||||||
|
|
||||||
|
# The following lines were added by compinstall
|
||||||
|
zstyle :compinstall filename '/home/d_mcknight/.zshrc'
|
||||||
|
|
||||||
|
autoload -Uz compinit
|
||||||
|
compinit
|
||||||
|
# End of lines added by compinstall
|
||||||
|
|
||||||
|
# Source common envvars
|
||||||
|
[ -f ~/.profile ] && source ~/.profile
|
||||||
|
|
||||||
|
# Prompt
|
||||||
|
function precmd {
|
||||||
|
# Check previous command output and notify
|
||||||
|
if [[ $? != 0 && $? != 130 ]];then
|
||||||
|
echo -e "⚠️\a"
|
||||||
|
else
|
||||||
|
echo -e "\a"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$EUID" -eq 0 ];then
|
||||||
|
chrome_color="{red}"
|
||||||
|
else
|
||||||
|
chrome_color="{magenta}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Static prefix
|
||||||
|
prefix="%F$chrome_color┌──[%F{cyan}%n%F$chrome_color@%F{cyan}%m%F$chrome_color]-"
|
||||||
|
|
||||||
|
# Calculate extra path
|
||||||
|
if [[ ${debian_chroot} ]]; then
|
||||||
|
path_extra="(%F{red}${debian_chroot}%F$chrome_color)-"
|
||||||
|
elif [[ ${VIRTUAL_ENV} ]]; then
|
||||||
|
rel_venv=$(realpath $VIRTUAL_ENV --relative-to $PWD --relative-base /home)
|
||||||
|
path_extra="[%F{blue}${rel_venv}%F$chrome_color]-"
|
||||||
|
else;
|
||||||
|
path_extra=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Static suffix
|
||||||
|
suffix="(%F{blue}%~%F${chrome_color})"$'\n'"└%F{cyan}%#%F{white} "
|
||||||
|
|
||||||
|
PROMPT=$prefix$path_extra$suffix
|
||||||
|
PS2="%F$chrome_color└%F{cyan}>%F{white} "
|
||||||
|
}
|
||||||
|
|
||||||
|
# Aliases
|
||||||
|
alias .=source
|
||||||
|
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
||||||
|
alias k9=k9s
|
||||||
|
alias rsync="rsync -e 'ssh -o RemoteCommand=none'"
|
||||||
|
alias sudosu="sudo ZDOTDIR=$(dirname ${0:a}) zsh"
|
||||||
|
alias ll='ls -alFh'
|
||||||
|
alias ls="ls --color=auto"
|
||||||
|
alias lsl="ls --color=auto -lah"
|
||||||
|
alias ssh=ssh
|
||||||
|
# Use tmux for local unelevated shells
|
||||||
|
if [ -z "${SUDO_USER}" ] && [ -z "${SSH_CONNECTION}" ] && [ -z "${TERM_PROGRAM}" ]; then
|
||||||
|
tmux new -A -s local_tmux
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Custom dircolors
|
||||||
|
[ -f ~/.dircolors ] && eval "$(dircolors ~/.dircolors)"
|
||||||
|
|
||||||
|
# Kubernetes Completion
|
||||||
|
which kubectl 1> /dev/null && source <(kubectl completion zsh)
|
||||||
|
which helm 1> /dev/null && source <(helm completion zsh)
|
||||||
|
|
||||||
|
# Start in the home directory
|
||||||
|
cd ~
|
||||||
|
|
||||||
|
# Ensure zinit is installed
|
||||||
|
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
|
||||||
|
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
|
||||||
|
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
|
||||||
|
source "${ZINIT_HOME}/zinit.zsh"
|
||||||
|
|
||||||
|
# Load zinit plugins
|
||||||
|
zinit snippet OMZP::extract
|
||||||
|
zinit snippet OMZP::colored-man-pages
|
||||||
|
zinit snippet OMZP::encode64
|
||||||
|
zinit snippet OMZP::gh
|
||||||
|
zinit snippet OMZP::pip
|
||||||
|
zinit snippet OMZP::sudo
|
||||||
|
|
||||||
|
zinit light zsh-users/zsh-autosuggestions
|
||||||
|
zinit light zsh-users/zsh-syntax-highlighting
|
||||||
|
|
||||||
|
# Key bindings config
|
||||||
|
KEYTIMEOUT=5
|
||||||
|
# ^[ for esc; ^I for tab
|
||||||
|
bindkey '^[' autosuggest-accept
|
||||||
|
|
||||||
|
## Explicitly exit ok
|
||||||
|
#echo "" > /dev/null
|
||||||
|
|
Loading…
Reference in a new issue