diff --git a/dot_sshrc.tmpl b/dot_sshrc.tmpl new file mode 100644 index 0000000..8ecf1b7 --- /dev/null +++ b/dot_sshrc.tmpl @@ -0,0 +1,115 @@ +# +# sshrc will be called byaliased ssh command 's'. +# +if [ -f $HOME/.profile ]; then + source $HOME/.profile +fi +if [ -f $HOME/.bashrc ]; then + source $HOME/.bashrc +fi + +# +# System Name and type detectedn +# +mySystem=$(uname -n) +myFQDN="$(uname -n).$(dnsdomainname)" +myCategory={{.bash.prompt.category}} +myType={{.chezmoi.hostname}} +myPrettyName={{.chezmoi.osRelease.prettyName}} + +# last exit code +function lastExitCode { + local exit="$?" + + if [ $exit != 0 ];then + printf '\e[38;5;160m%-5s' "✕ ❗ ($exit)" + else + printf '✔' + fi +} + +# sourcing Solarized Theme +# and building PS1 prompt +source $HOME/.solarize_colors_base +echo "mySystem: $mySystem" +echo "myFQDN: $myFQDN" + +bg_type="\[\e[48;5;254m\]" +bg_reset="\[\e[49m\]" +fg_reset="\[\e[39m\]" + +bg_system="${sol_bg_magenta}" +fg_system="${sol_base3}" +fg_type="${sol_magenta}" + +bg_type="${sol_bg_base3}" +fg_arrow1="${fg_type}" +fg_arrow2="${sol_base3}" + + +if [[ -z "${myType// }" ]]; then + TYPE=$(uname -n) +else +TYPE=" $myType " +fi +if [ "$myNum" != "0" ]; then + TYPE="$TYPE ($myNum)" +fi +echo "System Prompt: $SYSTEM_PROMPT" + +SYSTEM_PROMPT="\n${fg_arrow1}░▒▓${bg_system} ${fg_system}${myCategory} ${bg_type}${fg_arrow1}▓▒░" +TYPE_PROMPT="$TYPE  \$(lastExitCode) ${fg_arrow1}  $myPrettyName ${sol_blue}\${STY#[0-9]*.} ${bg_reset}${fg_arrow2}▓▒░" + +PROMPT="${SYSTEM_PROMPT} ${TYPE_PROMPT}" +DATE="\[\e[0;32m\]\d \t" +if [ "$(whoami)" = "root" ]; then + DIR="\[\e[97;49m\]\[\e[0;91;107m\] \u@\h \[\e[97;49m\]\[\e[39;49m\] in \[\e[0;32m\]\w" +else + DIR="\[\e[0;32m\]\u@\h \[\e[31m\]☆ \[\e[0;32m\]\w" +fi + +# PROMPT_COMMAND=promptcmd + +PS1="${PROMPT}\[\e[0m\] \n${DIR}\n${DATE} → \[\e[0m\]" + +if [ $(whoami | grep root | wc -l) == 1 ]; then + echo -e "\e[31;107m┌─────────────────────────────┐\e[0m" + echo -e "\e[31;107m│ YOU ARE ROOT, BE CAREFUL! │\e[0m" + echo -e "\e[31;107m└─────────────────────────────┘\e[0m" + + # Test mintty + echo -ne '\e]11;44,10,10\a' +fi + +# TODO: background colors... +# TODO: private history file for shared accounts +# TODO: vim + +export LS_OPTIONS='--color=auto' +eval "$(dircolors -b)" +alias ls='ls $LS_OPTIONS' + +alias psg='ps -aux | grep -v grep | grep ' + +# Some functions (some by c't magazine) +cdl() { + cd "$@" + if [ "$?" == 0 ]; then + ls + fi +} + +backup() { + cp -p "$@" "$@".backup-$(date +%Y-%m-%d_%H_%M_%S) +} + +extract() { + case $1 in + *.tar.bz2) tar xvjf $1;; + *.tar.gz|*.tgz) tar xvfz $1;; + *.zip) unzip $1;; + *) echo "Not supported: $1";; + esac +} + +PATH=$PATH:$HOME/bin