Skip to content

Commit 08d8715

Browse files
Collated ansible and dotfile setup into one project with symlinks
0 parents  commit 08d8715

14 files changed

+308
-0
lines changed

hosts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mac]
2+
localhost ansible_connection=local

playbook.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
- hosts: mac
4+
vars_files:
5+
- roles/vars/main.yml
6+
roles:
7+
- setup

roles/setup/files/.gitignore_global

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# IntelliJ
2+
.idea/
3+
*.iml
4+
5+
# VSCode
6+
.vscode/
7+
8+
# Java
9+
target/
10+
11+
# MacOS
12+
.DS_Store
13+
14+
# Python
15+
*.ipynb
16+
__pycache__/
17+
.ipynb_checkpoints/
18+
venv/
19+
*.pyc

roles/setup/files/.vimrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
" turn on hybrid line numbers
2+
:set number relativenumber
3+
:set nu rnu
4+
5+
let g:is_posix=1 " fix to posix for better syntax highlighting
6+
7+
" tabs vs spaces
8+
set tabstop=4
9+
set softtabstop=4
10+
set expandtab " tabs are spaces
11+
12+
" theming
13+
colorscheme gruvbox
14+
let g:lightline = {'colorscheme': 'jellybeans',}
15+
set noshowmode " lightline shows the mode in the status bar
16+
17+
" generate help files for plugins
18+
packloadall
19+
silent! helptags ALL

roles/setup/files/.zsh_aliases

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# git aliases
2+
alias gcano='git commit -a --amend --no-edit'
3+
alias gcam='git commit -a -m'
4+
alias gfu='git commit --all --amend --no-edit && git push --force-with-lease'
5+
alias gcb='git checkout -b'
6+
alias gcom='git checkout master'
7+
alias gpu='git push -u'
8+
alias grh='git reset --hard'
9+
alias grom='git rebase origin/master'
10+
alias gst='git status'
11+
12+
# selectively taken from OMZ's common aliases
13+
alias zshrc='${=EDITOR} ~/.zshrc'
14+
alias la='ls -FaG'
15+
alias ll='ls -FlhG'
16+
17+
# Make zsh know about hosts already accessed by SSH
18+
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
19+
20+
alias ..='cd ..'
21+
alias ...='cd ../..'
22+
alias ....='cd ../../..'
23+
alias cat=bat
24+
alias config='/usr/bin/git --git-dir=/Users/samjoseph/.cfg/ --work-tree=/Users/samjoseph'
25+
alias mkdir='mkdir -p'
26+
alias myip='curl ipecho.net/plain ; echo'
27+
alias ping='prettyping --nolegend'
28+
alias run-help=man
29+
alias which-command=whence

roles/setup/files/.zshrc

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
source $HOME/.zsh_plugins
2+
source $HOME/.zsh_aliases
3+
4+
# load zsh completions
5+
autoload -U compinit && compinit
6+
7+
# dotfile management
8+
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
9+
10+
# history configuration
11+
HISTSIZE=5000
12+
HISTFILE=$HOME/.zsh_history
13+
SAVEHIST=5000
14+
setopt APPEND_HISTORY SHARE_HISTORY INC_APPEND_HISTORY HIST_FIND_NO_DUPS
15+
16+
# set dirs history and navigation
17+
setopt AUTO_CD PUSHD_IGNORE_DUPS
18+
zstyle :plugin:history-search-multi-word reset-prompt-protect 1
19+
20+
# terminal/editor configuration
21+
export VISUAL=vim
22+
export EDITOR="$VISUAL"
23+
bindkey "[3~" delete-char
24+
bindkey "^R" history-search-multi-word
25+
set -o vi
26+
bindkey -v
27+
28+
# Spaceship prompt configuration
29+
SPACESHIP_TIME_SHOW=true
30+
SPACESHIP_PROMPT_ORDER=(
31+
time user dir host git
32+
package node xcode golang rust docker aws venv pyenv kubecontext terraform
33+
exec_time line_sep
34+
jobs exit_code char
35+
)
36+
SPACESHIP_RPROMPT_ORDER=(vi_mode)
37+
spaceship_vi_mode_enable
38+
SPACESHIP_VI_MODE_SHOW=true
39+
SPACESHIP_VI_MODE_NORMAL=Vim
40+
SPACESHIP_VI_MODE_INSERT=
41+
42+
# navi shell widget
43+
source "$(navi widget zsh)"
44+
45+
eval $(thefuck --alias)
46+
47+
# TODO:
48+
# - missing a ton of aliases
49+
50+
###################
51+
# Application-specific config. Move to new file?
52+
###################
53+
54+
# tabtab source for serverless package
55+
# uninstall by removing these lines or running `tabtab uninstall serverless`
56+
[[ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.zsh ]] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.zsh
57+
# tabtab source for sls package
58+
# uninstall by removing these lines or running `tabtab uninstall sls`
59+
[[ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.zsh ]] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.zsh
60+
# tabtab source for slss package
61+
# uninstall by removing these lines or running `tabtab uninstall slss`
62+
[[ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/slss.zsh ]] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/slss.zsh
63+
64+
export NVM_DIR="$HOME/.nvm"
65+
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
66+
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" # This loads nvm bash_completion

