Move uncommon bash config items out of .bashrc and deploy them via Ansible
This commit is contained in:
parent
654445457d
commit
d7257d876b
|
@ -1,51 +1,93 @@
|
||||||
# Install Homebrew
|
# Install Homebrew
|
||||||
- name: Check for Homebrew
|
- name: 'Brew: Check if already installed'
|
||||||
tags:
|
tags:
|
||||||
- install
|
- install
|
||||||
|
- brew
|
||||||
stat:
|
stat:
|
||||||
path: /usr/local/bin/brew
|
path: /usr/local/bin/brew
|
||||||
register: st
|
register: st
|
||||||
|
|
||||||
- name: Install Homebrew
|
- name: 'Brew: Install'
|
||||||
tags:
|
tags:
|
||||||
- install
|
- install
|
||||||
|
- brew
|
||||||
command: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
command: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||||
when: st.stat.executable != True
|
when: st.stat.executable != True
|
||||||
|
|
||||||
- name: Disable Homebrew analytics
|
- name: 'Brew: Disable analytics'
|
||||||
|
tags:
|
||||||
|
- config
|
||||||
|
- brew
|
||||||
command: brew analytics off
|
command: brew analytics off
|
||||||
|
|
||||||
# Taps
|
# Taps
|
||||||
- name: Install Homebrew Taps
|
- name: 'Brew: Install Taps'
|
||||||
tags:
|
tags:
|
||||||
- install
|
- install
|
||||||
|
- brew
|
||||||
|
- packages
|
||||||
homebrew_tap:
|
homebrew_tap:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
loop: "{{ homebrew_tap_items }}"
|
loop: "{{ homebrew_tap_items }}"
|
||||||
|
|
||||||
# Update and upgrades
|
# Update and upgrades
|
||||||
- name: Homebrew update and upgrades
|
- name: 'Brew: Update and upgrades'
|
||||||
tags:
|
tags:
|
||||||
- install
|
- install
|
||||||
|
- brew
|
||||||
|
- upgrade
|
||||||
|
- update
|
||||||
homebrew:
|
homebrew:
|
||||||
update_homebrew: True
|
update_homebrew: True
|
||||||
upgrade_all: True
|
upgrade_all: True
|
||||||
|
|
||||||
# Brews
|
# Brews
|
||||||
- name: Install Homebrew Brews
|
- name: 'Brew: Install packages'
|
||||||
tags:
|
tags:
|
||||||
- install
|
- install
|
||||||
|
- brew
|
||||||
|
- packages
|
||||||
homebrew:
|
homebrew:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
loop: "{{ homebrew_brew_items }}"
|
loop: "{{ homebrew_brew_items }}"
|
||||||
|
|
||||||
# Casks
|
# Casks
|
||||||
- name: Install Homebrew Casks
|
- name: 'Brew: Install Casks'
|
||||||
tags:
|
tags:
|
||||||
- install
|
- install
|
||||||
|
- brew
|
||||||
|
- cask
|
||||||
|
- packages
|
||||||
homebrew_cask:
|
homebrew_cask:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
loop: "{{ homebrew_cask_items }}"
|
loop: "{{ homebrew_cask_items }}"
|
||||||
|
|
||||||
|
# Config
|
||||||
|
- name: 'Brew: Bash completion'
|
||||||
|
tags:
|
||||||
|
- config
|
||||||
|
- brew
|
||||||
|
- shell
|
||||||
|
copy:
|
||||||
|
content: |
|
||||||
|
if [ -f $(brew --prefix 2>/dev/null)/etc/bash_completion ]; then
|
||||||
|
. $(brew --prefix 2>/dev/null)/etc/bash_completion
|
||||||
|
fi
|
||||||
|
dest: '~/.bashrc.d/homebew_bash_completion'
|
||||||
|
mode: '0400'
|
||||||
|
|
||||||
|
- name: 'Brew: API token'
|
||||||
|
tags:
|
||||||
|
- config
|
||||||
|
- homebrew
|
||||||
|
- shell
|
||||||
|
copy:
|
||||||
|
content: |
|
||||||
|
if [ -x "$(which brew 2>/dev/null)" ]; then
|
||||||
|
export HOMEBREW_GITHUB_API_TOKEN=$(getkey HOMEBREW_GITHUB_API_TOKEN)
|
||||||
|
fi
|
||||||
|
dest: '~/.bashrc.d/homebrew_token'
|
||||||
|
mode: '0400'
|
||||||
|
|
|
@ -3,26 +3,62 @@
|
||||||
- config
|
- config
|
||||||
- iterm2
|
- iterm2
|
||||||
template:
|
template:
|
||||||
src: "{{ item }}"
|
src: "iterm2/{{ item }}"
|
||||||
dest: '~/.iterm2'
|
dest: '~/.iterm2'
|
||||||
mode: '0600'
|
mode: '0600'
|
||||||
loop: "{{ query('fileglob', 'iterm2/*') }}"
|
loop: ['com.googlecode.iterm2.plist', 'hybrid.itermcolors']
|
||||||
|
|
||||||
|
- name: 'Iterm2: Shell integration'
|
||||||
|
tags:
|
||||||
|
- config
|
||||||
|
- iterm2
|
||||||
|
copy:
|
||||||
|
src: 'iterm2/shell_integration.bash'
|
||||||
|
dest: '~/.bashrc.d'
|
||||||
|
mode: '0400'
|
||||||
|
|
||||||
|
- name: 'Shell: ps alias'
|
||||||
|
tags:
|
||||||
|
- config
|
||||||
|
- shell
|
||||||
|
copy:
|
||||||
|
content: |
|
||||||
|
[[ -x /bin/ps && -x $(which pstree 2>/dev/null) && $(uname -s) = 'Darwin' ]] && function ps() { if [[ ${1} =~ 'f' ]]; then pstree; else /bin/ps ${@}; fi }
|
||||||
|
dest: '~/.bashrc.d/alias.ps'
|
||||||
|
mode: '0400'
|
||||||
|
|
||||||
|
- name: 'Shell: GNU overrides'
|
||||||
|
tags:
|
||||||
|
- config
|
||||||
|
- shell
|
||||||
|
copy:
|
||||||
|
content: |
|
||||||
|
[[ -x $(which gdu 2>/dev/null) ]] && function du() { gdu ${@}; } && export -f du
|
||||||
|
[[ -x $(which gsort 2>/dev/null) ]] && function sort() { gsort ${@}; } && export -f sort
|
||||||
|
dest: '~/.bashrc.d/alias.gnu'
|
||||||
|
mode: '0400'
|
||||||
|
|
||||||
- name: 'Firefox: Set base path'
|
- name: 'Firefox: Set base path'
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
|
- firefox
|
||||||
|
- browser
|
||||||
set_fact:
|
set_fact:
|
||||||
firefox_path: '~/Library/Application Support/Firefox'
|
firefox_path: '~/Library/Application Support/Firefox'
|
||||||
|
|
||||||
- name: 'Firefox: Find profile path'
|
- name: 'Firefox: Find profile path'
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
|
- firefox
|
||||||
|
- browser
|
||||||
set_fact:
|
set_fact:
|
||||||
profile_path: "{{ lookup('ini', 'Path section=Profile0 file=' + firefox_path + '/profiles.ini') }}"
|
profile_path: "{{ lookup('ini', 'Path section=Profile0 file=' + firefox_path + '/profiles.ini') }}"
|
||||||
|
|
||||||
- name: 'Firefox: Add local config'
|
- name: 'Firefox: Add local config'
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
|
- firefox
|
||||||
|
- browser
|
||||||
copy:
|
copy:
|
||||||
content: |
|
content: |
|
||||||
user_pref("geo.enabled", false);
|
user_pref("geo.enabled", false);
|
||||||
|
@ -31,61 +67,53 @@
|
||||||
dest: "{{ firefox_path }}/{{ profile_path }}/user.js"
|
dest: "{{ firefox_path }}/{{ profile_path }}/user.js"
|
||||||
mode: '0600'
|
mode: '0600'
|
||||||
|
|
||||||
- name: 'OS X: Dock orientation'
|
- name: 'OS X: Preferences'
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
osx_defaults:
|
- os
|
||||||
domain: com.apple.dock
|
- osx
|
||||||
type: string
|
block:
|
||||||
key: orientation
|
- name: 'OS X: Dock orientation'
|
||||||
value: right
|
osx_defaults:
|
||||||
|
domain: com.apple.dock
|
||||||
|
type: string
|
||||||
|
key: orientation
|
||||||
|
value: right
|
||||||
|
|
||||||
- name: 'OS X: Dock size'
|
- name: 'OS X: Dock size'
|
||||||
tags:
|
osx_defaults:
|
||||||
- config
|
domain: com.apple.dock
|
||||||
osx_defaults:
|
type: float
|
||||||
domain: com.apple.dock
|
key: tilesize
|
||||||
type: float
|
value: '35'
|
||||||
key: tilesize
|
|
||||||
value: '35'
|
|
||||||
|
|
||||||
- name: 'OS X: Smart quotes off'
|
- name: 'OS X: Smart quotes off'
|
||||||
tags:
|
osx_defaults:
|
||||||
- config
|
domain: NSGlobalDomain
|
||||||
osx_defaults:
|
type: int
|
||||||
domain: NSGlobalDomain
|
key: NSAutomaticQuoteSubstitutionEnabled
|
||||||
type: int
|
value: '0'
|
||||||
key: NSAutomaticQuoteSubstitutionEnabled
|
|
||||||
value: '0'
|
|
||||||
|
|
||||||
- name: 'OS X: Smart dashes off'
|
- name: 'OS X: Smart dashes off'
|
||||||
tags:
|
osx_defaults:
|
||||||
- config
|
domain: NSGlobalDomain
|
||||||
osx_defaults:
|
type: int
|
||||||
domain: NSGlobalDomain
|
key: NSAutomaticDashSubstitutionEnabled
|
||||||
type: int
|
value: '0'
|
||||||
key: NSAutomaticDashSubstitutionEnabled
|
|
||||||
value: '0'
|
|
||||||
|
|
||||||
- name: 'OS X: Spell correction off'
|
- name: 'OS X: Spell correction off'
|
||||||
tags:
|
osx_defaults:
|
||||||
- config
|
domain: NSGlobalDomain
|
||||||
osx_defaults:
|
type: int
|
||||||
domain: NSGlobalDomain
|
key: NSAutomaticSpellingCorrectionEnabled
|
||||||
type: int
|
value: '0'
|
||||||
key: NSAutomaticSpellingCorrectionEnabled
|
|
||||||
value: '0'
|
|
||||||
|
|
||||||
- name: 'OS X: Web spell correction off'
|
- name: 'OS X: Web spell correction off'
|
||||||
tags:
|
osx_defaults:
|
||||||
- config
|
domain: NSGlobalDomain
|
||||||
osx_defaults:
|
type: int
|
||||||
domain: NSGlobalDomain
|
key: WebAutomaticSpellingCorrectionEnabled
|
||||||
type: int
|
value: '0'
|
||||||
key: WebAutomaticSpellingCorrectionEnabled
|
always:
|
||||||
value: '0'
|
- name: 'OS X: Clear preferences cache'
|
||||||
|
command: 'pkill -u ${USER} cfprefsd'
|
||||||
- name: 'OS X: Clear preferences cache'
|
|
||||||
tags:
|
|
||||||
- config
|
|
||||||
command: 'pkill -u ${USER} cfprefsd'
|
|
||||||
|
|
81
.bashrc
81
.bashrc
|
@ -64,26 +64,6 @@ pathadd /usr/local/bin
|
||||||
pathadd ~/bin
|
pathadd ~/bin
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Set some variables
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Add the Homebrew API token, if appropriate
|
|
||||||
if [ -x "$(which brew 2>/dev/null)" ]; then
|
|
||||||
export HOMEBREW_GITHUB_API_TOKEN=$(getkey HOMEBREW_GITHUB_API_TOKEN)
|
|
||||||
fi
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Add bash completion scripts (deferred until the end and backgrounded)
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
function _deferred {
|
|
||||||
# Bash completion with Homebrew
|
|
||||||
if [ -f $(brew --prefix 2>/dev/null)/etc/bash_completion ]; then
|
|
||||||
. $(brew --prefix 2>/dev/null)/etc/bash_completion
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
# A useful prompt
|
# A useful prompt
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
@ -97,23 +77,6 @@ export PROMPT_COMMAND="${PROMPT_COMMAND:+"${PROMPT_COMMAND%%';__PROMPT_COMMAND'}
|
||||||
export PROMPT_COMMAND="${PROMPT_COMMAND//;;/;}"
|
export PROMPT_COMMAND="${PROMPT_COMMAND//;;/;}"
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Record history for longer and more dynamically
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Unlimited history buffer
|
|
||||||
export HISTSIZE=
|
|
||||||
export HISTFILESIZE=
|
|
||||||
|
|
||||||
# Avoid duplicates in the history...
|
|
||||||
export HISTCONTROL=ignoreboth
|
|
||||||
|
|
||||||
# Record the timestamp in the bash history
|
|
||||||
export HISTTIMEFORMAT="%Y-%m-%d %T "
|
|
||||||
|
|
||||||
# Append history entries...
|
|
||||||
shopt -s histappend
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
# Command alias functions
|
# Command alias functions
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
@ -122,51 +85,13 @@ function space() { du -ahx --max-depth=1 | sort -h; } && export -f space
|
||||||
if ! alias ll >/dev/null 2>&1; then function ll() { ls -l ${@}; } && export -f ll; fi
|
if ! alias ll >/dev/null 2>&1; then function ll() { ls -l ${@}; } && export -f ll; fi
|
||||||
[[ ! -x $(which psgrep 2>/dev/null) ]] && function psgrep() { ps -ef | grep ${@} | grep -v ${$}; } && export -f psgrep
|
[[ ! -x $(which psgrep 2>/dev/null) ]] && function psgrep() { ps -ef | grep ${@} | grep -v ${$}; } && export -f psgrep
|
||||||
[[ -x $(which glances 2>/dev/null) ]] && function top() { glances; } && export -f top
|
[[ -x $(which glances 2>/dev/null) ]] && function top() { glances; } && export -f top
|
||||||
[[ -x $(which gdu 2>/dev/null) ]] && function du() { gdu ${@}; } && export -f du
|
|
||||||
[[ -x $(which gsort 2>/dev/null) ]] && function sort() { gsort ${@}; } && export -f sort
|
|
||||||
[[ -x /bin/ps && -x $(which pstree 2>/dev/null) && $(uname -s) = 'Darwin' ]] && function ps() { if [[ ${1} =~ 'f' ]]; then pstree; else /bin/ps ${@}; fi }
|
|
||||||
[[ -x $(which tree 2>/dev/null) ]] && alias tree="tree -AQh --du"
|
[[ -x $(which tree 2>/dev/null) ]] && alias tree="tree -AQh --du"
|
||||||
|
|
||||||
export GIT_SSH_COMMAND="$(which ssh) -o RemoteCommand=none"
|
export GIT_SSH_COMMAND="$(which ssh) -o RemoteCommand=none"
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
# Set up GOPATH for Go development
|
# Include deployed bash config
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
export GOPATH=${HOME}
|
source ~/.bashrc.d/* 2>/dev/null
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Run an SSH agent, if possible
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Check if we already have an agent running and sourced
|
|
||||||
if [ -z "${SSH_AUTH_SOCK}" ]; then
|
|
||||||
SSH_AUTH_SOCK_FILE=~/.ssh/auth_sock
|
|
||||||
if [ -S ${SSH_AUTH_SOCK_FILE} ]; then
|
|
||||||
export SSH_AUTH_SOCK=${SSH_AUTH_SOCK_FILE}
|
|
||||||
export SSH_AGENT_PID=$(cat ~/.ssh/agent.pid)
|
|
||||||
else
|
|
||||||
eval `ssh-agent -a ${SSH_AUTH_SOCK_FILE} -s`
|
|
||||||
echo ${SSH_AGENT_PID} > ~/.ssh/agent.pid
|
|
||||||
ssh-add
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# iTerm2 shell integration
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
[ -f ~/.iterm2/shell_integration.bash ] && source ~/.iterm2/shell_integration.bash
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Run local .bashrc for any local-only commands
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
[ -f ~/.bashrc_local ] && source ~/.bashrc_local
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
# Kick off the _deferred() function and background it (speeding up Bash loading)
|
|
||||||
#--------------------------------------------------------------------------------
|
|
||||||
trap '_deferred 2>/dev/null; trap USR1' USR1
|
|
||||||
{ sleep 0.1 ; builtin kill -USR1 $$ ; } & disown
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
5
.bashrc.d/go
Normal file
5
.bashrc.d/go
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
# Set up GOPATH for Go development
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
export GOPATH=${HOME}
|
||||||
|
#--------------------------------------------------------------------------------
|
16
.bashrc.d/history
Normal file
16
.bashrc.d/history
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
# Record history for longer and more dynamically
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
# Unlimited history buffer
|
||||||
|
export HISTSIZE=
|
||||||
|
export HISTFILESIZE=
|
||||||
|
|
||||||
|
# Avoid duplicates in the history...
|
||||||
|
export HISTCONTROL=ignoreboth
|
||||||
|
|
||||||
|
# Record the timestamp in the bash history
|
||||||
|
export HISTTIMEFORMAT="%Y-%m-%d %T "
|
||||||
|
|
||||||
|
# Append history entries...
|
||||||
|
shopt -s histappend
|
||||||
|
#--------------------------------------------------------------------------------
|
16
.bashrc.d/ssh-agent
Normal file
16
.bashrc.d/ssh-agent
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
# Run an SSH agent, if possible
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
# Check if we already have an agent running and sourced
|
||||||
|
if [ -z "${SSH_AUTH_SOCK}" ]; then
|
||||||
|
SSH_AUTH_SOCK_FILE=~/.ssh/auth_sock
|
||||||
|
if [ -S ${SSH_AUTH_SOCK_FILE} ]; then
|
||||||
|
export SSH_AUTH_SOCK=${SSH_AUTH_SOCK_FILE}
|
||||||
|
export SSH_AGENT_PID=$(cat ~/.ssh/agent.pid)
|
||||||
|
else
|
||||||
|
eval `ssh-agent -a ${SSH_AUTH_SOCK_FILE} -s`
|
||||||
|
echo ${SSH_AGENT_PID} > ~/.ssh/agent.pid
|
||||||
|
ssh-add
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#--------------------------------------------------------------------------------
|
|
@ -1,4 +0,0 @@
|
||||||
# Launch/restore screen
|
|
||||||
if [ -x $(which screen 2>/dev/null) ]; then
|
|
||||||
if [ -z "$STY" ]; then exec screen -xRR; fi
|
|
||||||
fi
|
|
Loading…
Reference in a new issue