fix(shell): correct fzf preview configuration and improve bat alias
- Move bat preview from FZF_DEFAULT_OPTS to FZF_CTRL_T_OPTS to prevent breaking fzf when used with non-file operations (ps, history, etc.) - Add FZF_ALT_C_OPTS with tree preview for directory navigation - Change cat alias to use 'bat -pp' for plain output without line numbers, making it easier to copy text - Add tree package for directory preview support This follows the official fzf documentation recommendation to avoid adding --preview to FZF_DEFAULT_OPTS as it breaks general-purpose use.
- commit
- 451e60228931afd0bbf65733b0daaffa8d883944
- author
- bnema · · 2025-10-28 21:01 UTC
- parent
- 66cc81f
- signature
- unsigned
4 files · +29 -10
M install/configs/shell/aliases +2 -2
| @@ -10,12 +10,12 @@ fi | |||
| 10 | 10 | ||
| 11 | 11 | # Bat + FZF integration | |
| 12 | 12 | if command -v bat &> /dev/null && command -v fzf &> /dev/null; then | |
| 13 | - | alias ff="fzf --preview '[[ -f {} ]] && bat --style=numbers --color=always {} || echo \"{}\"'" | |
| 13 | + | alias ff="fzf --preview 'bat -n --color=always {}' --preview-window right:60%:wrap" | |
| 14 | 14 | fi | |
| 15 | 15 | ||
| 16 | 16 | # Bat aliases | |
| 17 | 17 | if command -v bat &> /dev/null; then | |
| 18 | - | alias cat='bat --paging=never' | |
| 18 | + | alias cat='bat -pp' | |
| 19 | 19 | alias less='bat' | |
| 20 | 20 | fi | |
| 21 | 21 | ||
| @@ -10,12 +10,12 @@ fi | |||||
| 10 | 10 | ||||
| 11 | # Bat + FZF integration | 11 | # Bat + FZF integration | ||
| 12 | if command -v bat &> /dev/null && command -v fzf &> /dev/null; then | 12 | if command -v bat &> /dev/null && command -v fzf &> /dev/null; then | ||
| 13 | - | alias ff="fzf --preview '[[ -f {} ]] && bat --style=numbers --color=always {} || echo \"{}\"'" | 13 | + | alias ff="fzf --preview 'bat -n --color=always {}' --preview-window right:60%:wrap" |
| 14 | fi | 14 | fi | ||
| 15 | 15 | ||||
| 16 | # Bat aliases | 16 | # Bat aliases | ||
| 17 | if command -v bat &> /dev/null; then | 17 | if command -v bat &> /dev/null; then | ||
| 18 | - | alias cat='bat --paging=never' | 18 | + | alias cat='bat -pp' |
| 19 | alias less='bat' | 19 | alias less='bat' | ||
| 20 | fi | 20 | fi | ||
| 21 | 21 | ||||
M install/configs/shell/envs +12 -3
| @@ -3,9 +3,18 @@ if command -v bat &> /dev/null; then | |||
| 3 | 3 | export BAT_THEME="TwoDark" | |
| 4 | 4 | fi | |
| 5 | 5 | ||
| 6 | - | # FZF default options | |
| 7 | - | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | |
| 8 | - | export FZF_DEFAULT_OPTS="--preview '[[ -f {} ]] && bat --color=always --style=numbers --line-range=:500 {} || echo \"{}\"' --preview-window right:60%:wrap" | |
| 6 | + | # FZF configuration | |
| 7 | + | # Note: Do NOT add --preview to FZF_DEFAULT_OPTS as it breaks non-file operations | |
| 8 | + | if command -v fzf &> /dev/null; then | |
| 9 | + | # CTRL-T file/directory picker options | |
| 10 | + | if command -v bat &> /dev/null; then | |
| 11 | + | export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always {}' --preview-window right:60%:wrap" | |
| 12 | + | fi | |
| 13 | + | ||
| 14 | + | # ALT-C directory navigation options | |
| 15 | + | if command -v tree &> /dev/null; then | |
| 16 | + | export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200' --preview-window right:60%:wrap" | |
| 17 | + | fi | |
| 9 | 18 | fi | |
| 10 | 19 | ||
| 11 | 20 | # Initialize dircolors for bash-completion and ls colors | |
| @@ -3,9 +3,18 @@ if command -v bat &> /dev/null; then | |||||
| 3 | export BAT_THEME="TwoDark" | 3 | export BAT_THEME="TwoDark" | ||
| 4 | fi | 4 | fi | ||
| 5 | 5 | ||||
| 6 | - | # FZF default options | 6 | + | # FZF configuration |
| 7 | - | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | 7 | + | # Note: Do NOT add --preview to FZF_DEFAULT_OPTS as it breaks non-file operations |
| 8 | - | export FZF_DEFAULT_OPTS="--preview '[[ -f {} ]] && bat --color=always --style=numbers --line-range=:500 {} || echo \"{}\"' --preview-window right:60%:wrap" | 8 | + | if command -v fzf &> /dev/null; then |
| 9 | + | # CTRL-T file/directory picker options | |||
| 10 | + | if command -v bat &> /dev/null; then | |||
| 11 | + | export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always {}' --preview-window right:60%:wrap" | |||
| 12 | + | fi | |||
| 13 | + | ||||
| 14 | + | # ALT-C directory navigation options | |||
| 15 | + | if command -v tree &> /dev/null; then | |||
| 16 | + | export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200' --preview-window right:60%:wrap" | |||
| 17 | + | fi | |||
| 9 | fi | 18 | fi | ||
| 10 | 19 | ||||
| 11 | # Initialize dircolors for bash-completion and ls colors | 20 | # Initialize dircolors for bash-completion and ls colors | ||
M install/extra.packages +1 -0
| @@ -39,6 +39,7 @@ fzf | |||
| 39 | 39 | ripgrep | |
| 40 | 40 | bat | |
| 41 | 41 | fd | |
| 42 | + | tree | |
| 42 | 43 | btop | |
| 43 | 44 | git-delta | |
| 44 | 45 | dust | |
| @@ -39,6 +39,7 @@ fzf | |||||
| 39 | ripgrep | 39 | ripgrep | ||
| 40 | bat | 40 | bat | ||
| 41 | fd | 41 | fd | ||
| 42 | + | tree | |||
| 42 | btop | 43 | btop | ||
| 43 | git-delta | 44 | git-delta | ||
| 44 | dust | 45 | dust | ||
M install/post-install/shell-config.sh +14 -5
| @@ -97,12 +97,12 @@ fi | |||
| 97 | 97 | ||
| 98 | 98 | # Bat + FZF integration | |
| 99 | 99 | if command -v bat &> /dev/null && command -v fzf &> /dev/null; then | |
| 100 | - | alias ff="fzf --preview 'bat --style=numbers --color=always {}'" | |
| 100 | + | alias ff="fzf --preview 'bat -n --color=always {}' --preview-window right:60%:wrap" | |
| 101 | 101 | fi | |
| 102 | 102 | ||
| 103 | 103 | # Bat aliases | |
| 104 | 104 | if command -v bat &> /dev/null; then | |
| 105 | - | alias cat='bat --paging=never' | |
| 105 | + | alias cat='bat -pp' | |
| 106 | 106 | alias less='bat' | |
| 107 | 107 | fi | |
| 108 | 108 | ||
| @@ -132,9 +132,18 @@ if command -v bat &> /dev/null; then | |||
| 132 | 132 | export BAT_THEME="TwoDark" | |
| 133 | 133 | fi | |
| 134 | 134 | ||
| 135 | - | # FZF default options | |
| 136 | - | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | |
| 137 | - | export FZF_DEFAULT_OPTS="--preview 'bat --color=always --style=numbers --line-range=:500 {}' --preview-window right:60%:wrap" | |
| 135 | + | # FZF configuration | |
| 136 | + | # Note: Do NOT add --preview to FZF_DEFAULT_OPTS as it breaks non-file operations | |
| 137 | + | if command -v fzf &> /dev/null; then | |
| 138 | + | # CTRL-T file/directory picker options | |
| 139 | + | if command -v bat &> /dev/null; then | |
| 140 | + | export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always {}' --preview-window right:60%:wrap" | |
| 141 | + | fi | |
| 142 | + | ||
| 143 | + | # ALT-C directory navigation options | |
| 144 | + | if command -v tree &> /dev/null; then | |
| 145 | + | export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200' --preview-window right:60%:wrap" | |
| 146 | + | fi | |
| 138 | 147 | fi | |
| 139 | 148 | ENVS_END | |
| 140 | 149 | ||
| @@ -97,12 +97,12 @@ fi | |||||
| 97 | 97 | ||||
| 98 | # Bat + FZF integration | 98 | # Bat + FZF integration | ||
| 99 | if command -v bat &> /dev/null && command -v fzf &> /dev/null; then | 99 | if command -v bat &> /dev/null && command -v fzf &> /dev/null; then | ||
| 100 | - | alias ff="fzf --preview 'bat --style=numbers --color=always {}'" | 100 | + | alias ff="fzf --preview 'bat -n --color=always {}' --preview-window right:60%:wrap" |
| 101 | fi | 101 | fi | ||
| 102 | 102 | ||||
| 103 | # Bat aliases | 103 | # Bat aliases | ||
| 104 | if command -v bat &> /dev/null; then | 104 | if command -v bat &> /dev/null; then | ||
| 105 | - | alias cat='bat --paging=never' | 105 | + | alias cat='bat -pp' |
| 106 | alias less='bat' | 106 | alias less='bat' | ||
| 107 | fi | 107 | fi | ||
| 108 | 108 | ||||
| @@ -132,9 +132,18 @@ if command -v bat &> /dev/null; then | |||||
| 132 | export BAT_THEME="TwoDark" | 132 | export BAT_THEME="TwoDark" | ||
| 133 | fi | 133 | fi | ||
| 134 | 134 | ||||
| 135 | - | # FZF default options | 135 | + | # FZF configuration |
| 136 | - | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | 136 | + | # Note: Do NOT add --preview to FZF_DEFAULT_OPTS as it breaks non-file operations |
| 137 | - | export FZF_DEFAULT_OPTS="--preview 'bat --color=always --style=numbers --line-range=:500 {}' --preview-window right:60%:wrap" | 137 | + | if command -v fzf &> /dev/null; then |
| 138 | + | # CTRL-T file/directory picker options | |||
| 139 | + | if command -v bat &> /dev/null; then | |||
| 140 | + | export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always {}' --preview-window right:60%:wrap" | |||
| 141 | + | fi | |||
| 142 | + | ||||
| 143 | + | # ALT-C directory navigation options | |||
| 144 | + | if command -v tree &> /dev/null; then | |||
| 145 | + | export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200' --preview-window right:60%:wrap" | |||
| 146 | + | fi | |||
| 138 | fi | 147 | fi | ||
| 139 | ENVS_END | 148 | ENVS_END | ||
| 140 | 149 | ||||