Skip to content

Commit

Permalink
Happy New Years Patch.
Browse files Browse the repository at this point in the history
* fasd role
* role antibody-zsh -> zsh-antibody
* Thinned out homebrew cask
* bash and zsh powerline locked into ap- versions
* etchosts role installs .raw-ads.hosts instead of .merge.hosts
* ask-sudo -> ask-become-pass flag in bootstrap
  • Loading branch information
adrw committed Jan 3, 2018
1 parent 0876cb2 commit 85843e2
Show file tree
Hide file tree
Showing 31 changed files with 343 additions and 97 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_store
*.retry
.*.hosts*
.bash-powerline.*
.zsh-powerline.*
3 changes: 1 addition & 2 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[defaults]

hostfile = ./inventories
roles_path = ./roles
roles_path = ./roles
3 changes: 2 additions & 1 deletion ansible/plays/provision.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- include: provision/mac_core.yml
- include: provision/mac_dev.yml
- include: provision/mac_secure_no_animate.yml
- include: provision/mac_etchost_no_animate.yml
- include: provision/mac_jekyll.yml
58 changes: 29 additions & 29 deletions ansible/plays/provision/mac_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
- etchosts
# - oh-my-zsh
- homebrew
- antibody-zsh
- bash
- zsh
- zsh-antibody
- fasd
- aliases
- functions
- git
Expand Down Expand Up @@ -51,12 +52,13 @@
- antibody
- cheat
- dockutil
# - gnupg2 # requires java...
# - fasd # separate role
# - gnupg2 # requires java...
- htop
- mas
# - mas
- node
- openssl
- privoxy
# - privoxy # separate role
- python
- python3
- syncthing
Expand All @@ -66,53 +68,51 @@
- yarn
homebrew_cask_apps:
- 1password
- adobe-digital-editions
# - adobe-digital-editions
- alfred
- anaconda # python ML libraries
# - anaconda # python ML libraries
- appcleaner
- atom
- autodmg
# - autodmg
- backblaze
- backblaze-downloader
# - backblaze-downloader
- bartender
- calibre
- createuserpkg
- coda
- dash
# - createuserpkg
# - coda
# - dash
- docker
- dropbox
- eloston-chromium
- firefox
# - flux
- gmvault
# - eloston-chromium
# - firefox
# - gmvault
- google-chrome
- google-chrome-canary
- gpgtools-beta
- handbrake
- handbrakebatch
# - google-chrome-canary
# - gpgtools-beta
# - handbrake
# - handbrakebatch
- imagealpha
- insomnia
- ipartition
# - ipartition
- iterm2
- keybase
- kdiff3
# - kdiff3
- ngrok
- notational-velocity
- microsoft-office
- microsoft-office # requires password
- musicbrainz-picard
- onedrive
- onedrive # requires password
- pomello
- quitter
- sqlpro-for-sqlite
- skype
# - sqlpro-for-sqlite
# - skype
- slack
- spectacle
- sublime-text
- switch
- synology-assistant
# - sublime-text
# - synology-assistant
- the-unarchiver
- torbrowser
- transmission
- virtualbox # requires password
- viscosity
- vlc
- whatsapp
Expand Down
12 changes: 5 additions & 7 deletions ansible/plays/provision/mac_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
- etchosts
# - oh-my-zsh
- homebrew
- antibody-zsh
- bash
- zsh
- zsh-antibody
- fasd
- aliases
- functions
- git
Expand Down Expand Up @@ -53,7 +54,7 @@
- dockutil
# - gnupg2 # requires java...
- htop
- mas
# - mas
- node
- openssl
- privoxy
Expand All @@ -68,7 +69,7 @@
- 1password
# - adobe-digital-editions
- alfred
- anaconda # python ML libraries
# - anaconda # python ML libraries
- appcleaner
- atom
# - autodmg
Expand All @@ -83,7 +84,6 @@
- dropbox
- eloston-chromium
- firefox
# - flux
- gmvault
- google-chrome
- google-chrome-canary
Expand All @@ -97,18 +97,16 @@
- keybase
# - kdiff3
- ngrok
# - notational-velocity
- microsoft-office
# - musicbrainz-picard
- onedrive
- pomello
- quitter
- sqlpro-for-sqlite
# - sqlpro-for-sqlite
# - skype
- slack
- spectacle
- sublime-text
# - switch
# - synology-assistant
- the-unarchiver
- torbrowser
Expand Down
66 changes: 34 additions & 32 deletions ansible/roles/aliases/files/.ap-aliases
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,33 @@ alias st="syncthing"
#Jupyter
alias jn="jupyter notebook"

