Move zsh and aliases to conf.d style configs

This commit is contained in:
2023-03-30 15:46:14 -05:00
parent f3e303fd93
commit 2cbf3d6e55
21 changed files with 181 additions and 188 deletions

View File

@@ -0,0 +1,4 @@
# Autosuggestions
if [[ -s /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
fi

4
zsh.d/broot.zsh Normal file
View File

@@ -0,0 +1,4 @@
# broot
if [[ -s ~/.config/broot/launcher/bash/br ]]; then
source ~/.config/broot/launcher/bash/br
fi

4
zsh.d/direnv.zsh Normal file
View File

@@ -0,0 +1,4 @@
# Per-directory env
if (( $+commands[direnv])); then
eval "$(direnv hook zsh)"
fi

33
zsh.d/exa.zsh Normal file
View File

@@ -0,0 +1,33 @@
# exa
if (( $+commands[exa] )); then
# exa explorer
exex() {
local depth=1
local old_depth=0
local min_depth=1
local max_depth=3
local exa_opts=("--color=always" "--git" "--icons" "-F" "-T")
while true; do
if [[ $depth -ne $old_depth ]]; then
local old_depth=$depth
clear
exa $exa_opts -L$depth
fi
read -sk key
case $key in
h)
[[ $depth -gt $min_depth ]] && (( depth-- ))
;;
l)
[[ $depth -lt $max_depth ]] && (( depth++ ))
;;
q)
break
;;
esac
done
}
fi

10
zsh.d/fd.zsh Normal file
View File

@@ -0,0 +1,10 @@
# Use fd for fzf
if (( $+commands[fd] && $+commands[fzf] )); then
_fzf_compgen_path() {
fd --hidden --follow --exclude ".git" . "$1"
}
_fzf_compgen_dir() {
fd --type d --hidden --follow --exclude ".git" . "$1"
}
fi

12
zsh.d/gh.zsh Normal file
View File

@@ -0,0 +1,12 @@
# gh
if (( $+commands[gh] )); then
gh_chpwd_hook() {
if [[ -d ".github" ]]; then
gh pr list
fi
}
chpwd_functions+=( gh_chpwd_hook )
gh_chpwd_hook
fi

12
zsh.d/git.zsh Normal file
View File

@@ -0,0 +1,12 @@
# git
if (( $+commands[git] )); then
git_chpwd_hook() {
if [[ -d ".git" ]]; then
git status
fi
}
chpwd_functions+=( git_chpwd_hook )
git_chpwd_hook
fi

4
zsh.d/manjaro.zsh Normal file
View File

@@ -0,0 +1,4 @@
# Source manjaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
source /usr/share/zsh/manjaro-zsh-config
fi

4
zsh.d/navi.zsh Normal file
View File

@@ -0,0 +1,4 @@
# Cheat my way through the CLI
if (( $+commands[navi] )); then
eval "$(navi widget zsh)"
fi

7
zsh.d/nvm.zsh Normal file
View File

@@ -0,0 +1,7 @@
# NVM
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
source "$NVM_DIR/nvm.sh" # This loads nvm
fi
if [[ -s "$NVM_DIR/bash_completion" ]]; then
source "$NVM_DIR/bash_completion" # This loads nvm bash_completion
fi

26
zsh.d/prompt.zsh Normal file
View File

@@ -0,0 +1,26 @@
# Use a prompt, depending on what is available:
# 1. starship
# 2. p10k
# 3. manjaro
if (( $+commands[starship] )); then
eval "$(starship init zsh)"
else
if [[ -s ~/.p10k.zsh ]]; then
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
source ~/.p10k.zsh
else
# Use powerline
USE_POWERLINE="true"
# Use manjaro zsh prompt
if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
source /usr/share/zsh/manjaro-zsh-prompt
fi
fi
fi

View File

@@ -0,0 +1,6 @@
# Virtualenvwrapper
if [[ -s "$HOME/.local/bin/virtualenvwrapper_lazy.sh" ]]; then
source "$HOME/.local/bin/virtualenvwrapper_lazy.sh"
elif [[ -s "$HOME/.local/bin/virtualenvwrapper.sh" ]]; then
source "$HOME/.local/bin/virtualenvwrapper.sh"
fi

18
zsh.d/zellij.zsh Normal file
View File

@@ -0,0 +1,18 @@
# zellij
if (( $+commands[zellij] )); then
ZELLIJ_AUTO_ATTACH=true
eval "$(zellij setup --generate-auto-start zsh)"
ide() {
local layout="${ZELLIJ_LAYOUT:-${HOME}/.config/zellij/layouts/project.kdl}"
local name="${PWD##*/}"
local name="${name:-/}"
if (( ${+ZELLIJ} )); then
# FIXME: https://github.com/zellij-org/zellij/issues/2299
zellij action new-tab --layout "${layout}" --cwd "${PWD}" --name "${name}"
else
zellij --layout "${layout}" $@
fi
}
fi

4
zsh.d/zoxide.zsh Normal file
View File

@@ -0,0 +1,4 @@
# Intelligent and fast autojump
if (( $+commands[zoxide] )); then
eval "$(zoxide init zsh)"
fi