roles/setup/files/vim-plug-man.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# Stolen with love and gratitude from: https://stories.abletech.nz/get-rid-of-your-vim-plugin-manager-7c8ff742f643
3+
4+
function set_group () {
5+
package_group=$1
6+
path="$HOME/.vim/pack/$package_group/start"
7+
mkdir -p "$path"
8+
cd "$path" || exit
9+
}
10+
11+
function package () {
12+
repo_url=$1
13+
expected_repo=$(basename "$repo_url" .git)
14+
if [ -d "$expected_repo" ]; then
15+
cd "$expected_repo" || exit
16+
result=$(git pull --force --depth=1)
17+
echo "$expected_repo: $result"
18+
else
19+
echo "$expected_repo: Installing..."
20+
git clone -q "$repo_url" --depth=1
21+
fi
22+
}
23+
24+
(
25+
set_group general
26+
package https://github.com/tpope/vim-sensible &
27+
package https://github.com/itchyny/lightline.vim &
28+
package https://github.com/mhinz/vim-signify &
29+
wait
30+
) &
31+
32+
(
33+
set_group syntax
34+
package https://github.com/dense-analysis/ale &
35+
wait
36+
) &
37+
38+
(
39+
set_group colorschemes
40+
package https://github.com/morhetz/gruvbox &
41+
wait
42+
) &
43+
wait

roles/setup/files/zsh_plugins.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cal2195/q
2+
djui/alias-tips
3+
Tarrasch/zsh-bd
4+
tysonwolker/iterm-tab-colors
5+
6+
zsh-users/zsh-autosuggestions
7+
zsh-users/zsh-completions
8+
9+
robbyrussell/oh-my-zsh path:plugins/thefuck
10+
11+
zdharma/history-search-multi-word
12+
zsh-users/zsh-syntax-highlighting
13+
14+
denysdovhan/spaceship-prompt
15+

roles/setup/tasks/homebrew.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
# install and update homebrew and cask
3+
4+
- name: ensure homebrew is installed
5+
stat:
6+
path: "/usr/local/bin/brew"
7+
register: "homebrew_check"
8+
9+
- name: install homebrew
10+
when: not homebrew_check.stat.exists
11+
shell: 'yes | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'
12+
args:
13+
creates: /usr/local/bin/brew
14+
15+
- name: ensure homebrew is updated
16+
homebrew:
17+
state: latest
18+
update_homebrew: yes
19+
upgrade_all: yes
20+
21+
-name: install homebrew packages
22+
homebrew:
23+
name: "{{ homebrew.packages }}"
24+
state: present
25+
26+
- name: tap casks
27+
homebrew_tap:
28+
tap: "{{ homebrew.casks }}"
29+
state: present
30+
31+
- name: install cask applications
32+
homebrew_cask:
33+
name: "{{ homebrew.applications }}"
34+
state: present

roles/setup/tasks/main.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
- name: configure zsh
2+
import_tasks: zsh.yml
3+
4+
- name: homebrew and application installs
5+
import_tasks: homebrew.yml
6+
7+
- name: configure vim and install plugins
8+
import_tasks: vim.yml
9+
10+
- name: miscellaneous configuration
11+
import_tasks: misc.yml
12+
13+
# - name: osx defaults
14+
# import_tasks: osx.yml

roles/setup/tasks/misc.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# miscellaneous configuration
3+
4+
- name: link git dotfiles
5+
file:
6+
src: .gitignore_global
7+
dest: ~/.gitignore_global
8+
state: link

roles/setup/tasks/vim.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: link vimrc
3+
file:
4+
- src: .vimrc
5+
- dest: ~/.vimrc
6+
- state: link
7+
8+
# install/update vim plugins using custom script and Vim's native plugin management
9+
- name: run vim plugin script
10+
script: vim-plug-man.sh

roles/setup/tasks/zsh.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- name: link dotfiles
3+
file:
4+
- src: {{ item }}
5+
- dest: ~/{{ item }}
6+
- state: link
7+
loop:
8+
- .zshrc
9+
- .zsh_aliases
10+
11+
# antibody static loading: https://getantibody.github.io/usage/
12+
- name: static loading from plugins.txt
13+
command: antibody bundle < zsh_plugins.txt > ~/.zsh_plugins
14+
15+
- name: Change login shell
16+
command: chsh -s /usr/local/bin/zsh

roles/setup/vars/main.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
3+
homebrew:
4+
packages:
5+
- ansible
6+
- antibody
7+
- bat
8+
- git
9+
- httpie
10+
- jq
11+
- denisidoro/tools/navi
12+
- node
13+
- nvm
14+
- prettyping
15+
- python
16+
- thefuck
17+
- tldr
18+
- tree
19+
- yarn
20+
- zsh
21+
casks:
22+
- caskroom/cask
23+
- homebrew/cask-fonts
24+
applications:
25+
- font-fira-code
26+
# cask applications

0 commit comments

Comments
 (0)