diff --git a/bash/bash_aliases b/bash/bash_aliases index fac031f..b56e9bc 100644 --- a/bash/bash_aliases +++ b/bash/bash_aliases @@ -1,12 +1,25 @@ -function parse_git_branch { - git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' -} +export EDITOR='vi' +export WORKON_HOME=$HOME/.virtualenvs +export LC_CTYPE="en_US.UTF-8" +export LANG="en_US.UTF-8" -if [ -f $HOME/.srv_name ]; then - SRV_NAME=`cat $HOME/.srv_name` - PS1='\u@\h($SRV_NAME):\W $(parse_git_branch)\n\$ ' +alias tmux='tmux -u' +alias t='tmux.py' +alias reKill='reKill.py' +alias pysmtp='python -m smtpd -n -c DebuggingServer localhost:1025' +alias resetterminal='echo -n -e "\033]0;\007"' +alias gitpretty="git log --pretty=format:'%h : %Cblue%aN%Creset : %Cred%d%Creset : %s' --graph" + +if [[ -r $HOME/.host_nickname ]]; then + HOST_NICKNAME=`cat ${HOME}/.host_nickname` else - PS1='\u@\h:\W $(parse_git_branch)\n\$ ' + HOST_NICKNAME=`hostname -s` fi -export PS1 +export PS1="\u@${HOST_NICKNAME}:\W \$ " + +if [[ -r $HOME/.${HOST_NICKNAME}_bash_profile ]]; then + source $HOME/.${HOST_NICKNAME}_bash_profile +else + echo "WARNING: Can't find custom bash_profile" +fi diff --git a/bash/bash_profile b/bash/bash_profile index fc6b398..0870c41 100644 --- a/bash/bash_profile +++ b/bash/bash_profile @@ -1,7 +1,7 @@ export EDITOR='vi' export WORKON_HOME=$HOME/.virtualenvs export LC_CTYPE="en_US.UTF-8" -export LANG="en_US" +export LANG="en_US.UTF-8" alias tmux='tmux -u' alias t='tmux.py' @@ -14,7 +14,7 @@ alias ls='ls -G' alias ll='ls -lG' if [[ -r $HOME/.host_nickname ]]; then - HOST_NICKNAME=`cat .host_nickname` + HOST_NICKNAME=`cat ${HOME}/.host_nickname` else HOST_NICKNAME=`hostname -s` fi diff --git a/scripts/tmux.py b/scripts/tmux.py new file mode 100755 index 0000000..b1fffed --- /dev/null +++ b/scripts/tmux.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +import os +import subprocess + +print "TMUX: %s" % os.getenv("TMUX", "") +print "SSH_TTY: %s" % os.getenv("SSH_TTY", "") +print "SSH_AUTH_SOCK: %s" % os.getenv("SSH_AUTH_SOCK", "") +print "HOME: %s" % os.getenv("HOME", "") + +if os.getenv("TMUX") is None: + if os.getenv("SSH_TTY") is not None: + if os.getenv("SSH_AUTH_SOCK") is not None: + sock_file = os.path.join(os.getenv("HOME"), ".wrap_auth_sock") + try: + #always try to remove + os.remove(sock_file) + except OSError: + pass + os.symlink(os.getenv("SSH_AUTH_SOCK"), sock_file) + os.environ['SSH_AUTH_SOCK'] = sock_file + + try: + subprocess.check_call(["tmux", "attach-session", "-t", "sshwrap"]) + except subprocess.CalledProcessError: + print "lets create session" + os.environ['STY'] = "tmux-sshwrap" + os.execlpe("tmux", "tmux", "new-session", "-s", "sshwrap", + os.environ) diff --git a/vim/vimrc b/vim/vimrc index a066593..861e24d 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -166,3 +166,39 @@ if 'VIRTUAL_ENV' in os.environ: activate_this = os.path.join(project_base_dir, 'bin/activate_this.py') execfile(activate_this, dict(__file__=activate_this)) EOF + +" +" Put Tab numbers on tabline +" http://vim.wikia.com/wiki/Show_tab_number_in_your_tab_line +" +if exists("+showtabline") + function MyTabLine() + let s = '' + let t = tabpagenr() + let i = 1 + while i <= tabpagenr('$') + let buflist = tabpagebuflist(i) + let winnr = tabpagewinnr(i) + let s .= '%' . i . 'T' + let s .= (i == t ? '%1*' : '%2') + let s .= ' ' + let s .= i . ')' + "let s .= ' %*' + let s .= (i == t ? ' %*' : ' ') " Added by BMS + let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#') + let file = bufname(buflist[winnr - 1]) + let file = fnamemodify(file, ':p:t') + if file == '' + let file = '[No Name]' + endif + let s .= file + let s .= ' %*' " Added by BMS + let i = i + 1 + endwhile + let s .= '%T%#TabLineFill#%=' + let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X') + return s + endfunction + set stal=2 + set tabline=%!MyTabLine() +endif