# Directory Shortcuts
alias .f="cd ~/.files"
alias dx="cd ~/Dropbox"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias sr="cd ~/src"
alias sra="cd ~/src/ape"
alias srg="cd ~/src/github.com"
alias sri="cd ~/src/interviews"
alias srj="cd ~/src/jupyter"
alias sru="cd ~/src/uw"
alias ap="cd ~/src/github.com/andrewparadi.github.io"
alias qa="cd ~/src/github.com/Quantular-API"
alias qw="cd ~/src/github.com/Quantular-Web-Client"
#Git
alias gs="git status"
alias ga="git add"
alias gc="git commit"
alias grau="git remote add upstream"
alias gra="git remote add"
alias gl="git log --oneline"
alias gr="git rebase -i"

# UW SSH
alias uwssh="ssh -4 -i ~/.ssh/id_rsa -Y [email protected]"
alias uwssh1404="ssh -4 -i ~/.ssh/id_rsa -Y [email protected]"
alias uwssh1604="ssh -4 -i ~/.ssh/id_rsa -Y [email protected]"
alias uwssh458="ssh [email protected]"
alias uw458scp="scp -r [email protected]:uml/share/* ./"
alias uwscp458="scp -r ./ [email protected]:uml/share/"
# Docker
alias dc="docker-compose"
alias dka="docker kill $(docker ps -q)"
alias dvp="docker volume prune"
alias drmc="docker rm $(docker ps -a -q)"
alias drmi="docker rmi -f $(docker images -q)"

# fasd
alias fa='fasd -a' # any
alias s='fasd -si' # show / search / select
alias d='fasd -d' # directory
alias f='fasd -f' # file
alias sd='fasd -sid' # interactive directory selection
alias sf='fasd -sif' # interactive file selection
alias z='fasd_cd -d' # cd, same functionality as j in autojump
alias zz='fasd_cd -d -i' # cd with interactive selection
alias jj='fasd_cd -i'
alias j='fasd_cd -i -1'

# UW Directories
case "$(uname)" in
Expand All @@ -53,21 +58,18 @@ case "$(uname)" in
*) ;;
esac
alias uw="cd ~/docs/UW/4b"
alias 456="cd ${uwsrc}/cs456${uwpost}"
alias 458="cd ${uwsrc}/cs458${uwpost}"
alias 349="cd ${uwsrc}/cs349${uwpost}"
alias 451="cd ${uwsrc}/cs451${uwpost}"
alias 454="cd ${uwsrc}/cs454${uwpost}"
alias 487="cd ${uwsrc}/co487${uwpost}"
alias 492="cd ${uwsrc}/cs492${uwpost}"

#Git
alias gs="git status"
alias ga="git add"
alias gc="git commit"
alias grau="git remote add upstream"
alias gra="git remote add"
alias gl="git log --oneline"
alias gr="git rebase -i"
# UW SSH
alias uwssh="ssh -4 -i ~/.ssh/id_rsa -Y [email protected]"
alias uwssh1404="ssh -4 -i ~/.ssh/id_rsa -Y [email protected]"
alias uwssh1604="ssh -4 -i ~/.ssh/id_rsa -Y [email protected]"
alias uwssh458="ssh [email protected]"
alias uw458scp="scp -r [email protected]:uml/share/* ./"
alias uwscp458="scp -r ./ [email protected]:uml/share/"

#Web Download files off of a webpage
# - Every file: wd "" {url}
Expand Down
3 changes: 2 additions & 1 deletion ansible/roles/bash/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

bash_powerline_div: "### Theme"
bash_powerline_source: 'source {{home}}/.bash-powerline.sh'
bash_powerline_source: 'source {{home}}/.ap-bash-powerline.sh'
bash_powerline_url: https://raw.githubusercontent.com/riobard/bash-powerline/master/bash-powerline.sh
bash_powerline_file: .bash-powerline.sh
bash_powerline_ap_file: .ap-bash-powerline.sh
92 changes: 92 additions & 0 deletions ansible/roles/bash/files/.ap-bash-powerline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env bash

