From: Nicolas Boisselier Date: Mon, 17 Nov 2014 22:38:07 +0000 (+0100) Subject: bin + etc X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=adc6f20ec272ad05ae507846a7b684f3e7673583;p=nb.git bin + etc --- diff --git a/bin/nb-install b/bin/nb-install index eab3f617..168f1c55 100755 --- a/bin/nb-install +++ b/bin/nb-install @@ -8,7 +8,7 @@ case "$@" in *-v*) install="$install -v";; esac case "$@" in *-n*) install="$install -n";; esac function verbose() { - printf '\n> %s\n\n' "$@" + printf '> %s\n' "$@" } # @@ -21,7 +21,7 @@ $install "$NB_ROOT/etc/cron/nb" /etc/cron.d/nb # Profile # verbose "Install /etc/profile.d/nb-profile.sh" -echo "[ -x $NB_ROOT/etc/profile.sh ] && . $ROOT/etc/profile.sh" > /tmp/nb-profile.sh \ +echo "[ -r $NB_ROOT/etc/profile.sh ] && . $NB_ROOT/etc/profile.sh" > /tmp/nb-profile.sh \ && $install -c /tmp/nb-profile.sh /etc/profile.d/nb-profile.sh \ && chmod 755 /etc/profile.d/nb-profile.sh \ ; diff --git a/etc/bashrc b/etc/bashrc index 3c859453..d030c3ed 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -1,4 +1,4 @@ -declare -r NB_ROOT=$(realpath ${BASH_SOURCE%/*}/..) +NB_ROOT=$(realpath ${BASH_SOURCE%/*}/..) . "${BASH_SOURCE%/*}/bashrc.function" . "${BASH_SOURCE%/*}/bashrc.alias" ################################################################################# @@ -48,25 +48,24 @@ export LESS="-iMR" export EDITOR=vim # -# Color / PS1 +# Color / PS1 / ls # -declare color_prompt color char +declare color_prompt color char h case "$TERM" in xterm-color) color_prompt=yes;; *screen*) color_prompt=yes;; linux) color_prompt=yes;; esac -case `hostname -s|tr A-Z a-z` in - pi*) color=31 ;; - *.ovh.net) color=33 ;; - *.kimsufi.com) color=33 ;; - *.ip-*.eu) color=33 ;; - Nicolas-Boisselier-MacBook*) h="macbook" - color=35 - ;; - MacMini*) color=35 ;; - *) color=36 ;; +h='\h' +case $(tr '[:upper:]' '[:lower:]' <<<"$HOSTNAME") in + pi*) color=31 ;; + # ovh - yellow + *.ovh.net|*.kimsufi.com|*.ip-*.eu) color=33 ;; + # mac - magenta + Nicolas-Boisselier-MacBook*) h="macbook"; color=35 ;; + MacMini*) color=35 ;; + *) color=36 ;; esac char='$'; [ $UID == "0" ] && char='#' @@ -75,5 +74,20 @@ if [ "$color_prompt" = yes ]; then else PS1="\u@\h:\W${char} " fi -unset color char + +# ls +ls_opt='-a' +case "$OSTYPE" in + darwin*) + [ "$color_prompt" = yes ] && ls_opt="$ls_opt -G" + ;; + *) + ls_opt="$ls_opt --time-style=long-iso" + [ "$color_prompt" = yes ] && ls_opt="$ls_opt --color=auto" + ;; +esac +[ "$ls_opt" == "" ] || alias ls="ls $ls_opt" +unset ls_opt +alias ll='ls -lh' +unset color char color_prompt h diff --git a/etc/bashrc.alias b/etc/bashrc.alias index 37b1c53b..f3296398 100644 --- a/etc/bashrc.alias +++ b/etc/bashrc.alias @@ -15,24 +15,6 @@ alias mysqlshow-view="mysql -e \"SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'\" alias nmap-ping="nmap -sP -PE -PS443 -PA21,22,23,80,3389" alias arp-list="arp -an" -#-------------------------------------------------------------------------------- -# ls -# -ls_opt='-a' -case "$OSTYPE" in - darwin*) - [ "$color_prompt" = yes ] && ls_opt="$ls_opt -G" - ;; - *) - ls_opt="$ls_opt --time-style=long-iso" - [ "$color_prompt" = yes ] && ls_opt="$ls_opt --color=auto" - ;; -esac -[ "$ls_opt" == "" ] || alias ls="ls $ls_opt" -unset ls_opt -alias ll='ls -lh' -unset color_prompt - #-------------------------------------------------------------------------------- # Etherwake # Cable: alias advent-on="etherwake -i eth0 00:22:68:7b:fb:99 -D -b"