-
Notifications
You must be signed in to change notification settings - Fork 2
add zsh configuration; stock is way too bland #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| function la | ||
| ls -a $argv | ||
| ls -a --git $argv | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| function ll | ||
| ls -l $argv | ||
| ls -lh --git $argv | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # ~/.config/zsh/plugins.zsh | ||
|
|
||
| ZPLUGINDIR="${ZDOTDIR:-$HOME/.config/zsh}/plugins" | ||
|
|
||
| _zplugin_load() { | ||
| local plugin_path="${ZPLUGINDIR}/${2}" | ||
| if [[ ! -d "$plugin_path" ]]; then | ||
| mkdir -p "$ZPLUGINDIR" | ||
| echo "Installing ${2}..." | ||
| git clone --depth=1 "https://github.com/${1}/${2}" "$plugin_path" \ | ||
| || { echo "ERROR: failed to install ${2}" >&2; return 1; } | ||
| fi | ||
| source "${plugin_path}/${2}.plugin.zsh" | ||
| } | ||
|
|
||
| zplugin-update() { | ||
| local dir | ||
| for dir in "${ZPLUGINDIR}"/*/; do | ||
| echo "Updating ${dir:t}..." | ||
| git -C "$dir" pull --ff-only | ||
| done | ||
| } | ||
|
|
||
| _zplugin_load zsh-users zsh-autosuggestions | ||
| _zplugin_load zsh-users zsh-history-substring-search | ||
| _zplugin_load jeffreytse zsh-vi-mode | ||
| _zplugin_load zdharma-continuum fast-syntax-highlighting | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # ~/.config/zsh/.zshenv | ||
| # | ||
| # to bootstrap zsh to this config, ensure /etc/zshenv has this entry: | ||
| # | ||
| # if [[ -d "$HOME/.config/zsh" ]] | ||
| # then | ||
| # export ZDOTDIR="$HOME/.config/zsh" | ||
| # fi | ||
|
|
||
| # ---------- XDG base directories ---------- | ||
| # Centralizes config/cache/data locations | ||
| export XDG_CONFIG_HOME="$HOME/.config" | ||
| export XDG_CACHE_HOME="$HOME/.cache" | ||
| export XDG_DATA_HOME="$HOME/.local/share" | ||
| export XDG_STATE_HOME="$HOME/.local/state" | ||
|
|
||
| export EDITOR="nvim" | ||
| export VISUAL="nvim" | ||
| export LESS="-c -i -x4 -J -w -M -r" | ||
|
|
||
| if [[ ! -d "$XDG_DATA_HOME/zsh" ]] | ||
| then | ||
| mkdir -p "$XDG_DATA_HOME/zsh" | ||
| fi | ||
| if [[ ! -d "$XDG_STATE_HOME/zsh" ]] | ||
| then | ||
| mkdir -p "$XDG_STATE_HOME/zsh" | ||
| fi | ||
|
davidjenni marked this conversation as resolved.
|
||
|
|
||
| if command -v bat >/dev/null 2>&1; then | ||
| export MANPAGER="bat -l man -p" | ||
| fi | ||
|
|
||
| export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship.toml" | ||
|
|
||
| export PATH="$HOME/.local/bin:$PATH" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # ~/.config/zsh/.zshrc | ||
|
|
||
| HISTFILE="$XDG_STATE_HOME/zsh/history" | ||
| HISTSIZE=100000 | ||
| SAVEHIST=100000 | ||
|
|
||
| setopt APPEND_HISTORY | ||
| setopt SHARE_HISTORY | ||
| setopt HIST_IGNORE_DUPS | ||
| setopt HIST_IGNORE_SPACE | ||
| setopt HIST_EXPIRE_DUPS_FIRST | ||
| setopt HIST_FIND_NO_DUPS | ||
|
|
||
| setopt AUTOCD | ||
| setopt NOBEEP | ||
| setopt NUMERIC_GLOB_SORT # sort file10 after file9, not after file1 | ||
|
|
||
| # Initialize zoxide | ||
| eval "$(zoxide init zsh)" | ||
|
davidjenni marked this conversation as resolved.
|
||
|
|
||
| # Load completion system | ||
| autoload -Uz compinit | ||
|
davidjenni marked this conversation as resolved.
|
||
| # Ensure completion cache directory exists | ||
| mkdir -p -- "$XDG_CACHE_HOME/zsh" | ||
| # Initialize completion with cached metadata file | ||
| compinit -d "$XDG_CACHE_HOME/zsh/zcompdump" | ||
|
|
||
| zstyle ':completion:*' menu select | ||
| # Make completion case-insensitive | ||
| zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' # lowercase input matches upper and lower | ||
|
|
||
| alias l='bat' | ||
| alias ls='eza --sort ext --group-directories-first --classify --icons' | ||
| alias ll='eza -lh --sort ext --group-directories-first --classify --icons --git' | ||
| alias la='eza -lah --sort ext --group-directories-first --classify --icons --git' | ||
| alias tree='eza --tree --sort ext --group-directories-first --classify --icons' | ||
| # Reuse ls completions for eza (avoids defining a separate completion function) | ||
| compdef eza=ls | ||
|
|
||
| alias cat='bat' | ||
| alias grep='rg --color=auto' | ||
| alias diff='diff --color=auto' | ||
| alias df='df -h' | ||
|
|
||
| alias -- -='cd -' # -- prevents - being parsed as a flag; cd - jumps to previous directory | ||
|
|
||
| alias v='nvim' | ||
| alias vi='nvim' | ||
| alias vim='nvim' | ||
|
|
||
| ## FZF Configuration | ||
| export FZF_DEFAULT_COMMAND='fd --type f --hidden --strip-cwd-prefix' # strip-cwd-prefix removes the leading ./ from results | ||
| # Ctrl-T uses fd | ||
| export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | ||
|
|
||
| export FZF_DEFAULT_OPTS=' | ||
| --height=60% | ||
| --layout=reverse | ||
| --border=rounded | ||
| --prompt=" " | ||
| --pointer=" " | ||
| --preview-window=right:65%:wrap:border-left | ||
| ' | ||
|
|
||
| export _FZF_PREVIEW_CMD='bat --color=always --style=plain,numbers --line-range=:500 {}' | ||
| export FZF_CTRL_T_OPTS="--preview '$_FZF_PREVIEW_CMD'" | ||
|
|
||
| # Ctrl+F: file picker excluding hidden files | ||
| _fzf_file_no_hidden() { | ||
| local cmd result | ||
| cmd="${FZF_DEFAULT_COMMAND/--hidden /}" | ||
| result=$(eval "${cmd:-find . -type f}" | fzf --preview "$_FZF_PREVIEW_CMD") \ | ||
|
davidjenni marked this conversation as resolved.
|
||
| && LBUFFER+="$result" # LBUFFER is the text left of the cursor | ||
| zle reset-prompt | ||
| } | ||
| zle -N _fzf_file_no_hidden | ||
|
|
||
| # macOS / Homebrew (Apple Silicon) | ||
| if [[ -f /opt/homebrew/opt/fzf/shell/key-bindings.zsh ]]; then | ||
| source /opt/homebrew/opt/fzf/shell/key-bindings.zsh | ||
| source /opt/homebrew/opt/fzf/shell/completion.zsh | ||
| fi | ||
|
|
||
| # Arch | ||
| if [[ -f /usr/share/fzf/key-bindings.zsh ]]; then | ||
| source /usr/share/fzf/key-bindings.zsh | ||
| source /usr/share/fzf/completion.zsh | ||
| fi | ||
|
|
||
| # Ubuntu | ||
| if [[ -f /usr/share/doc/fzf/examples/key-bindings.zsh ]]; then | ||
| source /usr/share/doc/fzf/examples/key-bindings.zsh | ||
| source /usr/share/doc/fzf/examples/completion.zsh | ||
| fi | ||
|
|
||
| # Cursor shape per vi mode | ||
| ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BEAM | ||
| ZVM_NORMAL_MODE_CURSOR=$ZVM_CURSOR_BLOCK | ||
| ZVM_VISUAL_MODE_CURSOR=$ZVM_CURSOR_BLOCK | ||
|
|
||
| ZVM_VI_HIGHLIGHT_BACKGROUND=none | ||
| ZVM_VI_HIGHLIGHT_FOREGROUND=none | ||
| ZVM_VI_HIGHLIGHT_EXTRASTYLE=none | ||
|
|
||
| # zsh-vi-mode resets all bindings on init, so custom bindings | ||
| # must be registered via this hook to survive. | ||
| zvm_after_init() { | ||
| # Ctrl+F -> fzf file picker (no hidden files) | ||
| bindkey '^F' _fzf_file_no_hidden | ||
|
|
||
| # Ctrl+\ -> toggle autosuggestions (useful for screen recordings) | ||
| bindkey '^\' autosuggest-toggle | ||
|
|
||
| bindkey '^[[A' history-substring-search-up | ||
| bindkey '^[[B' history-substring-search-down | ||
| } | ||
|
|
||
| # Plugins and plugin manager | ||
| source "$ZDOTDIR/plugins.zsh" | ||
|
|
||
| if [[ -f "$HOME/.cargo/env" ]]; then | ||
| source "$HOME/.cargo/env" | ||
| fi | ||
|
|
||
| eval "$(starship init zsh)" | ||
|
davidjenni marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.