Skip to content

Commit

Permalink
feat(zsh): improved configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroSuero committed Apr 21, 2024
1 parent 64996a1 commit e018943
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 11 deletions.
22 changes: 11 additions & 11 deletions roles/zsh/files/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ fi

export STARSHIP_CONFIG="$HOME/.config/starship/starship.toml"

export FZF_DEFAULT_OPTS="
--color=fg:#908caa,bg:#232136,hl:#ea9a97
--color=fg+:#e0def4,bg+:#393552,hl+:#ea9a97
--color=border:#44415a,header:#3e8fb0,gutter:#232136
--color=spinner:#f6c177,info:#9ccfd8,separator:#44415a
--color=pointer:#c4a7e7,marker:#eb6f92,prompt:#908caa"
export BAT_THEME="Catppuccin Mocha"

# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
Expand All @@ -36,9 +31,7 @@ fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
plugins=(
gh
git
golang
tmux
zoxide
web-search
zsh-autosuggestions
zsh-syntax-highlighting
)
Expand All @@ -63,6 +56,9 @@ if [[ -f "$HOME/.config/zsh/.zsh_private" ]]; then
source "$HOME/.config/zsh/.zsh_private"
fi

eval "$(starship init zsh)"
eval "$(fzf --zsh)"

for file in $HOME/.config/zsh/*.sh; do
source "$file"
done
Expand All @@ -78,6 +74,10 @@ if [[ "$(uname)" == "Darwin" ]]; then
addToPathFront "/opt/homebrew/opt/gnu-tar/libexec/gnubin"
fi

eval "$(starship init zsh)"
eval "$(fzf --zsh)"
source ~/fzf-git.sh/fzf-git.sh
check_nvmrc

eval "$(thefuck --alias)"
eval "$(thefuck --alias fk)"

eval "$(zoxide init zsh)"
45 changes: 45 additions & 0 deletions roles/zsh/files/zsh/fzf_functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env zsh

# rose-pine colorscheme
export FZF_DEFAULT_OPTS="
--color=fg:#908caa,bg:#232136,hl:#ea9a97
--color=fg+:#e0def4,bg+:#393552,hl+:#ea9a97
--color=border:#44415a,header:#3e8fb0,gutter:#232136
--color=spinner:#f6c177,info:#9ccfd8,separator:#44415a
--color=pointer:#c4a7e7,marker:#eb6f92,prompt:#908caa"

# -- Use fd instead of fzf --

export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_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 'exa --tree --color=always {} | head -200'"

# Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command.
# - You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() {
local command=$1
shift

case "$command" in
cd) fzf --preview 'exa --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
}

# Use fd (https://github.com/sharkdp/fd) for listing path candidates.
# - The first argument to the function ($1) is the base path to start traversal
# - See the source code (completion.{bash,zsh}) for the details.
_fzf_compgen_path() {
fd --hidden --exclude .git . "$1"
}

# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
fd --type=d --hidden --exclude .git . "$1"
}

0 comments on commit e018943

Please sign in to comment.