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

View file

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

9
zshrc
View file

@ -56,9 +56,12 @@ colors
. "$RC_PATH/functions" . "$RC_PATH/functions"
. "$RC_PATH/aliases" . "$RC_PATH/aliases"
. "$RC_PATH/prompt" . "$RC_PATH/prompt"
# Setup colors for GNU ls
# TODO: check for GNU ls # Detect if we have GNU coreutils or BSD
eval "$(dircolors -b)" 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 for rc updates in the background
(check_rc_update&) 2> /dev/null (check_rc_update&) 2> /dev/null