refactor: combine with Ubuntu Provisioning repo
Combine with this repository with https://github.com/opdavies/ubuntu-provisioning so that everything can be managed in one place, and add a role for each piece of software.
This commit is contained in:
parent
e11cf61218
commit
8916e90050
73 changed files with 239 additions and 3783 deletions
3
roles/zsh/files/.zsh/completion-scripts/_g
Normal file
3
roles/zsh/files/.zsh/completion-scripts/_g
Normal file
|
@ -0,0 +1,3 @@
|
|||
#compdef g
|
||||
compdef g=git
|
||||
|
2
roles/zsh/files/.zsh/completion-scripts/_m
Normal file
2
roles/zsh/files/.zsh/completion-scripts/_m
Normal file
|
@ -0,0 +1,2 @@
|
|||
#compdef m
|
||||
compdef m=make
|
32
roles/zsh/files/.zsh/configs/aliases.zsh
Normal file
32
roles/zsh/files/.zsh/configs/aliases.zsh
Normal file
|
@ -0,0 +1,32 @@
|
|||
alias c="clear"
|
||||
alias l="ls -lah"
|
||||
|
||||
# Open the current directory in Finder.
|
||||
alias o="open ."
|
||||
|
||||
alias hosts="sudo vim /etc/hosts"
|
||||
alias sshconfig='vim ~/.ssh/config'
|
||||
|
||||
# Pretty print the path.
|
||||
alias path='echo $PATH | tr -s ":" "\n"'
|
||||
|
||||
# Open the current directory in PhpStorm.
|
||||
# Open the current directory in Sublime Text.
|
||||
alias sublime='open -a /Applications/Sublime\ Text.app "`pwd`"'
|
||||
|
||||
# Allow for pasting lines of code that start with a dollar sign.
|
||||
alias \$=''
|
||||
|
||||
# Re-implement pbcopy and pbpaste from macOS.
|
||||
alias pbcopy="xclip -selection clipboard"
|
||||
alias pbpaste="xclip -selection clipboard -o"
|
||||
|
||||
# Include custom aliases
|
||||
if [[ -f ~/.aliases.local ]]; then
|
||||
source ~/.aliases.local
|
||||
fi
|
||||
|
||||
# Open directory aliases
|
||||
if [[ -f $(pwd)/.aliases ]]; then
|
||||
source $(pwd)/.aliases
|
||||
fi
|
4
roles/zsh/files/.zsh/configs/colour.zsh
Normal file
4
roles/zsh/files/.zsh/configs/colour.zsh
Normal file
|
@ -0,0 +1,4 @@
|
|||
autoload -U colors
|
||||
colors
|
||||
|
||||
export CLICOLOR=1
|
38
roles/zsh/files/.zsh/configs/functions.zsh
Normal file
38
roles/zsh/files/.zsh/configs/functions.zsh
Normal file
|
@ -0,0 +1,38 @@
|
|||
function m() {
|
||||
if [[ -f .notes/Makefile ]];
|
||||
then
|
||||
make -f .notes/Makefile "$@"
|
||||
else
|
||||
make "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function mkd() {
|
||||
mkdir -p "$@" && cd "$@"
|
||||
}
|
||||
|
||||
function composer() {
|
||||
docker run -u $UID -it --rm \
|
||||
-v $(pwd):/app \
|
||||
-v ~/.composer:/root/.composer \
|
||||
-v ~/.ssh:/root/.ssh \
|
||||
composer \
|
||||
composer $*
|
||||
}
|
||||
|
||||
# Run 'phpunit' or 'pest' depending on the project.
|
||||
function p () {
|
||||
vendor/bin/$(phpunit-or-pest) $*;
|
||||
}
|
||||
function pf () {
|
||||
vendor/bin/$(phpunit-or-pest) --filter $*
|
||||
}
|
||||
|
||||
nv() {
|
||||
if [[ $# > 0 ]];
|
||||
then
|
||||
nvim $@
|
||||
else
|
||||
nvim .
|
||||
fi
|
||||
}
|
2
roles/zsh/files/.zsh/configs/fzf.zsh
Normal file
2
roles/zsh/files/.zsh/configs/fzf.zsh
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Include keybindings for fzf.
|
||||
. /usr/share/doc/fzf/examples/key-bindings.zsh
|
5
roles/zsh/files/.zsh/configs/general.zsh
Normal file
5
roles/zsh/files/.zsh/configs/general.zsh
Normal file
|
@ -0,0 +1,5 @@
|
|||
precmd() {
|
||||
# Add a blank line before each command.
|
||||
print ''
|
||||
}
|
||||
|
10
roles/zsh/files/.zsh/configs/git.zsh
Normal file
10
roles/zsh/files/.zsh/configs/git.zsh
Normal file
|
@ -0,0 +1,10 @@
|
|||
# No arguments: `git status`
|
||||
# With arguments: acts like `git`
|
||||
g() {
|
||||
if [[ $# > 0 ]];
|
||||
then
|
||||
git $@
|
||||
else
|
||||
git status --short --branch
|
||||
fi
|
||||
}
|
7
roles/zsh/files/.zsh/configs/history.zsh
Normal file
7
roles/zsh/files/.zsh/configs/history.zsh
Normal file
|
@ -0,0 +1,7 @@
|
|||
setopt histignoredups
|
||||
|
||||
setopt inc_append_history
|
||||
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
HISTFILE=~/.cache/zsh/history
|
9
roles/zsh/files/.zsh/configs/navigation.zsh
Normal file
9
roles/zsh/files/.zsh/configs/navigation.zsh
Normal file
|
@ -0,0 +1,9 @@
|
|||
bindkey -s "^f" "tmux-sessioniser\n"
|
||||
|
||||
# Search through history with the up and down arrows.
|
||||
autoload -U up-line-or-beginning-search
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search # Up
|
||||
bindkey "${terminfo[kcud1]}" up-line-or-beginning-search # Down
|
2
roles/zsh/files/.zsh/configs/nvm.zsh
Normal file
2
roles/zsh/files/.zsh/configs/nvm.zsh
Normal file
|
@ -0,0 +1,2 @@
|
|||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
3
roles/zsh/files/.zsh/configs/options.zsh
Normal file
3
roles/zsh/files/.zsh/configs/options.zsh
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Fix "zsh: no matches found: HEAD^" error.
|
||||
# See https://github.com/opdavies/dotfiles/issues/14.
|
||||
setopt NO_NOMATCH
|
20
roles/zsh/files/.zsh/configs/path.zsh
Normal file
20
roles/zsh/files/.zsh/configs/path.zsh
Normal file
|
@ -0,0 +1,20 @@
|
|||
setopt auto_cd
|
||||
|
||||
export PATH=\
|
||||
$PATH:\
|
||||
/usr/bin:\
|
||||
$HOME/.composer/vendor/bin:\
|
||||
$HOME/.local/bin:\
|
||||
$HOME/.platformsh/bin:\
|
||||
$HOME/bin:\
|
||||
$HOME/snap/bin:\
|
||||
bin:\
|
||||
node_modules/.bin:\
|
||||
vendor/bin
|
||||
|
||||
export CDPATH=\
|
||||
./:\
|
||||
$HOME/Code:\
|
||||
$HOME/Code/clients:\
|
||||
$HOME/Code/os:\
|
||||
$HOME
|
6
roles/zsh/files/.zsh/configs/platformsh.zsh
Normal file
6
roles/zsh/files/.zsh/configs/platformsh.zsh
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Platform.sh CLI configuration.
|
||||
export PATH="$HOME/"'.platformsh/bin':"$PATH"
|
||||
|
||||
if [ -f "$HOME/"'.platformsh/shell-config.rc' ]; then
|
||||
. "$HOME/"'.platformsh/shell-config.rc';
|
||||
fi
|
10
roles/zsh/files/.zsh/configs/plugins.zsh
Normal file
10
roles/zsh/files/.zsh/configs/plugins.zsh
Normal file
|
@ -0,0 +1,10 @@
|
|||
# antigen.zsh has been downloaded manually for now,
|
||||
# see https://github.com/zsh-users/antigen/issues/659.
|
||||
source $HOME/.antigen.zsh
|
||||
|
||||
antigen bundle mollifier/cd-gitroot
|
||||
antigen bundle zsh-users/zsh-autosuggestions
|
||||
antigen bundle zsh-users/zsh-completions
|
||||
antigen bundle zsh-users/zsh-syntax-highlighting
|
||||
|
||||
antigen apply
|
BIN
roles/zsh/files/.zsh/configs/plugins.zsh.zwc
Normal file
BIN
roles/zsh/files/.zsh/configs/plugins.zsh.zwc
Normal file
Binary file not shown.
18
roles/zsh/files/.zsh/configs/post/completion.zsh
Normal file
18
roles/zsh/files/.zsh/configs/post/completion.zsh
Normal file
|
@ -0,0 +1,18 @@
|
|||
# load our own completion functions
|
||||
fpath=(~/.zsh/completion-scripts /usr/local/share/zsh/site-functions $fpath)
|
||||
|
||||
# completion; use cache if updated within 24h
|
||||
autoload -Uz compinit
|
||||
if [[ -n $HOME/.zcompdump(#qN.mh+24) ]]; then
|
||||
compinit -d $HOME/.zcompdump;
|
||||
else
|
||||
compinit -C;
|
||||
fi;
|
||||
|
||||
# disable zsh bundled function mtools command mcd
|
||||
# which causes a conflict.
|
||||
compdef -d mcd
|
||||
|
||||
## case-insensitive (all), partial-word and then substring completion
|
||||
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' \
|
||||
'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
45
roles/zsh/files/.zsh/configs/prompt.zsh
Normal file
45
roles/zsh/files/.zsh/configs/prompt.zsh
Normal file
|
@ -0,0 +1,45 @@
|
|||
source /usr/lib/git-core/git-sh-prompt
|
||||
|
||||
git_is_repo() {
|
||||
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
git_current_branch() {
|
||||
echo $(git rev-parse --abbrev-ref HEAD)
|
||||
}
|
||||
|
||||
git_repo_is_dirty() {
|
||||
if [[ -z $(git status --short) ]]; then
|
||||
return 1;
|
||||
fi
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
git_prompt_info() {
|
||||
! git_is_repo || return
|
||||
|
||||
current_branch=$(git_current_branch 2> /dev/null)
|
||||
current_commit=$(git rev-parse --short HEAD 2> /dev/null)
|
||||
suffix=''
|
||||
|
||||
if [[ ! -z ${current_commit} ]]; then
|
||||
suffix="${suffix} [%{$fg_bold[yellow]%}${current_commit}%{$reset_color%}]"
|
||||
fi
|
||||
|
||||
if git_repo_is_dirty; then
|
||||
suffix="${suffix} %{$fg_bold[red]%}*%{$reset_color%}"
|
||||
fi
|
||||
|
||||
if [[ -n git_current_branch ]]; then
|
||||
echo " %{$fg_bold[green]%}$(__git_ps1 %s)%{$reset_color%}${suffix}"
|
||||
fi
|
||||
}
|
||||
|
||||
setopt promptsubst
|
||||
|
||||
export PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info) \$ '
|
4
roles/zsh/files/.zshenv
Normal file
4
roles/zsh/files/.zshenv
Normal file
|
@ -0,0 +1,4 @@
|
|||
PROMPT_EOL_MARK=''
|
||||
TERM=xterm-256color
|
||||
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
|
||||
ZLE_REMOVE_SUFFIX_CHARS=''
|
37
roles/zsh/files/.zshrc
Normal file
37
roles/zsh/files/.zshrc
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Enable extended globbing for use in _load_settings()
|
||||
setopt extendedglob
|
||||
|
||||
# extra files in ~/.zsh/configs/pre , ~/.zsh/configs , and ~/.zsh/configs/post
|
||||
# these are loaded first, second, and third, respectively.
|
||||
_load_settings() {
|
||||
_dir="$1"
|
||||
if [ -d "$_dir" ]; then
|
||||
if [ -d "$_dir/pre" ]; then
|
||||
for config in "$_dir"/pre/**/*~*.zwc(N-.); do
|
||||
. $config
|
||||
done
|
||||
fi
|
||||
|
||||
for config in "$_dir"/**/*(N-.); do
|
||||
case "$config" in
|
||||
"$_dir"/(pre|post)/*|*.zwc)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
. $config
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -d "$_dir/post" ]; then
|
||||
for config in "$_dir"/post/**/*~*.zwc(N-.); do
|
||||
. $config
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_load_settings "$HOME/.zsh/configs"
|
||||
|
||||
# Local config
|
||||
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
|
23
roles/zsh/tasks/main.yaml
Normal file
23
roles/zsh/tasks/main.yaml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: Install
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- zsh
|
||||
state: latest
|
||||
become: true
|
||||
|
||||
- name: Set default
|
||||
user:
|
||||
name: "{{ ansible_env['USER'] }}"
|
||||
shell: /usr/bin/zsh
|
||||
become: yes
|
||||
|
||||
- name: Configuration
|
||||
ansible.builtin.file:
|
||||
src: "{{ role_path }}/files/{{ item }}"
|
||||
dest: "{{ ansible_user_dir }}/{{ item }}"
|
||||
state: link
|
||||
with_items:
|
||||
- .zsh
|
||||
- .zshenv
|
||||
- .zshrc
|
Loading…
Add table
Add a link
Reference in a new issue