1
0
Fork 0

configs from workstation

main
Marissa Staib 5 years ago
commit e70f7cd2df
  1. 60
      .bash_aliases
  2. 36
      .bash_tmux
  3. 12
      .inputrc
  4. 8
      .ssh/rc
  5. 87
      .tmux.conf
  6. 38
      .tmux.screen.conf
  7. 52
      .tmux.status.sh
  8. 109
      .vimrc

@ -0,0 +1,60 @@
# vim: set filetype=sh:
# Install EDITOR
export EDITOR='vim -X'
# Update SSH_AUTH_SOCK
sock_proxy=$HOME/.ssh/ssh_auth_sock
if [ -S "$(readlink $sock_proxy)" ]; then
SSH_AUTH_SOCK=$sock_proxy
fi
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
alias vim="vim -X"
# Send a bell before the prompt if it has been a long time since the last
# prompt.
# function bell_on_long_running_commands() {
# local NOW=`date -u +%s`
# if [ $(( LASTCMD_FOR_BELLS )) -lt $(( NOW - 15 )) ]; then
# echo -n $'\a'
# fi
# unset LASTCMD_FOR_BELLS;
# }
# function set_last_command_time() {
# if [[ -z "${COMPLINE}" ]] && [[ -z "${LASTCMD_FOR_BELLS}" ]]; then
# LASTCMD_FOR_BELLS=`date -u +%s`
# fi
# }
# trap set_last_command_time DEBUG
# export PROMPT_COMMAND=bell_on_long_running_commands
function bell_after() {
"$@"
local exit="$?"
echo -n $'\a' 1>&2
return "$exit"
}
# Reload aliases
function bashreload()
{
source "$HOME"/.bashrc
}
function man ()
{
command man "$@" 2>/dev/null || builtin help -m "$@" 2>/dev/null || command man "$@"
}
function help ()
{
builtin help -m "$@" 2>/dev/null || command man "$@" 2>/dev/null || builtin help -m "$@"
}
PS1='\[\e[1;31m\]${debian_chroot:+($debian_chroot)}\[\e[0;36m\]\u\[\e[0;33m\]@\[\e[34m\]\h\[\e[0m\]:\[\e[1;32m\]\w\[\e[0m\]\n\$ '
source ~/.bash_tmux
auto_tmux

@ -0,0 +1,36 @@
#!/bin/bash
# vim: set filetype=sh:
function tmux_has_main() {
tmux -2 has-session -t "Main Screen"
}
function tmux_init_main() {
tmux -2 new-session -d -s "Main Screen" -n "Misc."
tmux -2 new-window -d -t "Main Screen:0" -n "Monitor" "htop"
}
function go_tmux ()
{
if [[ "$TERM" == screen* ]]; then
echo "Screenception is not permitted."
return 1;
fi
sleep 1s
echo "Starting tmux..."
tmux_has_main || tmux_init_main || return 1
if [[ $1 == "-x" ]]; then
exec tmux -2 attach-session -t "Main Screen" || return 1
else
tmux -2 attach-session -t "Main Screen" || return 1
fi
}
function auto_tmux ()
{
if [[ "$TERM" != screen* ]] && [[ -z "$ALREADY_TRIED_STARTING_TMUX" ]]; then
ALREADY_TRIED_STARTING_TMUX=true
echo "Switching to tmux, press Ctrl+C to cancel...";
sleep 1s && go_tmux -x
fi
}

@ -0,0 +1,12 @@
# Mac terminal keys
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
set completion-ignore-case On

@ -0,0 +1,8 @@
#!/bin/sh
if [ -n "$SSH_AUTH_SOCK" ]; then
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
fi
source /etc/ssh/sshrc

