fix(shell): improve fzf integration and add bash completion colors
- commit
- 52072ecb23521bba40fe394fca1bae95146920f4
- author
- bnema · · 2025-10-28 18:25 UTC
- parent
- c45daf9
- signature
- GPG Unverified
2B82207D370127A0The key is unknown
3 files · +13 -2
M install/configs/shell/aliases +1 -1
| @@ -10,7 +10,7 @@ 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 'bat --style=numbers --color=always {}'" | |
| 13 | + | alias ff="fzf --preview '[[ -f {} ]] && bat --style=numbers --color=always {} || echo \"{}\"'" | |
| 14 | 14 | fi | |
| 15 | 15 | ||
| 16 | 16 | # Bat aliases | |
| @@ -10,7 +10,7 @@ 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 'bat --style=numbers --color=always {}'" | 13 | + | alias ff="fzf --preview '[[ -f {} ]] && bat --style=numbers --color=always {} || echo \"{}\"'" |
| 14 | fi | 14 | fi | ||
| 15 | 15 | ||||
| 16 | # Bat aliases | 16 | # Bat aliases | ||
M install/configs/shell/envs +6 -1
| @@ -5,5 +5,10 @@ fi | |||
| 5 | 5 | ||
| 6 | 6 | # FZF default options | |
| 7 | 7 | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | |
| 8 | - | export FZF_DEFAULT_OPTS="--preview 'bat --color=always --style=numbers --line-range=:500 {}' --preview-window right:60%:wrap" | |
| 8 | + | export FZF_DEFAULT_OPTS="--preview '[[ -f {} ]] && bat --color=always --style=numbers --line-range=:500 {} || echo \"{}\"' --preview-window right:60%:wrap" | |
| 9 | + | fi | |
| 10 | + | ||
| 11 | + | # Initialize dircolors for bash-completion and ls colors | |
| 12 | + | if command -v dircolors &> /dev/null; then | |
| 13 | + | eval "$(dircolors -b)" | |
| 9 | 14 | fi | |
| @@ -5,5 +5,10 @@ fi | |||||
| 5 | 5 | ||||
| 6 | # FZF default options | 6 | # FZF default options | ||
| 7 | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | 7 | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | ||
| 8 | - | export FZF_DEFAULT_OPTS="--preview 'bat --color=always --style=numbers --line-range=:500 {}' --preview-window right:60%:wrap" | 8 | + | export FZF_DEFAULT_OPTS="--preview '[[ -f {} ]] && bat --color=always --style=numbers --line-range=:500 {} || echo \"{}\"' --preview-window right:60%:wrap" |
| 9 | + | fi | |||
| 10 | + | ||||
| 11 | + | # Initialize dircolors for bash-completion and ls colors | |||
| 12 | + | if command -v dircolors &> /dev/null; then | |||
| 13 | + | eval "$(dircolors -b)" | |||
| 9 | fi | 14 | fi | ||
M install/configs/shell/shell +6 -0
| @@ -8,6 +8,12 @@ HISTFILESIZE="${HISTSIZE}" | |||
| 8 | 8 | [[ $PS1 && ! ${BASH_COMPLETION_VERSINFO:-} && -f /usr/share/bash-completion/bash_completion ]] && \ | |
| 9 | 9 | . /usr/share/bash-completion/bash_completion | |
| 10 | 10 | ||
| 11 | + | # Enable colored completion output | |
| 12 | + | if [[ -n "$LS_COLORS" ]]; then | |
| 13 | + | bind 'set colored-completion-prefix on' | |
| 14 | + | bind 'set colored-stats on' | |
| 15 | + | fi | |
| 16 | + | ||
| 11 | 17 | # Set complete path | |
| 12 | 18 | export PATH="$HOME/.local/bin:$PATH" | |
| 13 | 19 | set +h | |
| @@ -8,6 +8,12 @@ HISTFILESIZE="${HISTSIZE}" | |||||
| 8 | [[ $PS1 && ! ${BASH_COMPLETION_VERSINFO:-} && -f /usr/share/bash-completion/bash_completion ]] && \ | 8 | [[ $PS1 && ! ${BASH_COMPLETION_VERSINFO:-} && -f /usr/share/bash-completion/bash_completion ]] && \ | ||
| 9 | . /usr/share/bash-completion/bash_completion | 9 | . /usr/share/bash-completion/bash_completion | ||
| 10 | 10 | ||||
| 11 | + | # Enable colored completion output | |||
| 12 | + | if [[ -n "$LS_COLORS" ]]; then | |||
| 13 | + | bind 'set colored-completion-prefix on' | |||
| 14 | + | bind 'set colored-stats on' | |||
| 15 | + | fi | |||
| 16 | + | ||||
| 11 | # Set complete path | 17 | # Set complete path | ||
| 12 | export PATH="$HOME/.local/bin:$PATH" | 18 | export PATH="$HOME/.local/bin:$PATH" | ||
| 13 | set +h | 19 | set +h | ||