-
Notifications
You must be signed in to change notification settings - Fork 5
/
sshrc
44 lines (37 loc) · 1.38 KB
/
sshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
if [[ -f /etc/profile ]]; then source /etc/profile ; fi
if [[ -f ~/.bashrc ]]; then source ~/.bashrc ; fi
if [[ -f ~/.bash_profile ]]; then source ~/.bash_profile ; fi
if [[ -f ~/.bash_login ]]; then source ~/.bash_login ; fi
if [[ -f ~/.profile ]]; then source ~/.profile ; fi
if [[ -f ~/.bash_logout ]]; then source ~/.bash_logout ; fi
source ${SSHHOME}/.sshrc.d/aliases.zsh
export VIMINIT="let \$MYVIMRC='$SSHHOME/.sshrc.d/vimrc' | source \$MYVIMRC"
export VISUAL=vim
export EDITOR=$VISUAL
# Allow autocd
if [ -n "$ZSH_VERSION" ]; then
setopt autocd
elif [ -n "$BASH_VERSION" ]; then
shopt -s autocd
fi
screenrc() {
local SCREENDIR=/tmp/sshrc_screen
if ! [ -d $SCREENDIR ]; then
rm -rf $SCREENDIR
mkdir -p $SCREENDIR
fi
cp -r $SSHHOME/bashsshrc $SSHHOME/sshrc $SSHHOME/.sshrc $SSHHOME/.sshrc.d $SCREENDIR
if [ -z "$1" ] ; then
# generate random screen name
local SCREENNAME="$(whoami)_$(LC_CTYPE=C tr -dc A-Za-z < /dev/urandom | head -c 8 | xargs)"
else
# screen name as a function argument
local SCREENNAME=$1
fi
# create a new screen
SSHHOME=$SCREENDIR /usr/bin/screen -dmS $SCREENNAME
# load .sshrc and clear screen
SSHHOME=$SCREENDIR /usr/bin/screen -r $SCREENNAME -p 0 -X stuff "source $SCREENDIR/.sshrc"`printf '\015'`
# attach
SSHHOME=$SCREENDIR /usr/bin/screen -r $SCREENNAME
}