commit f9ba12fe9366f40b9460c08463497d78598e4213 Author: lfreixial Date: Tue Mar 18 19:37:20 2025 +0000 Initial upload diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4661a0d --- /dev/null +++ b/Makefile @@ -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" diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..d82a816 --- /dev/null +++ b/readme.md @@ -0,0 +1 @@ +config files for terminal applications diff --git a/zsh/.zsh_alias b/zsh/.zsh_alias new file mode 100644 index 0000000..03a4902 --- /dev/null +++ b/zsh/.zsh_alias @@ -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" \ No newline at end of file diff --git a/zsh/.zsh_debian b/zsh/.zsh_debian new file mode 100644 index 0000000..8bf679f --- /dev/null +++ b/zsh/.zsh_debian @@ -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"' \ No newline at end of file diff --git a/zsh/.zsh_exports b/zsh/.zsh_exports new file mode 100644 index 0000000..9c299b1 --- /dev/null +++ b/zsh/.zsh_exports @@ -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" \ No newline at end of file diff --git a/zsh/.zsh_functions b/zsh/.zsh_functions new file mode 100644 index 0000000..f673878 --- /dev/null +++ b/zsh/.zsh_functions @@ -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 +} \ No newline at end of file diff --git a/zsh/.zsh_init b/zsh/.zsh_init new file mode 100644 index 0000000..465b9a5 --- /dev/null +++ b/zsh/.zsh_init @@ -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 \ No newline at end of file diff --git a/zsh/.zsh_keybinds b/zsh/.zsh_keybinds new file mode 100644 index 0000000..197324f --- /dev/null +++ b/zsh/.zsh_keybinds @@ -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 diff --git a/zsh/.zsh_mac b/zsh/.zsh_mac new file mode 100644 index 0000000..2e690c4 --- /dev/null +++ b/zsh/.zsh_mac @@ -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 diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..3487e12 --- /dev/null +++ b/zsh/.zshrc @@ -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)" \ No newline at end of file