From 7a5d1d5e46bbd936122ead944651e2858d467f65 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Mon, 3 Aug 2026 02:57:48 +0200 Subject: [PATCH] Add configuration for `bat` --- .config/bat/config | 17 +++++++++++++++++ .config/shell/env | 14 +++++++++++++- .local/bin/dotfiles-install | 6 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .config/bat/config diff --git a/.config/bat/config b/.config/bat/config new file mode 100644 index 0000000..28630ed --- /dev/null +++ b/.config/bat/config @@ -0,0 +1,17 @@ +--theme="ansi" + +# See $PAGER in ~/.config/shell/env +--pager="less --chop-long-lines --ignore-case --LONG-PROMPT --no-init --status-column --quit-if-one-screen --RAW-CONTROL-CHARS" + +--style="numbers,changes,header" + + +# Unrecognized mappings + +--map-syntax ".bash_history:Bourne Again Shell (bash)" +--map-syntax "**/bash/history:Bourne Again Shell (bash)" +--map-syntax "**/zsh/history:Bourne Again Shell (bash)" + +--map-syntax ".flake8:INI" + +--map-syntax "poetry.lock:TOML" diff --git a/.config/shell/env b/.config/shell/env index 5829ec4..47ebfd1 100644 --- a/.config/shell/env +++ b/.config/shell/env @@ -12,7 +12,7 @@ export XDG_DATA_HOME="$HOME/.local/share" # also set in ~/.local/bin/dotfiles-{ export XDG_STATE_HOME="$HOME/.local/state" # Make up a XDG directory for binaries (that does not exist in the standard) -export XDG_BIN_HOME="$HOME/.local/bin" +export XDG_BIN_HOME="$HOME/.local/bin" # also set in ~/.local/bin/dotfiles-install # Convenient names for various places in the system @@ -33,6 +33,18 @@ export LESS="--chop-long-lines --ignore-case --LONG-PROMPT --no-init --raw-contr [ -f "$XDG_CONFIG_HOME/shell/locale" ] && . "$XDG_CONFIG_HOME/shell/locale" +# ~/.local/bin/dotfiles-install symlinks Debian's `batcat` to ~/.local/bin/bat +for _bat in batcat bat; do + if _command_exists "$_bat"; then + export MANPAGER="sh -c 'col -bx | $_bat --language man --plain'" + export MANROFFOPT="-c" + break + fi +done +unset _bat + + # Move common tools' config and cache files into XDG directories +export BAT_CONFIG_PATH="$XDG_CONFIG_HOME/bat/config" export LESSHISTFILE="$XDG_STATE_HOME/less/history" diff --git a/.local/bin/dotfiles-install b/.local/bin/dotfiles-install index 8cd50c3..7832428 100755 --- a/.local/bin/dotfiles-install +++ b/.local/bin/dotfiles-install @@ -10,6 +10,7 @@ set -eu +XDG_BIN_HOME="${XDG_BIN_HOME:-$HOME/.local/bin}" # also set in ~/.config/shell/env XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" # also set in ~/.config/shell/env XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" # also set in ~/.config/shell/env @@ -107,6 +108,11 @@ _git config --local status.showUntrackedFiles no _git remote set-url origin "$DOTFILES_SSH" +if command -v batcat >/dev/null 2>&1 && ! command -v bat >/dev/null 2>&1; then + ln -sf "$(command -v batcat)" "$XDG_BIN_HOME/bat" +fi + + echo "" echo "The dotfiles were installed successfully (branch: $DOTFILES_BRANCH)" echo ""