diff --git a/.config/bat/config b/.config/bat/config new file mode 100644 index 0000000..e6e1f57 --- /dev/null +++ b/.config/bat/config @@ -0,0 +1,16 @@ +--theme="ansi" + +# See $PAGER in ~/.config/shell/env +--pager="less --chop-long-lines --ignore-case --LONG-PROMPT --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/aliases b/.config/shell/aliases index ed85ac8..522f114 100644 --- a/.config/shell/aliases +++ b/.config/shell/aliases @@ -7,6 +7,11 @@ alias dotfiles='git --git-dir=$XDG_DATA_HOME/dotfiles --work-tree=$HOME' +if _command_exists batcat; then + alias bat='batcat' +fi + + # Integrate `git` if _command_exists git; then diff --git a/.config/shell/env b/.config/shell/env index 84ee7c7..751bd14 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/install-do 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/install-dotfiles # Convenient names for various places in the system @@ -28,8 +28,14 @@ export PAGER="less --chop-long-lines --ignore-case --LONG-PROMPT --no-init --sta export TZ="Europe/Berlin" export VISUAL=$EDITOR +if command -v bat >/dev/null 2>&1; then + export MANPAGER="sh -c 'col -bx | bat --language man --plain'" + export MANROFFOPT="-c" +fi + # 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" export VIMINIT='let $MYVIMRC="'"$XDG_CONFIG_HOME"'/vim/vimrc" | source $MYVIMRC' diff --git a/.local/bin/install-dotfiles b/.local/bin/install-dotfiles index 0a84400..56f6656 100755 --- a/.local/bin/install-dotfiles +++ b/.local/bin/install-dotfiles @@ -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 DOTFILES_DIR="$XDG_DATA_HOME/dotfiles" # also set in ~/.config/shell/env @@ -96,6 +97,12 @@ _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 + mkdir -p "$XDG_BIN_HOME" + ln -sf "$(command -v batcat)" "$XDG_BIN_HOME/bat" +fi + + echo "" echo "The dotfiles were installed successfully (branch: $DOTFILES_BRANCH)" echo ""