@ -0,0 +1,87 @@
##############
# Key Bindings
##############
set-option -g status-keys emacs
set-window-option -g mode-keys vi
set-window-option -g xterm-keys on
bind-key _ split-window -v
source-file %%HOMEDIR%%/.tmux.screen.conf
#####################
# Terminal Properties
#####################
set-option -g default-terminal screen-256color-bce
############################
# Status/Title Configuration
############################
set-option -g set-titles on
set-option -g set-titles-string "#S - #W (#I.#P) #T"
set-option -g status on
set-option -g status-justify left
set-option -g status-left "#h#(%%HOMEDIR%%/.tmux.status.sh)"
set-option -g status-left-length 25
set-option -g status-right "%a %b %d %l:%M%p #[bg=colour21]#S:#I.#P"
set-option -g status-interval 5
set-window-option -g clock-mode-style 12
#############
# Colorscheme
#############
set-option -g message-attr default
set-option -g message-bg colour15
set-option -g message-fg colour232
set-option -g status-style bg=blue,fg=white
set-option -g status-left-style bg=colour51,fg=colour232,bold
set-option -g status-right-style bg=colour33,fg=colour15,bold
set-window-option -g window-status-current-style bg=blue,fg=white,bold
#############################
# Misc Session/Global Options
#############################
set-option -g base-index 1
set-option -g history-limit 99999
###############################
# Unused Session/Global Options
###############################
# set-option -ug bell-action
# set-option -ug default-command
# set-option -ug default-shell
# set-option -ug display-panes-color
# set-option -ug display-panes-time
# set-option -ug display-time
# set-option -ug lock-after-time
# set-option -ug lock-command
# set-option -ug lock-server
# set-option -ug mouse-select-pane
# set-option -ug repeat-time
# set-option -ug set-remain-on-exit
# set-option -ug status-right-length
# set-option -ug terminal-overrides
# set-option -ug update-environment
# set-option -ug visual-activity
# set-option -ug visual-bell
# set-option -ug visual-content
#######################
# Unused Window Options
#######################
# set-window-option -ug aggressive-resize
# set-window-option -ug automatic-rename
# set-window-option -ug clock-mode-colour
# set-window-option -ug force-height
# set-window-option -ug force-width
# set-window-option -ug main-pane-width
# set-window-option -ug main-pane-height
# set-window-option -ug mode-attr
# set-window-option -ug mode-bg
# set-window-option -ug mode-fg
# set-window-option -ug mode-mouse
# set-window-option -ug monitor-activity
# set-window-option -ug monitor-content
# set-window-option -ug remain-on-exit
# set-window-option -ug synchronize-panes
# set-window-option -ug window-status-attr
# set-window-option -ug window-status-bg
# set-window-option -ug window-status-fg

@ -0,0 +1,38 @@
# screen's prefix is Ctrl-A
set-option -g prefix C-a
# send prefix with a
unbind C-b
bind a send-prefix
# move to last window with Ctrl-A
unbind l
bind C-a last-window
# rename window with A
unbind ,
bind A command-prompt "rename-window '%%'"
# also create windows with Ctrl-C
bind C-c new-window
# also detach with Ctrl-D
bind C-d detach-client
# also go next window with Ctrl-N, space
unbind " "
bind " " next-window
bind C-n next-window
# also go previous with h, backspace
bind h previous-window
bind BSpace previous-window
# show window list with C-W, w
bind C-w list-windows
# unbind w
# bind w list-windows
# choose window with "
unbind '"'
bind '"' choose-window

