[zsh] Improve BSD compatibility

This commit is contained in:
Lara 2020-07-27 13:56:38 -04:00
parent 8fe09dc6e8
commit d4e82cf9cd
3 changed files with 22 additions and 14 deletions

View file

@ -5,7 +5,7 @@
# Detect if we have GNU coreutils or BSD
if date --version > /dev/null 2>&1 ;then
alias ls='ls --classify --tabsize=0 --literal --color=auto --show-control-chars -h'
alias diff='diff -u --color'
alias diff='diff --color'
alias less='less --quiet'
alias grep="grep --color"
alias rm='rm -I'
@ -13,6 +13,7 @@ if date --version > /dev/null 2>&1 ;then
alias ipa='ip route && echo && ip --brief address'
alias ipr='ip --brief address && echo && ip route'
else
alias ls='ls -FGh'
alias ipa='ip address'
alias ipa='ip route'
fi
@ -35,6 +36,7 @@ case $(uname -s) in
esac
alias ll='ls -lha'
alias df='df -h'
alias diff='diff -u'
alias du='du -h'
alias feh="feh -. --auto-rotate --action1 'dragon -x %F'"
alias which='which -a'

View file

@ -2,16 +2,19 @@
# Debugging #
#############
# Global counter that can be used to diagnose duplicated calls
printf "0" > /dev/shm/debug_counter
debug_counter_inc() {
count="$(cat /dev/shm/debug_counter)"
((count++))
printf "%d" "$count" > /dev/shm/debug_counter
}
debug_counter_print(){
printf "%d" "$(cat /dev/shm/debug_counter)"
}
# Detect if we have GNU coreutils or BSD
if date --version > /dev/null 2>&1 ;then
# Global counter that can be used to diagnose duplicated calls
printf "0" > /dev/shm/debug_counter
debug_counter_inc() {
count="$(cat /dev/shm/debug_counter)"
((count++))
printf "%d" "$count" > /dev/shm/debug_counter
}
debug_counter_print(){
printf "%d" "$(cat /dev/shm/debug_counter)"
}
fi
###################
# Update checking #

9
zshrc
View file

@ -56,9 +56,12 @@ colors
. "$RC_PATH/functions"
. "$RC_PATH/aliases"
. "$RC_PATH/prompt"
# Setup colors for GNU ls
# TODO: check for GNU ls
eval "$(dircolors -b)"
# Detect if we have GNU coreutils or BSD
if date --version > /dev/null 2>&1 ;then
# Setup colors for GNU ls
eval "$(dircolors -b)"
fi
# Check for rc updates in the background
(check_rc_update&) 2> /dev/null