summary refs log tree commit diff
path: root/bashrc
blob: 63a96f1ffbbf541f7d65239db999ca128b1dff65 (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
export EDITOR="emacsclient -a '' -nw"
export HISTFILE=
export LANG="en_US.UTF-8"
export LC_ALL="$LANG"
export LC_CTYPE="$LANG"
export PAGER="less"
export TMPDIR="${HOME}/tmp"
export TZ=America/Los_Angeles
export TERM="xterm-256color"

export PATH="$HOME/bin":"$HOME/.bin":"$PATH"

[ -z "$PS1" ] && return

# prompts
export PS1="\W % "

# limits
ulimit -S -c 0

# Set up ssh-agent
SSH_ENV="$HOME/.ssh/environment"

function start_agent {
  if [[ -f "${HOME}/.ssh/id_rsa" ]]; then
    echo "Initializing new GPG agent..."
    touch $SSH_ENV
    chmod 600 "${SSH_ENV}"
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' >> "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    /usr/bin/ssh-add
  fi
}

# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
  . "${SSH_ENV}" > /dev/null
  kill -0 $SSH_AGENT_PID 2>/dev/null || {
    start_agent
  }
else
  start_agent
fi

# some aliases
if [[ "${OSTYPE}" =~ "darwin" ]]; then
  alias ls='ls -G'
else
  alias ls='ls --color'
fi

alias cp="cp -i"
alias l="ls"
alias la="ls -a"
alias ll="ls -lh"
alias lt="ls -lhtr"
alias mv="mv -i"
alias rm="rm -i"

alias e="$EDITOR"
alias g="git"
alias gclean="git clean -dfx"
alias gst="git status"

alias gerp="grep --color=auto"
alias grep="grep --color=auto"

alias pjson="python -mjson.tool"
alias s="cd ~/src/source"
alias eb="cd ~/src/source/eventbus"
alias ops="cd ~/src/twitter-ops"

# tmux
alias tmux='tmux -2'
alias tmuxl='tmux new -A -s local'
alias tmuxr='tmux new -A -s remote'

# local stuff
[ -f "${HOME}/.bash_local" ] && source "${HOME}/.bash_local"

function gitme {
  git config --local user.email "franckcuny@gmail.com"
  git config --local user.name "Franck Cuny"
}

function puppet-master {
  local hostlist=$1
  if [[ -z "${hostlist}" ]]; then
    echo "host list is missing"
    return 1
  fi

  batch_size=$(sed -n '$=' "${hostlist}")
  if [[ "${batch_size}" -gt 10 ]]; then
    batch_size=10
  fi
  loony -F "${hostlist}" -t "${batch_size}" run sudo puppet-util run
}