@ -0,0 +1,52 @@
#!/bin/bash
TIMELEFT=${1:-INVALID}
if [[ $TIMELEFT == "INVALID" ]]; then
TIMELEFT=0
fi
COLORS=(
196 # red
202 208 214 220 # oranges
226 226 # yellow
190 154 118 # yellow-greens
046 046 046 # green
047 048 049 050 # green-cyans
051 # cyan
)
HOURS=$(( $TIMELEFT / (60 * 60) ))
MINUTES=$(( $TIMELEFT / 60 - $HOURS * 60 ))
TOTAL_MINUTES=$(( $HOURS * 60 + $MINUTES ))
THRESHOLD=$(( 8 * 60 * 60 ))
if [[ ! $TIMELEFT -lt $THRESHOLD ]]; then
GRADIENTINDEX=$(( ${#COLORS[@]} - 1 ))
elif [[ ! $TIMELEFT -gt 0 ]]; then
GRADIENTINDEX=0
else
GRADIENTINDEX=$(( ${#COLORS[@]} * $TIMELEFT / $THRESHOLD ))
fi
COLOR=${COLORS[$GRADIENTINDEX]}
if [[ $HOURS -gt 99 ]]; then
HOURS=99
MINUTES=59
fi
if [[ $HOURS -lt 10 ]]; then
HOURS=0$HOURS
fi
if [[ $MINUTES -lt 10 ]]; then
MINUTES=0$MINUTES
fi
# echo -en "\033[48;5;${COLOR}m"
if [[ $TIMELEFT -le 0 ]]; then
echo -n " #[bg=colour${COLOR}][00m"
elif [[ $TOTAL_MINUTES -le 99 ]]; then
if [[ $TOTAL_MINUTES -lt 10 ]]; then
TOTAL_MINUTES=0$TOTAL_MINUTES
fi
echo -n " #[bg=colour${COLOR}][${TOTAL_MINUTES}m"
else
echo -n " #[bg=colour${COLOR}][${HOURS}h"
fi
if [[ -f /var/run/reboot-required ]]; then
echo "|#[bg=colour${COLORS[0]}]REBOOT#[bg=colour${COLOR}]]"
else
echo "]"
fi

109
.vimrc

@ -0,0 +1,109 @@
" Welcome to Vim (http://go/vim).
"
" If you see this file, your homedir was just created on this workstation.
" That means either you are new to Google (in that case, welcome!) or you
" got yourself a faster machine.
" Either way, the main goal of this configuration is to help you be more
" productive; if you have ideas, praise or complaints, direct them to
" vi-users@google.com (http://g/vi-users). We'd especially like to hear from you
" if you can think of ways to make this configuration better for the next
" Noogler.
" If you want to learn more about Vim at Google, see http://go/vimintro.
" Enable modern Vim features not compatible with Vi spec.
set nocompatible
" Use the 'google' package by default (see http://go/vim/packages).
source /usr/share/vim/google/google.vim
" Plugin configuration.
" See http://google3/devtools/editors/vim/examples/ for example configurations
" and http://go/vim/plugins for more information about vim plugins at Google.
" Plugin loading is commented out below - uncomment the plugins you'd like to
" load.
" Load google's formatting plugins (http://go/vim/plugins/codefmt-google).
" The default mapping is \= (or <leader>= if g:mapleader has a custom value),
" with
" - \== formatting the current line or selected lines in visual mode
" (:FormatLines).
" - \=b formatting the full buffer (:FormatCode).
"
" To bind :FormatLines to the same key in insert and normal mode, add:
" noremap <C-K> :FormatLines<CR>
" inoremap <C-K> <C-O>:FormatLines<CR>
Glug codefmt plugin[mappings] gofmt_executable="goimports"
Glug codefmt-google
" Enable autoformatting on save for the languages at Google that enforce
" formatting, and for which all checked-in code is already conforming (thus,
" autoformatting will never change unrelated lines in a file).
" Note formatting changed lines only isn't supported yet
" (see https://github.com/google/vim-codefmt/issues/9).
augroup autoformat_settings
autocmd FileType bzl AutoFormatBuffer buildifier
autocmd FileType go AutoFormatBuffer gofmt
" See go/vim/plugins/codefmt-google, :help codefmt-google and :help codefmt
" for details about other available formatters.
augroup END
" Load YCM (http://go/ycm) for semantic auto-completion and quick syntax
" error checking. Pulls in a google3-enabled version of YCM itself and
" a google3-specific default configuration.
Glug youcompleteme-google
" Load the automated blaze dependency integration for Go.
" Note: for Go, blazedeps uses the Go team's glaze tool, which is fully
" supported by the Go team. The plugin is currently unsupported for other
" languages.
Glug blazedeps auto_filetypes=`['go']`
" Load piper integration (http://go/VimPerforce).
Glug piper plugin[mappings]
" Load Critique integration. Use :h critique for more details.
Glug critique plugin[mappings]
" Load blaze integration (http://go/blazevim).
Glug blaze plugin[mappings]
" Load the syntastic plugin (http://go/vim/plugins/syntastic-google).
" Note: this requires installing the upstream syntastic plugin from
" https://github.com/scrooloose/syntastic.
Glug syntastic-google
" Load the ultisnips plugin (http://go/ultisnips).
" Note: this requires installing the upstream ultisnips plugin from
" https://github.com/SirVer/ultisnips.
Glug ultisnips-google
" All of your plugins must be added before the following line.
" See go/vim-plugin-manager if you need help picking a plugin manager and
" setting it up.
" Enable file type based indent configuration and syntax highlighting.
" Note that when code is pasted via the terminal, vim by default does not detect
" that the code is pasted (as opposed to when using vim's paste mappings), which
" leads to incorrect indentation when indent mode is on.
" To work around this, use ":set paste" / ":set nopaste" to toggle paste mode.
" You can also use a plugin to:
" - enter insert mode with paste (https://github.com/tpope/vim-unimpaired)
" - auto-detect pasting (https://github.com/ConradIrwin/vim-bracketed-paste)
filetype plugin indent on
syntax on
" So we can see tabs and trailing spaces.
hi SpecialKey ctermbg=Yellow guibg=Yellow
" Make it so that tabs and trailing spaces are always visible:
" (Relys on syntax highlighting to turn them yellow.)
set list
set listchars=tab:\ \ ,trail:\ ,extends,precedes
let g:Powerline_symbols = 'unicode'
let g:Powerline_stl_path_style = 'short'
set modeline
set expandtab
set shiftwidth=2
set softtabstop=2
set laststatus=2
hi Statement ctermfg=3 guifg=#C4A000
Loading…
Cancel
Save