Skip to content

Instantly share code, notes, and snippets.

@xeonchen
Last active June 27, 2018 08:02
Show Gist options
  • Save xeonchen/1a881f6cf0403519f83ceec90a49fb2a to your computer and use it in GitHub Desktop.
Save xeonchen/1a881f6cf0403519f83ceec90a49fb2a to your computer and use it in GitHub Desktop.
[[ -r ~/.bashrc ]] && . ~/.bashrc
case $- in
*i*) ;;
*) return;;
esac
[ -r ~/.bash_aliases ] && . ~/.bash_aliases
[ -r /etc/bash_completion ] && . /etc/bash_completion
[ -r ~/.bash_completion ] && . ~/.bash_completion
export EDITOR=vim
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
export PATH="$HOME/.local/bin:$HOME/.local/sbin:$PATH"
export HISTCONTROL=ignoreboth:erasedups
export HISTFILESIZE=1000000
export HISTSIZE=1000000
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
shopt -s histappend
shopt -s checkwinsize
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h:\W \$(parse_git_branch)\\$ "
[ -r ~/.bashrc_loader ] && . ~/.bashrc_loader
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
################################
# SSH-Agent #
################################
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
for pkey in ~/.ssh/id_ecdsa ~/.ssh/id_rsa
do
test -f $pkey && chmod 600 $pkey && /usr/bin/ssh-add $pkey;
done
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
################################
# Platform Dependent Files #
################################
PLATFORM=$(uname -s)
BASHRC_PLATFORM=~/.bashrc_${PLATFORM,,}
[ -r $BASHRC_PLATFORM ] && . $BASHRC_PLATFORM
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: set sw=4 ts=4 sts=4 et fileencoding=utf-8 :
import os
import sys
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
TARGET_DIR = os.environ['HOME']
FILES = filter(lambda f: f.startswith('dot.'), os.listdir(BASE_DIR))
def main(argv):
for f in FILES:
link_name = os.path.join(TARGET_DIR, f[3:])
target_name = os.path.join(BASE_DIR, f)
if os.path.islink(link_name):
os.unlink(link_name)
print 'Installing %s' % link_name
os.symlink(target_name, link_name)
if __name__ == '__main__':
try:
main(sys.argv)
except KeyboardInterrupt:
print 'abort'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment