#!/bin/bash # A self-contained script to install my personal dotfiles. # It writes or overwrites .vimrc, .tmux.conf, and # .bashrc with my preferred customizations. echo "Setting up server environment..." echo "Overwriting .vimrc" cat << 'EOF' > ~/.vimrc syntax on set number set showcmd set wildmenu colorscheme default set mouse=a set history=1000 set backspace=indent,eol,start set incsearch set hlsearch set ignorecase set smartcase set tabstop=4 set shiftwidth=4 set expandtab set autoindent EOF echo "Overwriting .tmux.conf" cat << 'EOF' > ~/.tmux.conf set -g status-style fg=colour231,bg=colour2 set -g status-interval 5 set -g status-left-length 300 set -g status-left '#[bold]  #(pretty=$(hostnamectl --pretty 2>/dev/null); [ -n "$pretty" ] && echo "$pretty" || hostname)#[nobold] | #{user}@#{host} | #(hostname -I | tr " " "\n" | grep -E "^(10\.|192\.168\.|172\.(1[6-9]|2[0-9]|3[01])\.)"|head -1||echo "no-private") | ' set -g status-right ' %b %d %H:%M:%S (#(TZ="America/Los_Angeles" date "+%%I:%%M %%p")) ' EOF echo "Overwriting .bashrc" cat << 'EOF' > ~/.bashrc case $- in *i*) ;; *) return;; esac HISTCONTROL=ignoreboth shopt -s histappend HISTSIZE=10000 HISTFILESIZE=10000 shopt -s checkwinsize [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) fi case "$TERM" in xterm-color|*-256color) color_prompt=yes;; esac if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt case "$TERM" in xterm*|rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" ;; *) ;; esac if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi if [[ -z "$TMUX" ]] && [[ "$-" == *i* ]]; then tmux attach -t "$HOSTNAME" || tmux new -s "$HOSTNAME" fi EOF echo "" echo "Done! Log out and log back in, or run 'source ~/.bashrc' to apply all changes."