From 6447059b011f152b3b7be8e838ee1e5b758b7316 Mon Sep 17 00:00:00 2001 From: Guilherme Rugai Freire Date: Wed, 14 Feb 2024 18:06:27 -0300 Subject: [PATCH] add support for debain Debian packages bat (ls replacement) as `batcat`, while other distros, like archlinux, does not. This commits selects which binary to use depending if the current distro is debian. Also, debian's package for fzf places the zsh completitions file in other directory of what arch linux does, this commit also fixes this. --- .config/zsh/.zshrc | 13 +++++++++---- .profile | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index d896da5..7b1bd9a 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -31,7 +31,11 @@ export ZSH_PLUGINS_ALIAS_TIPS_EXCLUDES="_" # Fzf keybinds # search history of shell commands -source /usr/share/fzf/key-bindings.zsh +if [ $OS_RELEASE = "debian" ]; then + source /usr/share/doc/fzf/examples/key-bindings.zsh +else + source /usr/share/fzf/key-bindings.zsh +fi # Alias config to manage dotfiles with git alias config="git --git-dir=\$HOME/.dotfiles/ --work-tree=\$HOME" @@ -49,7 +53,7 @@ fzf_fast_file_edit() { config_files="$(config ls-tree -r "$current_branch" --name-only "$HOME")" # Select file - selected_file=$(printf "%s\n%s" "$scripts" "$config_files" | fzf --info=inline --prompt='Select a file: ' --preview='bat --paging=never --style=plain --color=always {}') + selected_file=$(printf "%s\n%s" "$scripts" "$config_files" | fzf --info=inline --prompt='Select a file: ' --preview="$bat_cmd --paging=never --style=plain --color=always {}") if [ -n "$selected_file" ]; then @@ -63,14 +67,15 @@ alias python="python3" alias pip="pip3" # Alias to bat instead of cat -alias cat="bat --paging=never --style=header,grid" +[ $OS_RELEASE = "debian" ] && bat_cmd="batcat" || bat_cmd="bat" +alias cat="$bat_cmd --paging=never --style=header,grid" # Alias to exa instead of ls alias ls="exa --color=always --icons --group-directories-first" alias tree="ls --tree" # Alias to bat instead of less -alias less="bat -p --paging=always" +alias less="$bat_cmd -p --paging=always" # Alias to nvim instead of vim alias vim="nvim" diff --git a/.profile b/.profile index 250a745..4365af0 100644 --- a/.profile +++ b/.profile @@ -1,5 +1,7 @@ #!/bin/sh +export OS_RELEASE="$(cat /etc/os-release | grep '^ID=' | sed 's|ID=||')" + ### SET PATHS ### # XDG Defaults @@ -25,9 +27,11 @@ export ZDOTDIR="$HOME"/.config/zsh eval `ssh-agent -s` > /dev/null ### Default programs ### +[ $OS_RELEASE = "debian" ] && bat_cmd="batcat" || bat_cmd="bat" + export EDITOR="nvim" export READER="zathura" -export MANPAGER="sh -c 'col -bx | bat -l man --paging always -p'" +export MANPAGER="sh -c \"col -bx | $bat_cmd -l man --paging always -p\"" export TERMINAL="alacritty" export BROWSER="firefox" export VIDEO="mpv"