diff --git a/bash_init.jssh b/bash_init.jssh new file mode 100755 index 0000000..d604664 --- /dev/null +++ b/bash_init.jssh @@ -0,0 +1 @@ +/bin/bash --rcfile $JSSHHOME/bashrc.jssh diff --git a/conf.d/bashrc b/bashrc.jssh similarity index 68% rename from conf.d/bashrc rename to bashrc.jssh index c592367..47c2a9b 100644 --- a/conf.d/bashrc +++ b/bashrc.jssh @@ -10,8 +10,9 @@ alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' alias sl='ls' -[ -r $JSSHHOME/screenrc ] && alias screen="screen -c $JSSHHOME/screenrc" -[ -r $JSSHHOME/vimrc ] && export VIMINIT="let \$MYVIMRC='$JSSHHOME/vimrc' | source \$MYVIMRC" +[ -x $JSSHHOME/sshrc.jssh ] && alias jssh="$JSSHHOME/sshrc.jssh" +[ -r $JSSHHOME/screenrc.jssh ] && alias screen="screen -c $JSSHHOME/screenrc.jssh" +[ -r $JSSHHOME/vimrc.jssh ] && export VIMINIT="let \$MYVIMRC='$JSSHHOME/vimrc.jssh' | source \$MYVIMRC" PROMPT_COMMAND=__prompt_command __prompt_command() { local curr_exit="$?" @@ -21,4 +22,4 @@ __prompt_command() { fi } set -o vi -EDITOR='vim' +export EDITOR='vim' diff --git a/conf.d/bash_init b/conf.d/bash_init deleted file mode 100755 index 2bc58ea..0000000 --- a/conf.d/bash_init +++ /dev/null @@ -1 +0,0 @@ -/bin/bash --rcfile $JSSHHOME/bashrc diff --git a/conf.d/screenrc b/screenrc.jssh similarity index 90% rename from conf.d/screenrc rename to screenrc.jssh index c17d79c..94236f9 100644 --- a/conf.d/screenrc +++ b/screenrc.jssh @@ -1,4 +1,4 @@ -defshell $JSSHHOME/bash_init +defshell $JSSHHOME/bash_init.jssh startup_message off deflogin on vbell off @@ -18,7 +18,7 @@ termcapinfo vt100 dl=5\E[M hardstatus off termcapinfo xterm*|rxvt*|kterm*|Eterm* hs:ts=\E]0;:fs=\007:ds=\E]0;\007 hardstatus string "%h%? users: %u%?" -hardstatus alwayslastline #"%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<" +hardstatus alwayslastline hardstatus string "%{= Kd}%{kd}%-Lw%{= Yk}%50>%n%f* %t%{-}%+Lw%< %-=%{kd}%{y}[%{-}%d/%m/%y - %c%{y}]" caption always string "%?%F%{.G.}%?%3n %t%? [%h]%?" termcapinfo xterm*|linux*|rxvt*|Eterm* OP diff --git a/sshrc.conf b/sshrc.conf.jssh similarity index 100% rename from sshrc.conf rename to sshrc.conf.jssh diff --git a/sshrc.jssh b/sshrc.jssh new file mode 100755 index 0000000..a11f8c7 --- /dev/null +++ b/sshrc.jssh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -eu + +CONFHOME="~/.local/share/jssh" +CONFALLBACK=$(dirname $(readlink -f -- "$0")) + +[[ -d $CONFHOME ]] && CONFDIR=$CONFHOME || CONFDIR=$CONFALLBACK + +[[ -r $CONFDIR/bashrc.jssh ]] || { echo "Confdir or bashrc missing or lack of permissions!"; exit 1; } + +DSTPREFIX=jssh + +[[ -r "$CONFDIR/sshrc.conf.jssh" ]] && source $CONFDIR/sshrc.conf.jssh + +arc=$(tar czf - -C $CONFDIR $(find $CONFDIR -name ".*" -prune -o -type f -regex ".*\.jssh" -printf "%f ")| base64 -w0) +[[ $(echo $arc | wc -c) -le 65535 ]] || { echo "Files size too large!"; exit 1; } + +COMMANDS=" +export JSSHHOME=\$(mktemp -d /tmp/$'"${DSTPREFIX}"'.XXXXXXXXXX); +echo $'"$arc"' | base64 -di | tar -xzf - -C \$JSSHHOME; +trap \"rm -rf \$JSSHHOME; exit\" 0; +bash --rcfile \$JSSHHOME/bashrc.jssh -i +" + +ssh -t $@ $COMMANDS diff --git a/sshrc.sh b/sshrc.sh deleted file mode 100755 index a22ef69..0000000 --- a/sshrc.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -eu - -CURDIR=$(dirname $(readlink "$0")) -CONFLOCAL="~/.local/share/jssh" -CONFHOME="$CONFLOCAL/conf.d" -CONFALLBACK="$CURDIR/conf.d" - -[[ -d $CONFHOME ]] && CONFDIR=$CONFHOME || CONFDIR=$CONFALLBACK - -[[ -r $CONFDIR/bashrc ]] || { echo "Confdir or bashrc missing or lack of permissions!"; exit 1; } - -DSTPREFIX=jssh - -if [[ -r "$CONFLOCAL/sshrc.conf" ]]; then - source "$CONFLOCAL/sshrc.conf" -elif [[ -r "$CURDIR/sshrc.conf" ]]; then - source "$CURDIR/sshrc.conf" -fi - -arc=$(tar czf - -C $CONFDIR $(find $CONFDIR -type f -printf "%f ")| base64 -w0) -[[ $(echo $arc | wc -c) -le 65535 ]] || { echo "Files size too large!"; exit 1; } - -COMMANDS=" -export JSSHHOME=\$(mktemp -d /tmp/$'"${DSTPREFIX}"'.XXXXXXXXXX); -echo $'"$arc"' | base64 -di | tar -xzf - -C \$JSSHHOME; -trap \"rm -rf \$JSSHHOME; exit\" 0; -bash --rcfile \$JSSHHOME/bashrc -i -" - -ssh -t $@ $COMMANDS diff --git a/conf.d/vimrc b/vimrc.jssh similarity index 100% rename from conf.d/vimrc rename to vimrc.jssh