Initial upload

This commit is contained in:
2025-03-18 19:37:20 +00:00
commit f9ba12fe93
10 changed files with 205 additions and 0 deletions

7
Makefile Normal file
View File

@@ -0,0 +1,7 @@
.PHONY: zsh
zsh:
@for file in zsh/.[!.]*; do \
file=$${file#zsh/}; \
[ -f "$$HOME/$$file" ] && mv "$$HOME/$$file" "$$HOME/$$file.bak"; \
done && cp -r zsh/.[!.]* ~/ && echo "zsh files copied to home directory" || echo "zsh files not copied to home directory"

1
readme.md Normal file
View File

@@ -0,0 +1 @@
config files for terminal applications

15
zsh/.zsh_alias Normal file
View File

@@ -0,0 +1,15 @@
alias vim='nvim'
alias c='clear'
alias gt='go test ./...'
alias v='nvim'
alias lg='lazygit'
alias gcm='git checkout origin/main'
alias gce='git fetch && git pull && git commit --allow-empty -m "run-ci" && git push'
alias dcu='docker compose up -d'
alias dcub='docker compose up --build -d'
alias dcd='docker compose down'
alias dps='docker ps'
alias dk=docker_kill_fzf
alias zs='nvim ~/.zshrc'
alias sz='source ~/.zshrc'
alias ls="eza --color=always --long --git --no-filesize --icons=always --no-time --no-user --no-permissions"

2
zsh/.zsh_debian Normal file
View File

@@ -0,0 +1,2 @@
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
alias f='selected=$(find . -type f 2>/dev/null | fzf --preview "batcat --style=numbers --color=always {}") && [ -n "$selected" ] && vim "$selected"'

5
zsh/.zsh_exports Normal file
View File

@@ -0,0 +1,5 @@
# Editor
export EDITOR='vim'
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

33
zsh/.zsh_functions Normal file
View File

@@ -0,0 +1,33 @@
# NVM configuration
export NVM_DIR="$HOME/.nvm"
if [ ! -s "$NVM_DIR/nvm.sh" ]; then
echo "Installing nvm..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
fi
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
nvm use
fi
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
fzf-cd-widget() {
local dir
dir=$(find ${1:-.} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf +m) && cd "$dir"
zle reset-prompt
}

16
zsh/.zsh_init Normal file
View File

@@ -0,0 +1,16 @@
# Add Zsh plugins
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
zinit light Aloxaf/fzf-tab
# Add snippets
zinit snippet OMZP::git
zinit snippet OMZP::sudo
zinit snippet OMZP::archlinux
zinit snippet OMZP::aws
zinit snippet OMZP::kubectl
zinit snippet OMZP::kubectx
zinit snippet OMZP::command-not-found
zinit cdreplay -q

5
zsh/.zsh_keybinds Normal file
View File

@@ -0,0 +1,5 @@
bindkey -e
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
bindkey '^[w' kill-region
bindkey "^[f" fzf-cd-widget

18
zsh/.zsh_mac Normal file
View File

@@ -0,0 +1,18 @@
if [[ -f "/opt/homebrew/bin/brew" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
alias f='selected=$(find . -type f | fzf --preview "bat --style=numbers --color=always {}") && [ -n "$selected" ] && vim "$selected"'
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
#source $(brew --prefix powerlevel10k)/powerlevel10k.zsh-theme
export GOPATH=$HOME/go
export GOROOT="$(brew --prefix golang)/libexec"
alias python=/usr/bin/python3
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.1.3/bin:$PATH"
export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.1.3/bin:$PATH"
# source $(dirname $(gem which colorls))/tab_complete.sh
export PATH="/opt/homebrew/opt/ruby@3.1.3/bin:$PATH"
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

103
zsh/.zshrc Normal file
View File

@@ -0,0 +1,103 @@
# Oh My Zsh configuration
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(
git
rbenv
ruby
aws
buf
z
)
source $ZSH/oh-my-zsh.sh
# Zinit configuration
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
# Download Zinit if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
mkdir -p "$(dirname $ZINIT_HOME)"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi
# Source/Load Zinit
source "${ZINIT_HOME}/zinit.zsh"
if [ -f ~/.zsh_functions ]; then
source ~/.zsh_functions
fi
# z init
if [ -f ~/.zsh_init ]; then
source ~/.zsh_init
fi
# Keybindings
if [ -f ~/.zsh_keybinds ]; then
source ~/.zsh_keybinds
fi
# History settings
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_SAVE_NO_DUPS
setopt HIST_FIND_NO_DUPS
# Load fzf if available
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu select
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
# Aliases
if [ -f ~/.zsh_alias ]; then
source ~/.zsh_alias
fi
# Load completions
autoload -Uz compinit && compinit
# Place this after nvm initialization!
autoload -U add-zsh-hook
add-zsh-hook chpwd load-nvmrc
load-nvmrc
zle -N fzf-cd-widget
# exports
if [ -f ~/.zsh_exports ]; then
source ~/.zsh_exports
fi
# OS-specific configurations
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [ -f ~/.zsh_debian ]; then
source ~/.zsh_debian
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if [ -f ~/.zsh_mac ]; then
source ~/.zsh_mac
fi
fi
# Initialize other tools
eval "$(zoxide init --cmd cd zsh)"
eval "$(rbenv init -)"
eval "$(starship init zsh)"