Skip to content

Commit b9ea1ee

Browse files
committed
zsh: improve fzf config
1 parent 5266a3e commit b9ea1ee

7 files changed

Lines changed: 39 additions & 13 deletions

File tree

.config/zsh/aliases.zsh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,3 @@ alias tskst='task stats'
4141
alias tskts='task timesheet'
4242
alias vi="nvim"
4343
alias y="yarn"
44-
alias faliases='alias | fzf --prompt="alias> " \
45-
--preview '\''echo {} | sed "s/^[^=]*=//" | sed "s/^'\'''\''//; s/'\'''\''$//" | bat --language=bash --style=plain --color=always'\'''

.config/zsh/fzf/aliases.zsh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/env zsh
2+
3+
alias fa='alias | fzf --prompt="alias> " \
4+
--preview '\''echo {} | sed "s/^[^=]*=//" | sed "s/^'\'''\''//; s/'\'''\''$//" | bat --language=bash --style=plain --color=always'\'''
5+
6+
alias ff='nvim $(fzf --preview="bat --color=always {}")'
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
# FZF Configuration
55

66

7-
# FZF scripts
8-
source $DOTFILES_ZSH/scripts-fzf.zsh
7+
98

109
export FZF_BASE="/opt/homebrew/opt/fzf"
1110
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,25 @@ fifa() {
1818
&& print -z "./$file" || return 1;
1919
}
2020

21+
# fzf and zoxide QOL functions
22+
zz() {
23+
local dir
24+
dir=$(zoxide query -l | fzf) && z "$dir"
25+
}
26+
27+
# with tree preview
28+
zfp() {
29+
local dir
30+
dir=$(zoxide query -l | fzf --preview 'tree -CL 2 {}')
31+
[ -n "$dir" ] && z "$dir" && ls -la
32+
}
33+
34+
# recent dirs
35+
zr() {
36+
local dir
37+
dir=$(zoxide query -l | sort -k2 -rn | fzf)
38+
[ -n "$dir" ] && z "$dir"
39+
}
40+
41+
2142

.config/zsh/oh-my-zsh.zsh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ for plugin in $github_plugins; do
3333
mkdir -p ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins
3434
git clone --depth 1 --recursive https://github.com/$plugin.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/$plugin_name
3535
fi
36-
# load the plugin
36+
done
37+
38+
# Load oh-my-zsh FIRST (it runs compinit internally)
39+
source $ZSH/oh-my-zsh.sh
40+
41+
# Load custom github plugins AFTER oh-my-zsh
42+
for plugin in $github_plugins; do
43+
plugin_name=${plugin#*/}
3744
for initscript in ${plugin_name}.zsh ${plugin_name}.plugin.zsh ${plugin_name}.sh; do
3845
if [[ -f ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/$plugin_name/$initscript ]]; then
3946
source ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/$plugin_name/$initscript
@@ -42,8 +49,6 @@ for plugin in $github_plugins; do
4249
done
4350
done
4451

45-
source $ZSH/oh-my-zsh.sh
46-
4752
unset github_plugins
4853
unset plugin
4954
unset initscript

.zshrc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ source $DOTFILES_ZSH/oh-my-zsh.zsh
3737

3838
# | FZF |
3939
if [ $(command -v "fzf") ]; then
40-
source $DOTFILES_ZSH/fzf.zsh
41-
fi
42-
43-
# | BREW |
44-
if [ $(command -v "brew") ]; then
45-
source $DOTFILES_ZSH/brew.zsh
40+
for file in $DOTFILES_ZSH/fzf/*.zsh; do
41+
source "$file"
42+
done
4643
fi
4744

4845
# | ALIASES |

0 commit comments

Comments
 (0)