detached 451e602

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
1010
1111 # Bat + FZF integration
1212 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"
1414 fi
1515
1616 # Bat aliases
1717 if command -v bat &> /dev/null; then
18- alias cat='bat --paging=never'
18+ alias cat='bat -pp'
1919 alias less='bat'
2020 fi
2121
@@ -10,12 +10,12 @@ fi
10 10
11 # Bat + FZF integration11 # Bat + FZF integration
12 if command -v bat &> /dev/null && command -v fzf &> /dev/null; then12 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 fi14 fi
15 15
16 # Bat aliases16 # Bat aliases
17 if command -v bat &> /dev/null; then17 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 fi20 fi
21 21
M install/configs/shell/envs +12 -3
@@ -3,9 +3,18 @@ if command -v bat &> /dev/null; then
33 export BAT_THEME="TwoDark"
44 fi
55
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
918 fi
1019
1120 # 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 fi4 fi
5 5
6-# FZF default options6+# FZF configuration
7-if command -v fzf &> /dev/null && command -v bat &> /dev/null; then7+# 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 fi18 fi
10 19
11 # Initialize dircolors for bash-completion and ls colors20 # Initialize dircolors for bash-completion and ls colors
M install/extra.packages +1 -0
@@ -39,6 +39,7 @@ fzf
3939 ripgrep
4040 bat
4141 fd
42+tree
4243 btop
4344 git-delta
4445 dust
@@ -39,6 +39,7 @@ fzf
39 ripgrep39 ripgrep
40 bat40 bat
41 fd41 fd
42+tree
42 btop43 btop
43 git-delta44 git-delta
44 dust45 dust
M install/post-install/shell-config.sh +14 -5
@@ -97,12 +97,12 @@ fi
9797
9898 # Bat + FZF integration
9999 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"
101101 fi
102102
103103 # Bat aliases
104104 if command -v bat &> /dev/null; then
105- alias cat='bat --paging=never'
105+ alias cat='bat -pp'
106106 alias less='bat'
107107 fi
108108
@@ -132,9 +132,18 @@ if command -v bat &> /dev/null; then
132132 export BAT_THEME="TwoDark"
133133 fi
134134
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
138147 fi
139148 ENVS_END
140149
@@ -97,12 +97,12 @@ fi
97 97
98 # Bat + FZF integration98 # Bat + FZF integration
99 if command -v bat &> /dev/null && command -v fzf &> /dev/null; then99 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 fi101 fi
102 102
103 # Bat aliases103 # Bat aliases
104 if command -v bat &> /dev/null; then104 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 fi107 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 fi133 fi
134 134
135-# FZF default options135+# FZF configuration
136-if command -v fzf &> /dev/null && command -v bat &> /dev/null; then136+# 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 fi147 fi
139 ENVS_END148 ENVS_END
140 149

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close