Last active
December 14, 2015 20:49
-
-
Save schuyler/5146553 to your computer and use it in GitHub Desktop.
my .bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source .bashrc | |
if [ `hostname -s` != $MY_LAPTOP ]; then | |
# reattach or start a new screen. don't make it a login shell. | |
screen -xRR -ln | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MY_USERNAME=schuyler | |
MY_LAPTOP=lappy386 | |
# prompt configuration. | |
# | |
if [ `hostname -s` != $MY_LAPTOP ]; then | |
# ... remote terminal prompt looks like: | |
# | |
# 16:08:35 my_server:~$ | |
# | |
# ... or if not using my regular username remotely: | |
# | |
# 16:08:35 ubuntu@aws_instance:~$ | |
# | |
HOST=`hostname -s` | |
if [ `whoami` != $MY_USERNAME ]; then | |
HOST=`whoami`@$HOST | |
fi | |
export PS1="\\[\\e]0;$HOST:\\w\\a\\]\\t $HOST:\\w$ " | |
else | |
# ... local terminal prompt looks like: | |
# | |
# 13:07:59 ~$ | |
export PS1='\[\e]0;\w\a\]\t \w$ ' | |
fi | |
# setting $SSH_AUTH_SOCK in combination with .screenrc lets ssh-agent reconnect | |
# after detaching and reattaching a screen(1) session. | |
# | |
test $SSH_AUTH_SOCK && ln -sf "$SSH_AUTH_SOCK" "/tmp/ssh-agent-$USER-screen" | |
# keep the matching .screenrc here for reference. | |
# | |
[ ! -r ~/.screenrc ] && cat > ~/.screenrc <<EOF | |
defutf8 on | |
term screen-256color | |
unsetenv SSH_AUTH_SOCK | |
setenv SSH_AUTH_SOCK "/tmp/ssh-agent-$USER-screen" | |
EOF | |
# usage: moveinto new.remote.server | |
# copies up all the necessaries, including this file. | |
# | |
moveinto () { | |
cd ~ | |
ssh $1 'mkdir -p .ssh && chmod 700 .ssh' | |
rsync -av .ssh/id_rsa.pub $1:.ssh/authorized_keys | |
rsync -av .ssh/config $1:.ssh/config | |
rsync -avz .screenrc .bash_profile .bashrc .gitconfig .gemrc .vim* $1: | |
} | |
# minutiae. | |
# | |
# don't put duplicate lines in the history. | |
HISTCONTROL=ignoredups | |
# append to the history file, don't overwrite it | |
shopt -s histappend | |
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | |
HISTSIZE=1000 | |
HISTFILESIZE=2000 | |
# check the window size after each command and, if necessary, | |
# update the values of LINES and COLUMNS. | |
shopt -s checkwinsize | |
# other minutiae. | |
export EDITOR=/usr/bin/vim | |
export TZ=America/Los_Angeles | |
alias h='history | tail -20' | |
# handy git aliases. | |
# | |
alias pull="git pull --ff-only origin" | |
alias fetch="git fetch" | |
alias rebase="git rebase -i" | |
alias commit="git commit" | |
alias checkout="git checkout" | |
alias push="git push origin" | |
alias branch="git branch" | |
alias merge="git merge" | |
alias delta="git diff" # so as not to conflict with diff(1) | |
alias status="git status" | |
alias log="git log" | |
alias stash="git stash" | |
# put server-specific stuff in ~/.bashrc.local | |
# | |
[ -r ~/.bashrc.local ] && source ~/.bashrc.local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment