From 6447059b011f152b3b7be8e838ee1e5b758b7316 Mon Sep 17 00:00:00 2001 From: Guilherme Rugai Freire Date: Wed, 14 Feb 2024 18:06:27 -0300 Subject: [PATCH 1/3] 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" From bd350b7649a319bdcb6accf491389110aee41ec1 Mon Sep 17 00:00:00 2001 From: Guilherme Rugai Freire Date: Wed, 14 Feb 2024 18:08:01 -0300 Subject: [PATCH 2/3] move ohmyzsh and zinit install locations They were cluttering the home folder, now the live in ~/.local/share --- .config/zsh/.zshrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 7b1bd9a..08c9bf7 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -4,7 +4,7 @@ source ~/.profile ZSH_THEME="robbyrussell" # Oh my zsh -export ZSH="$HOME/.oh-my-zsh" +export ZSH="$HOME/.local/share/ohmyzsh" source $ZSH/oh-my-zsh.sh # Load cargo env @@ -19,7 +19,8 @@ compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION export HISTORY_IGNORE="ce" ### zinit plugins - start -source $HOME/.zinit/bin/zinit.zsh +ZINIT_PATH="$HOME/.local/share/zinit" +source $ZINIT_PATH/zinit.zsh zinit light zdharma-continuum/fast-syntax-highlighting zinit light zsh-users/zsh-autosuggestions From d122d7477f14203bb51523de7e87c1400723aaa3 Mon Sep 17 00:00:00 2001 From: Guilherme Rugai Freire Date: Wed, 14 Feb 2024 18:09:37 -0300 Subject: [PATCH 3/3] check cargo and nvm/fnm existence before sourcing --- .config/zsh/.zshrc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 08c9bf7..862ca41 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -8,7 +8,9 @@ export ZSH="$HOME/.local/share/ohmyzsh" source $ZSH/oh-my-zsh.sh # Load cargo env -. "$CARGO_HOME/env" +if [ -d "$CARGO_HOME" ]; then + . "$CARGO_HOME/env" +fi # Set cursor to beam shape echo -ne '\e[5 q' @@ -102,9 +104,13 @@ alias btw="neofetch" # Alias for qrcode alias qrcode="qrencode -s 10 -l H" -# This loads nvm -source $HOME/.config/fast-nvm.sh -source $NVM_DIR/bash_completion +# This loads fnm/nvm +if [ $(command -v fnm) ]; then + eval "$(fnm env --use-on-cd)" +else + source $HOME/.config/fast-nvm.sh + source $NVM_DIR/bash_completion +fi # Check if is integrated terminal emulator if [ "$EMULATOR" = "code" ]; then