236 lines
6.4 KiB
Bash
236 lines
6.4 KiB
Bash
# Setup zinit home and startup
|
|
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
|
|
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
|
|
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
|
|
|
|
# source zinit
|
|
source "${ZINIT_HOME}/zinit.zsh"
|
|
|
|
# Add in 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
|
|
zinit light junegunn/fzf-git.sh
|
|
|
|
# Homebrew
|
|
eval "$(brew shellenv)"
|
|
|
|
# Load completions
|
|
autoload -U compinit && compinit
|
|
|
|
# My configurations
|
|
# Colors
|
|
autoload -U colors && colors
|
|
|
|
# Prompt
|
|
PROMPT="%(!.%F{red}%n.%F{green}%n)%{$reset_color%}@%F{magenta}%m %F{blue}%(5~|%-2~/…/%2~|%4~) %(?.%F{green}.%F{red})%(?..[%?] )%{$reset_color%}%(!.%F{red}%#.%F{green}%#)%{$reset_color%} "
|
|
|
|
# keybindings
|
|
bindkey -v
|
|
bindkey "^p" history-search-backward
|
|
bindkey "^n" history-search-forward
|
|
bindkey -r "^G^B" fzf-git-branches-widget
|
|
bindkey -r "^G^E" fzf-git-each_ref-widget
|
|
bindkey -r "^G^F" fzf-git-files-widget
|
|
bindkey -r "^G^H" fzf-git-hashes-widget
|
|
bindkey -r "^G^L" fzf-git-lreflogs-widget
|
|
bindkey -r "^G^R" fzf-git-remotes-widget
|
|
bindkey -r "^G^S" fzf-git-stashes-widget
|
|
bindkey -r "^G^T" fzf-git-tags-widget
|
|
bindkey -r "^G^W" fzf-git-worktrees-widget
|
|
bindkey -r "^Gb" fzf-git-branches-widget
|
|
bindkey -r "^Ge" fzf-git-each_ref-widget
|
|
bindkey -r "^Gf" fzf-git-files-widget
|
|
bindkey -r "^Gh" fzf-git-hashes-widget
|
|
bindkey -r "^Gl" fzf-git-lreflogs-widget
|
|
bindkey -r "^Gr" fzf-git-remotes-widget
|
|
bindkey -r "^Gs" fzf-git-stashes-widget
|
|
bindkey -r "^Gt" fzf-git-tags-widget
|
|
bindkey "^[w" fzf-git-worktrees-widget
|
|
bindkey "^[b" fzf-git-branches-widget
|
|
bindkey "^[e" fzf-git-each_ref-widget
|
|
bindkey "^[f" fzf-git-files-widget
|
|
bindkey "^[h" fzf-git-hashes-widget
|
|
bindkey "^[l" fzf-git-lreflogs-widget
|
|
bindkey "^[r" fzf-git-remotes-widget
|
|
bindkey "^[s" fzf-git-stashes-widget
|
|
bindkey "^[t" fzf-git-tags-widget
|
|
bindkey "^[w" fzf-git-worktrees-widget
|
|
|
|
|
|
# History
|
|
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
|
|
|
|
# Copmletion styling
|
|
zstyle ":completion:*" matcher-list "m:{a-z}={A-Za-z}"
|
|
zstyle ":completion:*" list-colors "${(s.:.)LS_COLORS}"
|
|
# disable sort when completing `git checkout`
|
|
zstyle ":completion:*:git-checkout:*" sort false
|
|
# set descriptions format to enable group support
|
|
# NOTE: don"t use escape sequences (like "%F{red}%d%f") here, fzf-tab will ignore them
|
|
#zstyle ":completion:*:descriptions" format "[%d]"
|
|
# set list-colors to enable filename colorizing
|
|
#zstyle ":completion:*" list-colors ${(s.:.)LS_COLORS}
|
|
# force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix
|
|
#zstyle ":completion:*" menu no
|
|
## preview directory"s content with eza when completing cd
|
|
#zstyle ":fzf-tab:complete:cd:*" fzf-preview "eza -1 --color=always $realpath"
|
|
## custom fzf flags
|
|
## NOTE: fzf-tab does not follow FZF_DEFAULT_OPTS by default
|
|
#zstyle ":fzf-tab:*" fzf-flags --color=fg:1,fg+:2 --bind=tab:accept
|
|
## To make fzf-tab follow FZF_DEFAULT_OPTS.
|
|
## NOTE: This may lead to unexpected behavior since some flags break this plugin. See Aloxaf/fzf-tab#455.
|
|
#zstyle ":fzf-tab:*" use-fzf-default-opts yes
|
|
## switch group using `<` and `>`
|
|
#zstyle ":fzf-tab:*" switch-group "<" ">"
|
|
#zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
|
|
|
|
# Start tmux
|
|
ID=$(id -u)
|
|
if [[ "$TMUX" = "" && $ID != 0 ]]; then
|
|
/opt/homebrew/bin/tmux
|
|
fi
|
|
|
|
# PATH
|
|
# Homebrew
|
|
export PATH="/opt/homebrew/bin:$PATH"
|
|
export PATH="/opt/homebrew/sbin:$PATH"
|
|
|
|
# Local PATH
|
|
export PATH=$PATH:$HOME/.local/bin
|
|
|
|
# Mason PATH
|
|
export PATH=$PATH:$HOME/.local/share/nvim/mason/bin
|
|
|
|
# Java
|
|
export PATH="$PATH:/opt/homebrew/Cellar/openjdk/23.0.1/bin"
|
|
|
|
# Ruby
|
|
#export PATH=$PATH:/opt/homebrew/opt/ruby/bin
|
|
#export PATH=$PATH:/opt/homebrew/lib/ruby/gems/3.4.0/bin
|
|
|
|
# Zig
|
|
export PATH=$PATH:/opt/zig
|
|
|
|
# pyenv
|
|
export PYENV_ROOT="$HOME/.pyenv"
|
|
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
|
|
eval "$(pyenv init - zsh)"
|
|
eval "$(pyenv virtualenv-init -)"
|
|
|
|
|
|
# VARIABLES
|
|
if [ $ID != 0 ]; then
|
|
# ssh and gpg
|
|
export GPG_TTY=$(tty)
|
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
|
gpgconf --launch gpg-agent
|
|
gpg-connect-agent updatestartuptty /bye > /dev/null
|
|
fi
|
|
|
|
# bat
|
|
export BAT_THEME='tokyonight_night'
|
|
|
|
# Editor
|
|
export EDITOR='nvim'
|
|
|
|
# Manpager
|
|
#export PAGER='nvim +Man!'
|
|
|
|
# fzf
|
|
export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always --line-range :500 {}'"
|
|
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head 200'"
|
|
|
|
# Term for ssh
|
|
#export TERM="xterm-256color"
|
|
|
|
# Homebrew
|
|
export HOMEBREW_NO_AUTO_UPDATE=1
|
|
export HOMEBREW_NO_ENV_HINTS=1
|
|
|
|
# DBUS for zathura
|
|
#export DBUS_LAUNCHD_SESSION_BUS_SOCKET=/tmp/(id -u)
|
|
#export DBUS_SESSION_BUS_ADDRESS='unix:path='$DBUS_LAUNCHD_SESSION_BUS_SOCKET
|
|
#if pgrep -x dbus-daemon &> /dev/null
|
|
# printf (_ "%sdbus-daemon%s is running\n") (set_color red) (set_color normal)
|
|
#else
|
|
# #echo "dbus-daemon is not running"
|
|
# dbus-daemon --fork --session --address=$DBUS_SESSION_BUS_ADDRESS
|
|
#end
|
|
|
|
# fzf
|
|
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
|
|
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
|
export FZF_DEFAULT_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
|
|
export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always --line-range :500 {}'"
|
|
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
|
|
|
|
_fzf_compgen_path() {
|
|
fd --hidden --exclude .git . "$1"
|
|
}
|
|
|
|
_fzf_compgen_dir() {
|
|
fd --type=d --hidden --exclude .git . "$1"
|
|
}
|
|
|
|
_fzf_comprun() {
|
|
local command=$1
|
|
shift
|
|
case "$command" in
|
|
cd) fzf --preview "eza --tree --color=always {} | head -200" "$@" ;;
|
|
export|unset) fzf --preview "eval 'echo \$' {}" "$@" ;;
|
|
ssh) fzf --preview "dig {}" "$@" ;;
|
|
*) fzf --preview "bat -n --color=always --line-range :500 {}" "$@" ;;
|
|
esac
|
|
}
|
|
|
|
# ALIAS
|
|
# convinience
|
|
alias doas="sudo"
|
|
|
|
# Neovim
|
|
alias vi="nvim"
|
|
alias vim="nvim"
|
|
|
|
# cat
|
|
alias cat="bat"
|
|
|
|
# ls
|
|
alias ls="eza --color=always --long --git --icons=always --group"
|
|
|
|
# cd
|
|
alias cd="z"
|
|
|
|
# mutt
|
|
#alias mutt='neomutt'
|
|
|
|
# rsync
|
|
alias rsync="rsync -h -v -r -P -p -t --stats"
|
|
|
|
# wget folder
|
|
alias wget_f="wget -r -np -R 'index.html*'"
|
|
|
|
# btop
|
|
alias top="btop"
|
|
|
|
# Shell integrations
|
|
# The fuck
|
|
eval $(thefuck --alias)
|
|
|
|
#zoxide
|
|
eval "$(zoxide init zsh)"
|
|
|
|
# fzf
|
|
eval "$(fzf --zsh)"
|