## Uncomment to disable git info
#POWERLINE_GIT=0

__powerline() {
# Colorscheme
readonly RESET='\[\033[m\]'
readonly COLOR_CWD='\[\033[0;34m\]' # blue
readonly COLOR_GIT='\[\033[0;36m\]' # cyan
readonly COLOR_SUCCESS='\[\033[0;32m\]' # green
readonly COLOR_FAILURE='\[\033[0;31m\]' # red

readonly SYMBOL_GIT_BRANCH=''
readonly SYMBOL_GIT_MODIFIED='*'
readonly SYMBOL_GIT_PUSH=''
readonly SYMBOL_GIT_PULL=''

if [[ -z "$PS_SYMBOL" ]]; then
case "$(uname)" in
Darwin) PS_SYMBOL='';;
Linux) PS_SYMBOL='$';;
*) PS_SYMBOL='%';;
esac
fi

__git_info() {
[[ $POWERLINE_GIT = 0 ]] && return # disabled
hash git 2>/dev/null || return # git not found
local git_eng="env LANG=C git" # force git output in English to make our work easier

# get current branch name
local ref=$($git_eng symbolic-ref --short HEAD 2>/dev/null)

if [[ -n "$ref" ]]; then
# prepend branch symbol
ref=$SYMBOL_GIT_BRANCH$ref
else
# get tag name or short unique hash
ref=$($git_eng describe --tags --always 2>/dev/null)
fi

[[ -n "$ref" ]] || return # not a git repo

local marks

# scan first two lines of output from `git status`
while IFS= read -r line; do
if [[ $line =~ ^## ]]; then # header line
[[ $line =~ ahead\ ([0-9]+) ]] && marks+=" $SYMBOL_GIT_PUSH${BASH_REMATCH[1]}"
[[ $line =~ behind\ ([0-9]+) ]] && marks+=" $SYMBOL_GIT_PULL${BASH_REMATCH[1]}"
else # branch is modified if output contains more lines after the header line
marks="$SYMBOL_GIT_MODIFIED$marks"
break
fi
done < <($git_eng status --porcelain --branch 2>/dev/null) # note the space between the two <

# print the git branch segment without a trailing newline
printf " $ref$marks"
}

ps1() {
# Check the exit code of the previous command and display different
# colors in the prompt accordingly.
if [ $? -eq 0 ]; then
local symbol="$COLOR_SUCCESS $PS_SYMBOL $RESET"
else
local symbol="$COLOR_FAILURE $PS_SYMBOL $RESET"
fi

local cwd="$COLOR_CWD\w$RESET"
# Bash by default expands the content of PS1 unless promptvars is disabled.
# We must use another layer of reference to prevent expanding any user
# provided strings, which would cause security issues.
# POC: https://github.com/njhartwell/pw3nage
# Related fix in git-bash: https://github.com/git/git/blob/9d77b0405ce6b471cb5ce3a904368fc25e55643d/contrib/completion/git-prompt.sh#L324
if shopt -q promptvars; then
__powerline_git_info="$(__git_info)"
local git="$COLOR_GIT\${__powerline_git_info}$RESET"
else
# promptvars is disabled. Avoid creating unnecessary env var.
local git="$COLOR_GIT$(__git_info)$RESET"
fi

PS1="$cwd$git$symbol"
}

PROMPT_COMMAND="ps1${PROMPT_COMMAND:+; $PROMPT_COMMAND}"
}

__powerline
unset __powerline
4 changes: 2 additions & 2 deletions ansible/roles/bash/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
become: false

- file:
src: "{{ roles_dir }}/bash/files/{{ bash_powerline_file }}"
dest: "{{ home }}/{{ bash_powerline_file }}"
src: "{{ roles_dir }}/bash/files/{{ bash_powerline_ap_file }}"
dest: "{{ home }}/{{ bash_powerline_ap_file }}"
state: link
owner: "{{ user_name }}"
group: "{{ user_group }}"
Expand Down
Loading

0 comments on commit 85843e2

Please sign in to comment.