#
# ROOT PATH
#
-case "$BASH_SOURCE" in */*) path="${BASH_SOURCE%/*}";; *) path='.' ;; esac
-[ -e "$path/profile.d/functions" ] && . "$path/profile.d/functions"
-NB_ROOT=$(realpath ${path}/.. 2>/dev/null)
-unset path
+case "$BASH_SOURCE" in
+ */*) dir="${BASH_SOURCE%/*}";;
+ *)
+ case "$ZSH_NAME" in
+ *zsh)
+ dir=${(%):-%N}
+ dir=${dir%/*}
+ ;;
+ *) dir='.' ;;
+ esac
+ ;;
+esac
+
+[ -e "$dir/profile.d/functions" ] && source "$dir/profile.d/functions"
+NB_ROOT=$(realpath ${dir}/.. 2>/dev/null)
+unset dir i
if [ -z "$NB_ROOT" ]; then
unset NB_ROOT
else
for i in ${NB_ROOT}/etc/profile.d/envs ${NB_ROOT}/etc/profile.d/aliases $NB_ROOT/etc/profile.d/*.sh; do
- [ -r "$i" ] && . "$i"
+ [ -r "$i" ] && source "$i"
done
unset i tmp
#
# PS1
#
-h='\h'
-color=''
-#case $(tr '[:upper:]' '[:lower:]' <<<"$HOSTNAME") in
-case "`hostname -f`" 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 ;;
- *.semantico.net|dev*|cst*|csp*|isp*) color=32 ;;
- *) color=36 ;;
-esac
-char='$'; [ $UID = "0" ] && char='#'
-if [ "$color_prompt" = yes -a -n "$color" ]; then
- PS1="\[\033[01;${color}m\]\u@$h:\[\033[00m\]\W${char} "
-else
- PS1="\u@\h:\W${char} "
-fi
-unset h color char
+case "$SHELL" in
+ */zsh) ;;
+ *)
+
+ h='\h'
+ color=''
+ #case $(tr '[:upper:]' '[:lower:]' <<<"$HOSTNAME") in
+ case "`hostname -f`" 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 ;;
+ *.semantico.net|dev*|cst*|csp*|isp*) color=32 ;;
+ *) color=36 ;;
+ esac
+
+ char='$'; [ $UID = "0" ] && char='#'
+ if [ "$color_prompt" = yes -a -n "$color" ]; then
+ PS1="\[\033[01;${color}m\]\u@$h:\[\033[00m\]\W${char} "
+ else
+ PS1="\u@\h:\W${char} "
+ fi
+
+ unset h color char
+ ;;
+esac
#
# ls
shell_functions() {
# NB 15.02.16 set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1\n"'
- typeset -f | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1\n"'
+ typeset -f | perl -ne '/^([a-z][\w_-]+) \(\)\s*\{*$/ and print "$1\n"'
#set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1 "' | perl -pe 's/\s+$//'
}
declare server; server="$1"; shift
declare tmp; tmp="/tmp/$FUNCNAME.$USER"
(
- alias
- eval type $(shell_functions|perl -pe 's/\s+/ /') | grep -v 'is a function$'
- echo "[ -r /etc/profile ] && . /etc/profile"
+ alias | sed -e 's/^alias //' -e 's/^/alias /'
+ eval type $(shell_functions|perl -pe 's/\s+/ /') | grep -v ' function$'
+ echo "[ -r /etc/profile ] && source /etc/profile"
) | ssh "$server" "cat > $tmp || rm -vf $tmp" || return
declare args
if [ -z "$@" ]; then
[ -z "$ssh_opt" ] && ssh_opt='-t'
- ssh $ssh_opt "$server" "bash --rcfile $tmp && rm -f $tmp"
+
+ case "$ZSH_NAME" in
+ *zsh) ssh $ssh_opt "$server" "source $tmp && zsh -f -d; rm -f $tmp" ;;
+ *) ssh $ssh_opt "$server" "bash --rcfile $tmp; rm -f $tmp" ;;
+ esac
+
else
ssh $ssh_opt "$server" "bash && rm -f $tmp" <<< ". $tmp; $@"
+
fi
}