updates to dotfiles zsh
This commit is contained in:
parent
393f4efb7c
commit
1b85b9f269
@ -3,6 +3,9 @@
|
||||
## errol@sancaktar.net
|
||||
##
|
||||
|
||||
# If not running interactively, don't do anything and return early
|
||||
[[ $- == *i* ]] || return
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
@ -168,3 +171,6 @@ for bcfile in ~/.bash_completion.d/*; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Set the Hi status to be displayed as part of the prompt. #!>>HI<<!#
|
||||
PS1="\$(type __hi_prompt_large &> /dev/null && __hi_prompt_large)${PS1}" #!>>HI<<!#
|
||||
|
10
config.yaml
10
config.yaml
@ -26,24 +26,24 @@
|
||||
|
||||
## Bash
|
||||
~/.bashrc:
|
||||
if: '[ $SHELL == "/bin/bash" ]'
|
||||
if: '[ $SHELL = "/bin/bash" ]'
|
||||
path: bash/bashrc
|
||||
|
||||
~/.bash_profile:
|
||||
if: '[ $SHELL == "/bin/bash" ]'
|
||||
if: '[ $SHELL = "/bin/bash" ]'
|
||||
path: bash/bash_profile
|
||||
|
||||
~/.bash_completion.d:
|
||||
if: '[ $SHELL == "/bin/bash" ]'
|
||||
if: '[ $SHELL = "/bin/bash" ]'
|
||||
path: bash/bash_completion.d
|
||||
|
||||
|
||||
## Zsh
|
||||
~/.zshrc:
|
||||
if: '[ $SHELL == "/bin/zsh" ]'
|
||||
if: '[ $SHELL = "/bin/zsh" ]'
|
||||
path: zsh/zshrc
|
||||
~/.zprofile:
|
||||
if: '[ $SHELL == "/bin/zsh" ]'
|
||||
if: '[ $SHELL = "/bin/zsh" ]'
|
||||
path: zsh/zprofile
|
||||
|
||||
## Git
|
||||
|
@ -64,6 +64,12 @@ alias gdcgrants='grants add --reason=$BUG cloud-gmec-batool-prod-rw-acl:20h clou
|
||||
|
||||
alias gcsec='gcert -m=cloud-gmec-offnet --s --reason=$BUG --use_secondary_key --ua_ca_instance=prod --noloas2 --nocorpssh'
|
||||
|
||||
alias baq='exec /google/bin/releases/bandaid-team/baq/baq "$@"'
|
||||
alias vlad='/google/bin/releases/bandaid-team/vlad_par/vlad.par'
|
||||
|
||||
bootinstall() {
|
||||
admin_session --reason=$BUG blaze run //cloud/verticals/edge/tools:set_boot_strategy -- -- --machine_name=$1;
|
||||
}
|
||||
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
@ -72,6 +78,7 @@ alias l='ls -CF'
|
||||
#batool() { /google/data/ro/projects/bandaid/batool "$@"; }
|
||||
#pancetta() { bash /google/bin/releases/bandaid-team/pancetta_par/pancetta.par "$0"; }
|
||||
riker() { /google/data/ro/projects/bandaid/riker "$0"; }
|
||||
alias bacon='/google/bin/releases/acq-netops/oob/bin/bacon --ssh_proxy'
|
||||
# Function to display BUG and MACHINE info above the Bash prompt
|
||||
|
||||
|
||||
|
@ -5,7 +5,8 @@ alias_list=(
|
||||
# General Shell Aliases
|
||||
"ll='ls -alF'"
|
||||
"ls='ls -lah --color'"
|
||||
"grep='grep --color=auto'"
|
||||
# Fix for the grep alias - use \grep to prevent alias recursion
|
||||
"grep='\\grep --color=auto'"
|
||||
"vi='vim'"
|
||||
"lpg='cd ~/git/lucidpoint'"
|
||||
"ppg='cd ~/git/personal'"
|
||||
@ -46,26 +47,24 @@ alias_list=(
|
||||
"t='tofu'"
|
||||
)
|
||||
|
||||
# Alias Functions
|
||||
# Iterate and define aliases
|
||||
for alias_def in "${alias_list[@]}"; do
|
||||
# 'eval alias' works reliably in both Bash and Zsh for these types of aliases.
|
||||
# We no longer need separate branches for Bash/Zsh due to the eval approach.
|
||||
eval "alias $alias_def"
|
||||
done
|
||||
|
||||
# Alias Function (these are shell functions, not aliases, and work in both)
|
||||
# The `gc` function is already shell-compatible as written.
|
||||
gc() {
|
||||
git add --all
|
||||
if [ -n "$1" ]
|
||||
then
|
||||
if [ -n "$1" ]; then
|
||||
git commit --all --message "$1"
|
||||
else
|
||||
git commit -m update
|
||||
git commit -m "update" # Added default message for clarity
|
||||
fi
|
||||
git push --verbose
|
||||
}
|
||||
|
||||
for alias_def in "${alias_list[@]}"; do
|
||||
if [ -n "$BASH_VERSION" ]; then
|
||||
eval "alias $alias_def"
|
||||
elif [ -n "$ZSH_VERSION" ]; then
|
||||
alias ${alias_def}
|
||||
else
|
||||
eval "alias $alias_def"
|
||||
fi
|
||||
done
|
||||
|
||||
unset alias_list alias_def
|
||||
unset alias_list alias_def # Clean up temporary variables
|
||||
|
301
zsh/zshrc
301
zsh/zshrc
@ -1,120 +1,11 @@
|
||||
## zshrc file
|
||||
## Errol Sanckatar
|
||||
## errol@sancaktar.net
|
||||
##
|
||||
# Core Zsh settings
|
||||
HISTSIZE=5000000
|
||||
HISTFILE=~/.zsh_history
|
||||
SAVEHIST=$HISTSIZE
|
||||
|
||||
# HomeBrew
|
||||
function ensure_brew_packages {
|
||||
local packages=("$@")
|
||||
local cellar_dir="/opt/homebrew/Cellar"
|
||||
local caskroom_dir="/opt/homebrew/Caskroom"
|
||||
|
||||
for package in "${packages[@]}"; do
|
||||
# Check if the package exists in Cellar (for formulae)
|
||||
if [ -d "$cellar_dir/$package" ]; then
|
||||
# echo "$package (formula) is already installed."
|
||||
# Check if the package exists in Caskroom (for casks)
|
||||
elif [ -d "$caskroom_dir/$package" ]; then
|
||||
# echo "$package (cask) is already installed."
|
||||
else
|
||||
echo "Installing $package..."
|
||||
# Install or upgrade package based on whether it's a cask
|
||||
if brew info --cask $package &>/dev/null; then
|
||||
brew install --cask --force $package
|
||||
else
|
||||
brew install --force $package
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
brew_packages=(
|
||||
"opentofu"
|
||||
"docker"
|
||||
"docker-completion"
|
||||
"helm"
|
||||
"ipython"
|
||||
"jq"
|
||||
"k9s"
|
||||
"kubernetes-cli"
|
||||
"neovim"
|
||||
"nmap"
|
||||
"stow"
|
||||
"terragrunt"
|
||||
"tmux"
|
||||
"font-hack-nerd-font"
|
||||
"alacritty"
|
||||
"spotify"
|
||||
"tailscale"
|
||||
"visual-studio-code"
|
||||
"fzf"
|
||||
"ripgrep"
|
||||
"fd"
|
||||
"spotify_player"
|
||||
)
|
||||
|
||||
|
||||
|
||||
function alacritty_config_setup {
|
||||
if [[ -f $HOME/.config/alacritty/alacritty-base.toml ]]
|
||||
then
|
||||
# echo $(pwd)
|
||||
toml_files=("$HOME/.config/alacritty/alacritty-base.toml" "$HOME/.config/alacritty/alacritty-$1.toml")
|
||||
combined_file="$HOME/.config/alacritty/alacritty.toml"
|
||||
echo -n > "$combined_file"
|
||||
for file in "${toml_files[@]}"; do
|
||||
# Check if the file exists
|
||||
if [ -f "$file" ]; then
|
||||
# Append content of the current TOML file to the combined file
|
||||
cat "$file" >> "$combined_file"
|
||||
# Add a newline to separate TOML sections (optional)
|
||||
echo >> "$combined_file"
|
||||
else
|
||||
echo "File '$file' not found. Skipping."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
function shell_start_disp {
|
||||
echo -n "$(hostname) - "
|
||||
if [[ -f /sbin/ifconfig ]]
|
||||
then
|
||||
ifconfig | awk '/inet / && !/inet6/ && !/127.0.0.1/ {ips = ips " " $2} END {print ips}'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
## Check for HomeBrew
|
||||
if [[ -f "/opt/homebrew/bin/brew" ]] then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
export HOMEBREW_NO_ENV_HINTS=1
|
||||
ensure_brew_packages $brew_packages
|
||||
fi
|
||||
|
||||
# IF Linux
|
||||
if [[ `uname` == "Linux" ]]
|
||||
then
|
||||
[[ ":$PATH:" != *":/home/errol/Applications:"* ]] && PATH="/home/errol/Applications:${PATH}"
|
||||
# The next line updates PATH for the Google Cloud SDK.
|
||||
if [ -f '/home/errol/google-cloud-sdk/path.zsh.inc' ]; then . '/home/errol/google-cloud-sdk/path.zsh.inc'; fi
|
||||
|
||||
# The next line enables shell command completion for gcloud.
|
||||
if [ -f '/home/errol/google-cloud-sdk/completion.zsh.inc' ]; then . '/home/errol/google-cloud-sdk/completion.zsh.inc'; fi
|
||||
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
|
||||
|
||||
# Alacritty Crap
|
||||
alacritty_config_setup linux
|
||||
fi
|
||||
|
||||
## IF MacOS
|
||||
if [[ $(uname) == "Darwin" ]]
|
||||
then
|
||||
|
||||
# Alacritty Crap
|
||||
alacritty_config_setup osx
|
||||
fi
|
||||
|
||||
shell_start_disp
|
||||
setopt EXTENDED_HISTORY APPEND_HISTORY SHARE_HISTORY HIST_IGNORE_SPACE
|
||||
setopt HIST_IGNORE_ALL_DUPS HIST_SAVE_NO_DUPS HIST_IGNORE_DUPS HIST_FIND_NO_DUPS
|
||||
setopt AUTOCD
|
||||
|
||||
# Keybindings
|
||||
bindkey -e
|
||||
@ -122,77 +13,145 @@ bindkey '^p' history-search-backward
|
||||
bindkey '^n' history-search-forward
|
||||
bindkey '^[w' kill-region
|
||||
|
||||
# Alias
|
||||
if [[ -r ~/.aliasrc ]]; then
|
||||
. ~/.aliasrc
|
||||
fi
|
||||
|
||||
# History
|
||||
HISTSIZE=5000000
|
||||
HISTFILE=~/.zsh_history
|
||||
SAVEHIST=$HISTSIZE
|
||||
|
||||
setopt EXTENDED_HISTORY
|
||||
setopt APPEND_HISTORY
|
||||
setopt SHARE_HISTORY
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt HIST_FIND_NO_DUPS
|
||||
|
||||
# Fuzzy search
|
||||
function fh() {
|
||||
eval $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')
|
||||
}
|
||||
|
||||
# history with search
|
||||
function h() {
|
||||
# check if we passed any parameters
|
||||
if [ -z "$*" ]; then
|
||||
# if no parameters were passed print entire history
|
||||
history 1
|
||||
else
|
||||
# if words were passed use it as a search
|
||||
history 1 | egrep --color=auto "$@"
|
||||
fi
|
||||
}
|
||||
# Auto CD
|
||||
setopt AUTOCD
|
||||
|
||||
# Completion styling
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
||||
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
zstyle ':completion:*' menu no
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
|
||||
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
|
||||
zstyle ':completion:*' range 1000:100 # Try 100 history words at a time; max 1000 words.
|
||||
zstyle ':completion:*' range 1000:100
|
||||
|
||||
# Path Management (Linux specific from your original file)
|
||||
# This assumes your main environment is Linux given the path elements.
|
||||
# If this is a dual-boot or you frequently switch OS,
|
||||
# you might need to adjust the PATH logic further.
|
||||
if [[ $(uname) == "Linux" ]]; then
|
||||
# Ensure /usr/local/bin is at the front
|
||||
PATH="/usr/local/bin:$PATH"
|
||||
|
||||
# Check Starship is installed
|
||||
if which starship &> /dev/null
|
||||
then
|
||||
# Google Cloud SDK PATH and completion
|
||||
if [ -f '/home/errol/google-cloud-sdk/path.zsh.inc' ]; then
|
||||
. '/home/errol/google-cloud-sdk/path.zsh.inc'
|
||||
fi
|
||||
if [ -f '/home/errol/google-cloud-sdk/completion.zsh.inc' ]; then
|
||||
. '/home/errol/google-cloud-sdk/completion.zsh.inc'
|
||||
fi
|
||||
|
||||
# Krew (Kubernetes plugin manager)
|
||||
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
|
||||
|
||||
# Google Application Credentials
|
||||
export GOOGLE_APPLICATION_CREDENTIALS=/Users/errol/.config/gcloud/application_default_credentials.json
|
||||
|
||||
# Alacritty config setup
|
||||
alacritty_config_setup linux
|
||||
fi
|
||||
|
||||
# Homebrew setup (for macOS and Linuxbrew)
|
||||
if [[ -f "/opt/homebrew/bin/brew" ]]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
export HOMEBREW_NO_ENV_HINTS=1
|
||||
# Function to ensure Homebrew packages are installed
|
||||
function ensure_brew_packages {
|
||||
local packages=("$@")
|
||||
local cellar_dir="/opt/homebrew/Cellar"
|
||||
local caskroom_dir="/opt/homebrew/Caskroom"
|
||||
for package in "${packages[@]}"; do
|
||||
if ! [[ -d "$cellar_dir/$package" || -d "$caskroom_dir/$package" ]]; then
|
||||
echo "Installing $package..."
|
||||
if brew info --cask "$package" &>/dev/null; then
|
||||
brew install --cask --force "$package"
|
||||
else
|
||||
brew install --force "$package"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
# List of Homebrew packages to ensure are installed
|
||||
brew_packages=(
|
||||
"opentofu" "docker" "docker-completion" "helm" "ipython" "jq" "k9s"
|
||||
"kubernetes-cli" "neovim" "nmap" "stow" "terragrunt" "tmux" "font-hack-nerd-font"
|
||||
"alacritty" "spotify" "tailscale" "visual-studio-code" "fzf" "ripgrep"
|
||||
"fd" "spotify_player"
|
||||
)
|
||||
ensure_brew_packages "${brew_packages[@]}"
|
||||
fi
|
||||
|
||||
# Alacritty config setup (for macOS)
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
alacritty_config_setup osx
|
||||
fi
|
||||
|
||||
# Shell start display
|
||||
function shell_start_disp {
|
||||
echo -n "$(hostname) - "
|
||||
if command -v ifconfig &>/dev/null; then # Use command -v for portability
|
||||
ifconfig | awk '/inet / && !/inet6/ && !/127.0.0.1/ {ips = ips " " $2} END {print ips}'
|
||||
elif command -v ip &>/dev/null; then # Fallback for systems without ifconfig
|
||||
ip -4 addr show | awk '/inet / && !/127.0.0.1/ {print $2}' | cut -d/ -f1 | tr '\n' ' '
|
||||
fi
|
||||
echo # Add a newline to separate prompt from output
|
||||
}
|
||||
shell_start_disp
|
||||
|
||||
# Load aliases and Google specific configurations
|
||||
if [[ -r ~/.aliasrc ]]; then
|
||||
. ~/.aliasrc
|
||||
fi
|
||||
if [[ -r ~/.google_rc ]]; then
|
||||
. ~/.google_rc
|
||||
fi
|
||||
|
||||
# Fuzzy search history
|
||||
function fh() {
|
||||
eval $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')
|
||||
}
|
||||
|
||||
# History search function (fixes the grep issue by using \grep)
|
||||
function h() {
|
||||
if [ -z "$*" ]; then
|
||||
history 1
|
||||
else
|
||||
history 1 | \grep --color=auto "$@" # Use \grep to avoid alias recursion
|
||||
fi
|
||||
}
|
||||
|
||||
# Starship prompt
|
||||
if command -v starship &> /dev/null; then
|
||||
eval "$(starship init zsh)"
|
||||
else
|
||||
# Simplified installation, assumes curl is available and interactive script is okay
|
||||
# You might want to make this non-interactive or pre-download in a production setup
|
||||
curl -sS https://starship.rs/install.sh | sh
|
||||
fi
|
||||
# Created by `pipx` on 2024-07-16 03:28:59
|
||||
export PATH="$PATH:/Users/errol/.local/bin"
|
||||
|
||||
if [[ ! -d ~/.tmux/plugins/tpm ]]
|
||||
then
|
||||
# tmux plugin manager
|
||||
if [[ ! -d ~/.tmux/plugins/tpm ]]; then
|
||||
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
||||
fi
|
||||
# The next line updates PATH for the Google Cloud SDK.
|
||||
if [ -f '/Users/errol/Downloads/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/errol/Downloads/google-cloud-sdk/path.zsh.inc'; fi
|
||||
|
||||
# The next line enables shell command completion for gcloud.
|
||||
if [ -f '/Users/errol/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/errol/Downloads/google-cloud-sdk/completion.zsh.inc'; fi
|
||||
|
||||
export GOOGLE_APPLICATION_CREDENTIALS=/Users/errol/.config/gcloud/application_default_credentials.json
|
||||
|
||||
# Gam alias
|
||||
alias gam="/home/errol/bin/gamadv-xtd3/gam"
|
||||
if which kubectl &> /dev/null
|
||||
then
|
||||
|
||||
# Kubectl completion
|
||||
if command -v kubectl &> /dev/null; then
|
||||
source <(kubectl completion zsh)
|
||||
fi
|
||||
|
||||
# --- Helper Functions (defined at the end for clarity) ---
|
||||
# Function to setup Alacritty configuration
|
||||
function alacritty_config_setup {
|
||||
if [[ -f "$HOME/.config/alacritty/alacritty-base.toml" ]]; then
|
||||
local toml_files=("$HOME/.config/alacritty/alacritty-base.toml" "$HOME/.config/alacritty/alacritty-$1.toml")
|
||||
local combined_file="$HOME/.config/alacritty/alacritty.toml"
|
||||
echo -n > "$combined_file"
|
||||
for file in "${toml_files[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
cat "$file" >> "$combined_file"
|
||||
echo >> "$combined_file" # Add newline
|
||||
else
|
||||
echo "File '$file' not found. Skipping."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user