diff --git a/nvim/dot-config/nvim/lua/plugins/treesitter.lua b/nvim/dot-config/nvim/lua/plugins/treesitter.lua index 1628771..d40c158 100644 --- a/nvim/dot-config/nvim/lua/plugins/treesitter.lua +++ b/nvim/dot-config/nvim/lua/plugins/treesitter.lua @@ -17,6 +17,7 @@ return { "regex", "bash", "fish", + "zsh", "typescript", "javascript", "tsx", diff --git a/zsh/dot-zshenv b/zsh/dot-zshenv new file mode 100644 index 0000000..b71684c --- /dev/null +++ b/zsh/dot-zshenv @@ -0,0 +1,19 @@ +export EDITOR='nvim' +export DIFFPROG='delta' + +export FZF_CTRL_T_COMMAND='fd --type f --type d --hidden --exclude ".git/"' +export FZF_DEFAULT_COMMAND='fd --type f --type d --hidden --exclude ".git/"' +export FZF_ALT_C_COMMAND='fd --type d --hidden --exclude ".git/"' + +export GOPATH="$HOME/code/go" +export GOBIN="$GOPATH/bin" + +export BUN_INSTALL="$HOME/.bun" +export PNPM_HOME="$HOME/.local/share/pnpm" + +PATH="$BUN_INSTALL/bin:$PATH" +PATH="$PNPM_HOME/bin:$PATH" +PATH="$GOBIN:$PATH" +PATH="$HOME/.local/bin:$PATH" +PATH="$HOME/code/scripts:$PATH" +export PATH diff --git a/zsh/dot-zshrc b/zsh/dot-zshrc new file mode 100644 index 0000000..9da5c05 --- /dev/null +++ b/zsh/dot-zshrc @@ -0,0 +1,102 @@ +# --- History --- +HISTFILE=~/.histfile +HISTSIZE=1000 +SAVEHIST=2000 + +# --- Options --- +setopt autocd +setopt sharehistory +setopt histignoredups +setopt histignorealldups +setopt histsavenodups +bindkey -v + +# --- Completion --- +zstyle :compinstall filename '/home/m/.zshrc' +autoload -Uz compinit +compinit + +# --- Aliases --- +alias ll='ls -l' +alias la='ls -lA' +alias o='opencode run --thinking' +alias oc='opencode' +alias sctl='sudo systemctl' +alias uctl='systemctl --user' + +# --- Keybinds --- +bindkey '.,' open-nvim +bindkey ',l' clear-screen +bindkey ',r' fzf-history-widget +bindkey ',f' fzf-file-widget +bindkey ',c' fzf-cd-widget + +# --- Functions --- +function open-nvim { nvim; } +zle -N open-nvim open-nvim + +function m { + local tmp cwd + tmp="$(mktemp -t "yazi-cwd.XXXXXX")" + command yazi "$@" --cwd-file="$tmp" + IFS= read -r -d '' cwd <"$tmp" + [ "$cwd" != "$PWD" ] && [ -d "$cwd" ] && builtin cd -- "$cwd" + rm -f -- "$tmp" +} + +# --- Prompt Configuration --- +prompt_char='>' + +function set_prompt { + local branch + branch="$(git branch --show-current 2>/dev/null)" + + if [[ "$PWD" == "$HOME" ]]; then + PROMPT="%F{magenta}%~%f $prompt_char " + elif [[ "$branch" != '' ]]; then + PROMPT="%F{magenta}%~%f ($branch) +$prompt_char " + else + PROMPT="%F{magenta}%~%f +$prompt_char " + fi +} +autoload -Uz add-zsh-hook +add-zsh-hook precmd set_prompt + +function set_prompt_char { + local old + old=$prompt_char + + if [[ $KEYMAP == vicmd && $REGION_ACTIVE != 0 ]]; then + prompt_char='v' + elif [[ $KEYMAP == vicmd ]]; then + prompt_char='<' + else + prompt_char='>' + fi + + if [[ $prompt_char != "$old" ]]; then + set_prompt + zle reset-prompt + fi +} +autoload -Uz add-zle-hook-widget +add-zle-hook-widget line-pre-redraw set_prompt_char + +# --- External Tools & Plugins --- +command -v mise >/dev/null && eval "$(mise activate zsh)" +command -v zoxide >/dev/null && eval "$(zoxide init zsh)" +command -v fzf >/dev/null && eval "$(fzf --zsh)" +command -v lsd >/dev/null && alias ls='lsd' + +if [[ -d ~/.zsh ]]; then + source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh + source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + source ~/.zsh/zsh-history-substring-search/zsh-history-substring-search.zsh + + bindkey '^[[A' history-substring-search-up + bindkey '^[[B' history-substring-search-down + bindkey -M vicmd 'k' history-substring-search-up + bindkey -M vicmd 'j' history-substring-search-down +fi