From 32b9d7373f217a1df27a85ecae4a2bf23f7072da Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Sun, 23 Jan 2022 02:20:50 +0100 Subject: [PATCH] initial commit --- defaults/main.yml | 1 + files/odie/bash/bash_aliases | 32 ++ files/odie/bash/bash_profile | 2 + files/odie/bash/bashrc | 70 +++++ files/odie/nano/nanorc | 1 + files/odie/tmux/tmux.conf | 95 ++++++ files/odie/vim/after/ftplugin/css.vim | 1 + files/odie/vim/after/ftplugin/help.vim | 10 + files/odie/vim/after/ftplugin/html.vim | 7 + files/odie/vim/after/ftplugin/javascript.vim | 1 + files/odie/vim/after/ftplugin/jinja.vim | 4 + files/odie/vim/after/ftplugin/markdown.vim | 1 + files/odie/vim/after/ftplugin/nfo.vim | 16 + files/odie/vim/after/ftplugin/php.vim | 1 + files/odie/vim/after/ftplugin/python.vim | 11 + files/odie/vim/after/ftplugin/rst.vim | 1 + files/odie/vim/after/ftplugin/ruby.vim | 2 + files/odie/vim/after/ftplugin/scss.vim | 1 + files/odie/vim/after/ftplugin/vue.vim | 5 + files/odie/vim/after/ftplugin/xml.vim | 1 + files/odie/vim/autoload/myfuncs.vim | 44 +++ files/odie/vim/vimrc | 306 +++++++++++++++++++ files/odie/zsh/zshenv | 16 + files/odie/zsh/zshrc | 27 ++ files/retropie/bash_profile | 4 + tasks/groups.yml | 9 + tasks/main.yml | 18 ++ tasks/users.yml | 89 ++++++ templates/AccountsService | 2 + templates/dmrc | 3 + templates/sudoers | 5 + vars/os_Arch.yml | 1 + vars/os_Debian.yml | 1 + vars/os_Raspbian.yml | 1 + 34 files changed, 789 insertions(+) create mode 100644 defaults/main.yml create mode 100644 files/odie/bash/bash_aliases create mode 100644 files/odie/bash/bash_profile create mode 100644 files/odie/bash/bashrc create mode 100644 files/odie/nano/nanorc create mode 100644 files/odie/tmux/tmux.conf create mode 100644 files/odie/vim/after/ftplugin/css.vim create mode 100644 files/odie/vim/after/ftplugin/help.vim create mode 100644 files/odie/vim/after/ftplugin/html.vim create mode 100644 files/odie/vim/after/ftplugin/javascript.vim create mode 100644 files/odie/vim/after/ftplugin/jinja.vim create mode 100644 files/odie/vim/after/ftplugin/markdown.vim create mode 100644 files/odie/vim/after/ftplugin/nfo.vim create mode 100644 files/odie/vim/after/ftplugin/php.vim create mode 100644 files/odie/vim/after/ftplugin/python.vim create mode 100644 files/odie/vim/after/ftplugin/rst.vim create mode 100644 files/odie/vim/after/ftplugin/ruby.vim create mode 100644 files/odie/vim/after/ftplugin/scss.vim create mode 100644 files/odie/vim/after/ftplugin/vue.vim create mode 100644 files/odie/vim/after/ftplugin/xml.vim create mode 100644 files/odie/vim/autoload/myfuncs.vim create mode 100644 files/odie/vim/vimrc create mode 100644 files/odie/zsh/zshenv create mode 100644 files/odie/zsh/zshrc create mode 100644 files/retropie/bash_profile create mode 100644 tasks/groups.yml create mode 100644 tasks/main.yml create mode 100644 tasks/users.yml create mode 100644 templates/AccountsService create mode 100644 templates/dmrc create mode 100644 templates/sudoers create mode 100644 vars/os_Arch.yml create mode 100644 vars/os_Debian.yml create mode 100644 vars/os_Raspbian.yml diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..dd16570 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1 @@ +users: [] diff --git a/files/odie/bash/bash_aliases b/files/odie/bash/bash_aliases new file mode 100644 index 0000000..6ef153d --- /dev/null +++ b/files/odie/bash/bash_aliases @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# File listing +alias ls='ls -F' +alias ll='ls -l' +alias la='ls -al' + +# Colors +alias grep='grep --color=auto' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' +alias diff='colordiff' + +# Convinience +alias mkdir='mkdir -p' +alias rm='rm -i' +alias mv='mv -i' +alias cp='cp -i' +alias ln='ln -i' + +# Editor +alias vi='vim' + +# Python +alias venv="source .venv/bin/activate" +alias serve='python -m http.server' + +# Network +alias ports='ss -tulpn' + +# Shortcuts +alias mpy='python manage.py' diff --git a/files/odie/bash/bash_profile b/files/odie/bash/bash_profile new file mode 100644 index 0000000..ee04237 --- /dev/null +++ b/files/odie/bash/bash_profile @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +[[ -f ${HOME}/.bashrc ]] && . ${HOME}/.bashrc diff --git a/files/odie/bash/bashrc b/files/odie/bash/bashrc new file mode 100644 index 0000000..968ce61 --- /dev/null +++ b/files/odie/bash/bashrc @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# Normal Colors +#Black="\[$(tput setaf 0)\]" # Black +Red="\[$(tput setaf 1)\]" # Red +Green="\[$(tput setaf 2)\]" # Green +Yellow="\[$(tput setaf 3)\]" # Yellow +#Blue="\[$(tput setaf 4)\]" # Blue +#Purple="\[$(tput setaf 5)\]" # Purple +Cyan="\[$(tput setaf 6)\]" # Cyan +#White="\[$(tput setaf 7)\]" # White + +# Bold +#Bold="\[$(tput bold)\]" # Black +#Bold="\[$(tput dim)\]" # Dim +#Bold="\[$(tput smso)\]" # Standout +#Bold="\[$(tput invis)\]" # Invisible +Reset="\[$(tput sgr0)\]" # Invisible + +# Background +#On_Black="\[$(tput setab 0)\]" # Black +#On_Red="\[$(tput setab 1)\]" # Red +#On_Green="\[$(tput setab 2)\]" # Green +#On_Yellow="\[$(tput setab 3)\]" # Yellow +#On_Blue="\[$(tput setab 4)\]" # Blue +#On_Purple="\[$(tput setab 5)\]" # Purple +#On_Cyan="\[$(tput setab 6)\]" # Cyan +#On_White="\[$(tput setab 7)\]" # White + +NC=$Reset # Color Reset + +function prompt_username { + # Test user type: + if [[ "${USER}" == "root" ]]; then + SU=${Red} # User is root. + elif [[ "$((UID))" == "0" ]]; then + SU=${Red} # User is root. + elif [[ "${USER}" != "$(whoami)" ]]; then + SU=${Red} # User is not login user. + else + SU=${Green} # User is normal (well ... most of us are). + fi + echo -n "${SU}\u${NC}" +} + +function prompt_hostname { + echo -n "${Cyan}\h${NC}" +} + +function prompt_directory { + echo -n "${Yellow}\W${NC}" +} + +function prompt_end { + retval=$Green + [[ $? -eq 0 ]] || retval=$Red + symbol="▸" + end="${retval}${symbol}${NC}" + echo -n "${end}" +} + +# PS1='[\u@\h \W]\$ ' +PS1="$(prompt_username)@$(prompt_hostname) $(prompt_directory) $(prompt_end) " + + +[ -f /usr/share/fzf/key-bindings.bash ] && source /usr/share/fzf/key-bindings.bash +[ -f /usr/share/fzf/completion.bash ] && source /usr/share/fzf/completion.bash diff --git a/files/odie/nano/nanorc b/files/odie/nano/nanorc new file mode 100644 index 0000000..bc10d47 --- /dev/null +++ b/files/odie/nano/nanorc @@ -0,0 +1 @@ +include "/usr/share/nano/*.nanorc" diff --git a/files/odie/tmux/tmux.conf b/files/odie/tmux/tmux.conf new file mode 100644 index 0000000..10519c6 --- /dev/null +++ b/files/odie/tmux/tmux.conf @@ -0,0 +1,95 @@ +# Unicode +#setw -g utf8 on +#set -g status-utf8 on +# prefix like screen +unbind C-b +set -g prefix ^A +bind a send-prefix + +# Quick pane cycling +unbind ^A +bind ^A last-window + +unbind 'Space' +bind 'Space' next-window + +# Start counting at 1 +set -g base-index 1 +set-window-option -g pane-base-index 1 + +# Act like Vim +set-window-option -g mode-keys vi +bind-key h select-pane -L +bind-key j select-pane -D +bind-key k select-pane -U +bind-key l select-pane -R + +bind-key -r '+' resize-pane -U 5 +bind-key -r '-' resize-pane -D 5 +bind-key -r '<' resize-pane -L 10 +bind-key -r '>' resize-pane -R 10 + +# Look good +#set -g default-terminal "screen-256color" +set-option -g mouse on + +# Increase History limit +set -g history-limit 10000 + +# Allows faster key repetition +set -s escape-time 0 + +bind-key b set-option status + +##CLIPBOARD selection integration +##Requires prefix key before the command key +#Copy tmux paste buffer to CLIPBOARD +bind C-c run "tmux show-buffer | xsel -i -b" +#Copy CLIPBOARD to tmux paste buffer and paste tmux paste buffer +bind C-v run "tmux set-buffer -- \"$(xsel -o -b)\"; tmux paste-buffer" + +# Status line +set -g status-justify "left" +set -g status "on" +set -g status-left-length "100" +set -g status-bg "#465457" +set -g status-right-length "100" +setw -g window-status-separator "" +set -g status-left "#[fg=#080808,bg=#e6db74] #S #[fg=#e6db74,bg=#465457,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=#232526,bg=#465457,nobold,nounderscore,noitalics]#[fg=#f8f8f0,bg=#232526] %d.%m.%Y  %H:%M #[fg=#e6db74,bg=#232526,nobold,nounderscore,noitalics]#[fg=#080808,bg=#e6db74] #h " +setw -g window-status-format "#[fg=#f8f8f0,bg=#465457] #I #[fg=#f8f8f0,bg=#465457] #W " +setw -g window-status-current-format "#[fg=#465457,bg=#232526,nobold,nounderscore,noitalics]#[fg=#f8f8f0,bg=#232526] #I #[fg=#f8f8f0,bg=#232526] #W #[fg=#232526,bg=#465457,nobold,nounderscore,noitalics]" + +set -g set-titles on +set -g set-titles-string "tmux - #S" + +set-option -sa terminal-overrides ',xterm-256color:RGB' + +is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" + +bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' } +bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' } +bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' } +bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' } + +bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L' +bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D' +bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U' +bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R' + +# List of plugins +# Supports `github_username/repo` or full git repo URLs +set -g @tpm_plugins ' \ + tmux-plugins/tpm \ + tmux-plugins/tmux-sensible \ + tmux-plugins/tmux-yank \ + nhdaly/tmux-better-mouse-mode \ +' +# Other examples: +# github_username/plugin_name \ +# git@github.com/user/plugin \ +# git@bitbucket.com/user/plugin \ + +# Initializes TMUX plugin manager. +# Keep this line at the very bottom of tmux.conf. +run-shell '~/.tmux/plugins/tpm/tpm' diff --git a/files/odie/vim/after/ftplugin/css.vim b/files/odie/vim/after/ftplugin/css.vim new file mode 100644 index 0000000..6f78fab --- /dev/null +++ b/files/odie/vim/after/ftplugin/css.vim @@ -0,0 +1 @@ +setlocal shiftwidth=2 diff --git a/files/odie/vim/after/ftplugin/help.vim b/files/odie/vim/after/ftplugin/help.vim new file mode 100644 index 0000000..8f90abf --- /dev/null +++ b/files/odie/vim/after/ftplugin/help.vim @@ -0,0 +1,10 @@ +""" +" Easyer Help mode navigation +""" + +nnoremap +nnoremap +nnoremap o /'\l\{2,\}' +nnoremap O ?'\l\{2,\}' +nnoremap s /\|\zs\S\+\ze\| +nnoremap S ?\|\zs\S\+\ze\| diff --git a/files/odie/vim/after/ftplugin/html.vim b/files/odie/vim/after/ftplugin/html.vim new file mode 100644 index 0000000..1a67f7c --- /dev/null +++ b/files/odie/vim/after/ftplugin/html.vim @@ -0,0 +1,7 @@ +setlocal shiftwidth=2 + +let b:delimitMate_matchpairs = '(:),[:],{:}' + +unlet! b:did_ftplugin +source $HOME/.vim/bundle/xmledit/ftplugin/html.vim +source $HOME/.vim/bundle/xmledit/ftplugin/xml.vim diff --git a/files/odie/vim/after/ftplugin/javascript.vim b/files/odie/vim/after/ftplugin/javascript.vim new file mode 100644 index 0000000..6f78fab --- /dev/null +++ b/files/odie/vim/after/ftplugin/javascript.vim @@ -0,0 +1 @@ +setlocal shiftwidth=2 diff --git a/files/odie/vim/after/ftplugin/jinja.vim b/files/odie/vim/after/ftplugin/jinja.vim new file mode 100644 index 0000000..e4f5228 --- /dev/null +++ b/files/odie/vim/after/ftplugin/jinja.vim @@ -0,0 +1,4 @@ +setlocal shiftwidth=2 + +let b:surround_45 = "{{ \r }}" +let b:surround_95 = "{% \r %}" diff --git a/files/odie/vim/after/ftplugin/markdown.vim b/files/odie/vim/after/ftplugin/markdown.vim new file mode 100644 index 0000000..85985f6 --- /dev/null +++ b/files/odie/vim/after/ftplugin/markdown.vim @@ -0,0 +1 @@ +setlocal textwidth=79 diff --git a/files/odie/vim/after/ftplugin/nfo.vim b/files/odie/vim/after/ftplugin/nfo.vim new file mode 100644 index 0000000..7dacf6e --- /dev/null +++ b/files/odie/vim/after/ftplugin/nfo.vim @@ -0,0 +1,16 @@ +" Necessary for multiple encodings +setlocal encoding=utf-8 + +" Common code for encodings +function! SetFileEncodings(encodings) + let b:myfileencodingsbak=&fileencodings + let &fileencodings=a:encodings +endfunction +function! RestoreFileEncodings() + let &fileencodings=b:myfileencodingsbak + unlet b:myfileencodingsbak +endfunction + +" .NFO specific +autocmd vimrc BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single +autocmd vimrc BufReadPost *.nfo call RestoreFileEncodings() diff --git a/files/odie/vim/after/ftplugin/php.vim b/files/odie/vim/after/ftplugin/php.vim new file mode 100644 index 0000000..6f78fab --- /dev/null +++ b/files/odie/vim/after/ftplugin/php.vim @@ -0,0 +1 @@ +setlocal shiftwidth=2 diff --git a/files/odie/vim/after/ftplugin/python.vim b/files/odie/vim/after/ftplugin/python.vim new file mode 100644 index 0000000..5f42ae1 --- /dev/null +++ b/files/odie/vim/after/ftplugin/python.vim @@ -0,0 +1,11 @@ +setlocal tabstop=4 +setlocal softtabstop=4 +setlocal shiftwidth=4 +setlocal textwidth=79 +setlocal expandtab +setlocal nosmarttab + +let b:surround_45 = "_(\r)" +let b:delimitMate_nesting_quotes = ['"', "'"] +let b:delimitMate_expand_cr = 1 +let b:delimitMate_expand_inside_quotes = 1 diff --git a/files/odie/vim/after/ftplugin/rst.vim b/files/odie/vim/after/ftplugin/rst.vim new file mode 100644 index 0000000..85985f6 --- /dev/null +++ b/files/odie/vim/after/ftplugin/rst.vim @@ -0,0 +1 @@ +setlocal textwidth=79 diff --git a/files/odie/vim/after/ftplugin/ruby.vim b/files/odie/vim/after/ftplugin/ruby.vim new file mode 100644 index 0000000..2bbb9fb --- /dev/null +++ b/files/odie/vim/after/ftplugin/ruby.vim @@ -0,0 +1,2 @@ +setlocal textwidth=79 +setlocal shiftwidth=2 diff --git a/files/odie/vim/after/ftplugin/scss.vim b/files/odie/vim/after/ftplugin/scss.vim new file mode 100644 index 0000000..6f78fab --- /dev/null +++ b/files/odie/vim/after/ftplugin/scss.vim @@ -0,0 +1 @@ +setlocal shiftwidth=2 diff --git a/files/odie/vim/after/ftplugin/vue.vim b/files/odie/vim/after/ftplugin/vue.vim new file mode 100644 index 0000000..879994c --- /dev/null +++ b/files/odie/vim/after/ftplugin/vue.vim @@ -0,0 +1,5 @@ +setlocal shiftwidth=2 + +unlet! b:did_ftplugin +source $HOME/.vim/bundle/xmledit/ftplugin/html.vim +source $HOME/.vim/bundle/xmledit/ftplugin/xml.vim diff --git a/files/odie/vim/after/ftplugin/xml.vim b/files/odie/vim/after/ftplugin/xml.vim new file mode 100644 index 0000000..6f78fab --- /dev/null +++ b/files/odie/vim/after/ftplugin/xml.vim @@ -0,0 +1 @@ +setlocal shiftwidth=2 diff --git a/files/odie/vim/autoload/myfuncs.vim b/files/odie/vim/autoload/myfuncs.vim new file mode 100644 index 0000000..1306dd8 --- /dev/null +++ b/files/odie/vim/autoload/myfuncs.vim @@ -0,0 +1,44 @@ +" Delete Trailing Whitespace +function! myfuncs#DeleteTrailingWhitespace() abort + if ! &bin + silent! %s/\s\+$//ge + endif +endfunction + + +" Recursively search up from dirname, sourcing all .vimrc.local files along the way +function! myfuncs#ApplyLocalSettings(dirname) abort + " convert windows paths to unix style + let l:curDir = substitute(a:dirname, '\\', '/', 'g') + + " walk to the top of the dir tree + let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, '/')) + if isdirectory(l:parentDir) + call ApplyLocalSettings(l:parentDir) + endif + + " now walk back down the path and source .vimsettings as you find them. + " child directories can inherit from their parents + let l:settingsFile = a:dirname . '/.vimrc.local' + if filereadable(l:settingsFile) + exec ':runtime' . l:settingsFile + endif +endfunction + +" Toggle relative number +function! myfuncs#NumberToggle() + if(&relativenumber == 1) + set norelativenumber + else + set relativenumber + endif +endfunction + +"Restore Last Cursor Position +function! myfuncs#RestoreCursor() + if line("'\"") <= line("$") + normal! g`" + return 1 + endif +endfunction + diff --git a/files/odie/vim/vimrc b/files/odie/vim/vimrc new file mode 100644 index 0000000..936c854 --- /dev/null +++ b/files/odie/vim/vimrc @@ -0,0 +1,306 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""" +""" VIM Config - by odie +""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +"""""""""""" +"" FUNCTIONS +"""""""""""" + +function! Cond(cond, ...) + let opts = get(a:000, 0, {}) + return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) +endfunction + +let g:my_vimdir = expand('$HOME/.vim') +let g:my_vimrc = expand('$HOME/.vim/init.vim') +let g:my_plugdir = g:my_vimdir . '/bundle' +let g:my_plug = g:my_vimdir . '/autoload/plug.vim' + +"""""""""" +"" PLUGINS +"""""""""" + +" Install Vim Plug if not installed +if empty(glob(g:my_plug)) + execute 'silent !curl -fLo ' . g:my_plug . ' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + autocmd VimEnter * PlugInstall +endif + +call plug#begin(g:my_plugdir) + +" Colorschemes +Plug 'patstockwell/vim-monokai-tasty' + +" Plugins +Plug 'Raimondi/delimitMate', { 'for': ['vue','python','javascript','typescript','html']} +Plug 'tpope/vim-surround', { 'for': ['vue','python','javascript','typescript','html']} +Plug 'tpope/vim-repeat', { 'for': ['vue','python','javascript','typescript','html']} +Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'Bookmark']} | Plug 'Xuyuanp/nerdtree-git-plugin' +Plug 'scrooloose/nerdcommenter', { 'for': ['vue','python','javascript','typescript','html']} +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!', 'WhichKeyVisual', 'WhichKeyVisual!'] } +Plug 'editorconfig/editorconfig-vim' +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' + +call plug#end() " required + +""""""""""""""" +"" VIM SETTINGS +""""""""""""""" + +syntax on +filetype plugin indent on +scriptencoding utf-8 + +"Move over end of line +set whichwrap=b,s,<,>,[,],h,l +" Backspace over autoindent, line breaks, start of insert (see :help 'backspace') +set backspace=indent,eol,start +"Auto indentation +set autoindent +"Tabs +set tabstop=8 +set softtabstop=4 +set shiftwidth=4 +set expandtab +set smarttab + +" Paste mode toggle key +set pastetoggle= + +" Set Leader Key +let g:mapleader = "\" +let g:maplocalleader = "," + +"" Mouse Settings +if has('mouse') + set mouse=a + set selectmode=mouse +endif + +"" Search Settings +"Better Tab Completion +set wildmenu +set wildmode=list:longest +set hlsearch +set ignorecase +set smartcase +set incsearch + +"" Misc Settings +" Status Line +set laststatus=2 +"Bigger History +set history=1000 +" keep at least 5 lines above/below +set scrolloff=5 +set sidescrolloff=5 +"1000 Undos +set undolevels=1000 +"Dont move to startofline +set nostartofline +"Activate hidden buffers +set hidden +"Automatically read buffer when changed outside of vim +set autoread +"Place backup and temp directory somewhere else +set backup +"Use "./" in the 'tags' options reads tags file relative to current directory +set cpoptions+=d +" Backup, tag and undo locations +execute 'set tags=./.tags,' . g:my_vimdir . '/tags,tags' +execute 'set backupdir=' . g:my_vimdir . '/backup' +execute 'set directory=' . g:my_vimdir . '/tmp' +execute 'set undodir=' . g:my_vimdir . '/undo' +" Line numbers +set number +" Make bell visual and disable error bells +set visualbell +set noerrorbells +" Show (partial) command in status line +set showcmd +" Colorize column 80 +set colorcolumn=80 +" +" Enable persistent undo +if has("persistent_undo") + set undofile +endif + +set ttyfast + +" Colorscheme +"set t_Co=256 +let g:vim_monokai_tasty_italic = 1 +silent! colorscheme vim-monokai-tasty + + +"""""""""""""""""" +"" PLUGIN SETTINGS +"""""""""""""""""" + +" Disable netrw +let loaded_netrwPlugin = 1 + + +" delimitMate +let delimitMate_balance_matchpairs = 1 + +" nerdtree +let NERDTreeIgnore = ['\.pyc$', '__pycache__$[[dir]]', '\~$', '\.git$'] + + +" vim-airline +let g:airline_powerline_fonts = 1 +let g:airline_theme = "molokai" +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif +let g:airline#extensions#hunks#enabled = 0 +let g:airline#extensions#hunks#non_zero_only = 1 +let g:airline#extensions#virtualenv#enabled = 1 +let g:airline#extensions#ale#enabled = 1 +let g:airline#extensions#lsp#enabled = 0 +let g:airline#extensions#whitespace#enabled = 0 +let g:airline#extensions#whitespace#trailing_format = '●[%s]' +let g:airline#extensions#whitespace#mixed_indent_format = '○[%s]' + +let g:which_key_use_floating_win = 1 +let g:which_key_floating_opts = { 'row': '-10', 'width': '-30', 'height': '+5', 'col': '+15' } +let g:which_key_disable_default_offset = 1 +let g:which_key_vertical = 1 + +let g:which_key_map = {} + + +"""""""""""""" +"" KEYBINDINGS +"""""""""""""" + +nnoremap :WhichKey '' +vnoremap :WhichKeyVisual '' + +nnoremap :WhichKey ',' +vnoremap :WhichKeyVisual ',' + +nnoremap :Files +nnoremap ff :Files +nnoremap fs :write +let g:which_key_map[''] = 'fzf-files' +let g:which_key_map.f = { + \ 'name' : '+file' , + \ 'f': ['Files' , 'fzf-files'] , + \ 's': ['write' , 'save-file'] , + \ } + +" Buffers +nnoremap , :Buffers +nnoremap bb :Buffers +nnoremap bd :bd +nnoremap bf :bfirst +nnoremap bl :blast +nnoremap bp :bprevious +nnoremap bn :bnext +let g:which_key_map[','] = 'fzf-buffers' +let g:which_key_map.b = { + \ 'name': '+buffer' , + \ 'd': ['bd' , 'delete-buffer'] , + \ 'f': ['bfirst' , 'first-buffer'] , + \ 'h': ['Startify' , 'home-buffer'] , + \ 'l': ['blast' , 'last-buffer'] , + \ 'n': ['bnext' , 'next-buffer'] , + \ 'p': ['bprevious' , 'previous-buffer'] , + \ 'b': ['Buffers' , 'fzf-buffer'] , + \ } + +nnoremap of :NERDTreeToggle +nnoremap oh :Startify +let g:which_key_map.o = { + \ 'name': '+open' , + \ 'f': ['NERDTreeToggle', 'nerdtree-toggle'] , + \ 'h': ['Startify' , 'save-file'] , + \ } + + +nnoremap gs :Git +nnoremap gc :Gitcommit +nnoremap gl :Gitlog +let g:which_key_map.g = { + \ 'name' : '+git' , + \ 's': ['Git', 'git-status'] , + \ 'c': ['Git commit', 'git-commit'] , + \ 'l': ['Git log', 'git-log'] , + \ } + +nnoremap qq :q +nnoremap qQ :q! +let g:which_key_map.q = { + \ 'name': '+quit' , + \ 'q': ['quit', 'quit'] , + \ 'Q': ['quit!', 'force-quit'] , + \ } + +nnoremap hhp :PlugUpdate +nnoremap hhP :PlugUpgrade +nnoremap hhc :PlugClean +nnoremap hhs :PlugStatus +let g:which_key_map.h = { + \ 'name': '+help' , + \ } + +let g:which_key_map.h.p = { + \ 'name': '+plugin' , + \ 'u': ['PlugUpdate', 'plug-update'] , + \ 'U': ['PlugUpgrade', 'plug-upgrade'] , + \ 'c': ['PlugClean', 'plug-clean'] , + \ 's': ['PlugStatus', 'plug-status'] , + \ } + +nnoremap ww :Windows +nnoremap wc c +nnoremap ws s +nnoremap wh h +nnoremap wj j +nnoremap wk k +nnoremap wl l +nnoremap wd c +let g:which_key_map.w = { + \ 'name': '+window' , + \ 'w': ['w' , 'fzf-windows'] , + \ 'd': ['c' , 'delete-window'] , + \ 'h': ['h' , 'window-left'] , + \ 'j': ['j' , 'window-below'] , + \ 'l': ['l' , 'window-right'] , + \ 'k': ['k' , 'window-up'] , + \ 's': ['s' , 'split-window-below'] , + \ 'v': ['v' , 'split-window-below'] , + \ } + +nnoremap pf :NERDTreeToggle +nnoremap pB :Bookmark +let g:which_key_map.p = { + \ 'name': '+project' , + \ 'f': ['NERDTreeToggle', 'nerdtree-toggle'] , + \ 'B': ['Bookmark', 'nerdtree-bookmark'] , + \ } + +autocmd! User vim-which-key call which_key#register('', 'g:which_key_map') + +"""""""""""""""""""" +"" AUTOCOMMAND GROUP +"""""""""""""""""""" + +if has('autocmd') + augroup vimrc + autocmd! + "autocmd BufWinEnter * :AirlineRefresh + autocmd BufWinEnter * call myfuncs#RestoreCursor() + autocmd BufWritePost * :call myfuncs#DeleteTrailingWhitespace() + execute 'autocmd BufWritePost .vimrc :source' . g:my_vimrc + execute 'autocmd BufWritePost vimrc :source' . g:my_vimrc + execute 'autocmd BufWritePost init.vim :source' . g:my_vimrc + augroup END +endif + +call myfuncs#ApplyLocalSettings('.') diff --git a/files/odie/zsh/zshenv b/files/odie/zsh/zshenv new file mode 100644 index 0000000..86352f7 --- /dev/null +++ b/files/odie/zsh/zshenv @@ -0,0 +1,16 @@ +export ENV_NAME=".venv" +export EDITOR="vim" +export SUDO_EDITOR=$EDITOR +export GIT_EDITOR=$EDITOR +export VISUAL=$EDITOR +export BROWSER="firefox" + +[ -f ~/.bash_aliases ] && source ~/.bash_aliases +[ -f ~/.bash_aliases.local ] && source ~/.bash_aliases.local + +export PATH="$HOME/bin:$HOME/.local/bin:$PATH" +export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' +# pipenv +export PIPENV_VENV_IN_PROJECT=1 + +[ -f ~/.zshenv.local ] && source ~/.zshenv.local diff --git a/files/odie/zsh/zshrc b/files/odie/zsh/zshrc new file mode 100644 index 0000000..4ae0f0a --- /dev/null +++ b/files/odie/zsh/zshrc @@ -0,0 +1,27 @@ +source ${HOME}/.zsh/antigen.zsh + +antigen use oh-my-zsh + +fpath=(${HOME}/.completion $fpath) + +antigen bundle git +antigen bundle gitignore +antigen bundle vi-mode +antigen bundle tmux +antigen bundle pip +antigen bundle virtualenv +antigen bundle direnv +antigen bundle zsh-users/zsh-syntax-highlighting +antigen bundle zsh-users/zsh-autosuggestions +antigen bundle zsh-users/zsh-completions + +antigen theme masterodie/zsh-theme-odie odie + +if [ -f /usr/bin/fzf ]; then + export FZF_BASE=/usr/bin/fzf + antigen bundle fzf +fi + +[ -f ~/.zshrc.local ] && source ~/.zshrc.local + +antigen apply diff --git a/files/retropie/bash_profile b/files/retropie/bash_profile new file mode 100644 index 0000000..1744ec5 --- /dev/null +++ b/files/retropie/bash_profile @@ -0,0 +1,4 @@ +[ "${XDG_VTNR}" -eq 8 ] +then + exec /usr/bin/emulationstation; exit +fi diff --git a/tasks/groups.yml b/tasks/groups.yml new file mode 100644 index 0000000..9c9d450 --- /dev/null +++ b/tasks/groups.yml @@ -0,0 +1,9 @@ +- block: + - name: "Create group for user '{{ user.username }}'." + tags: users + ansible.builtin.group: + name: "{{ user.group | default(user.username) }}" + gid: "{{ user.gid | default(omit) }}" + state: present + when: + - user.state | default('present') == 'present' diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..017551e --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,18 @@ +- name: Load OS specific variables. + tags: always,users + ansible.builtin.include_vars: + file: "os_{{ os_distribution }}.yml" + +- include_tasks: + file: groups.yml + tags: users + with_items: "{{ users }}" + loop_control: + loop_var: user + +- include_tasks: + file: users.yml + tags: users + with_items: "{{ users }}" + loop_control: + loop_var: user diff --git a/tasks/users.yml b/tasks/users.yml new file mode 100644 index 0000000..ab5f744 --- /dev/null +++ b/tasks/users.yml @@ -0,0 +1,89 @@ +- block: + - name: "Create user '{{ user.username }}'." + tags: users + ansible.builtin.user: + name: "{{ user.username }}" + state: "{{ user.state | default('present') }}" + group: "{{ user.group | default(user.username) }}" + groups: "{{ user.groups | default(omit) | join(',') }}" + comment: "{{ user.comment | default(omit) }}" + shell: "{{ user.shell | default(omit) }}" + password: "{{ user.password | default(omit) }}" + system: "{{ user.system | default(omit) }}" + uid: "{{ user.uid | default(omit) }}" + gid: "{{ user.gid | default(omit) }}" + update_password: on_create + + - name: "Create sudoers file for user '{{ user.username }}'." + tags: users,sudo + ansible.builtin.template: + src: "sudoers" + dest: "/etc/sudoers.d/{{ user.username }}" + owner: root + group: root + mode: 0440 + when: + - user.sudo | default(false) + + - name: "Create config directories for user '{{ user.username }}'." + tags: users + ansible.builtin.file: + path: "{{ user.home_dir | default('/home/' + user.username) }}/{{ item }}" + state: directory + owner: "{{ user.username }}" + group: "{{ user.username }}" + mode: 0700 + with_items: "{{ user.config_dirs | default([]) }}" + + - name: "Copy config files for user '{{ user.username }}'." + tags: users + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "{{user.home_dir | default('/home/' + user.username) }}/{{ item.dest }}" + owner: "{{ user.username }}" + group: "{{ user.username }}" + mode: 0600 + with_items: "{{ user.config_files | default([]) }}" + register: dotfiles_installed + + - name: "Create config files from templates for user '{{ user.username }}'." + tags: users + ansible.builtin.template: + src: "{{ item.src }}" + dest: "{{user.home_dir | default('/home/' + user.username) }}/{{ item.dest }}" + owner: "{{ user.username }}" + group: "{{ user.username }}" + mode: 0600 + with_items: "{{ user.config_templates | default([]) }}" + register: dotfiles_installed + + - name: "Add ssh public keys for user '{{ user.username }}'." + tags: users + ansible.builtin.authorized_key: + user: "{{ user.username }}" + key: "{{ item }}" + with_items: "{{ user.ssh_keys | default([]) }}" + + - name: "Install antigen for '{{ user.username }}'." + tags: users + become: true + become_user: "{{ user.username }}" + ansible.builtin.get_url: + url: https://git.io/antigen + dest: "{{ user.home_dir | default('/home/' + user.username) }}/.zsh/antigen.zsh" + mode: 0600 + when: + - user.shell is defined + - "'/zsh' in user.shell" + + - name: "Install tpm for user '{{ user.username }}'." + tags: users + become: true + become_user: "{{ user.username }}" + ansible.builtin.git: + repo: "https://github.com/tmux-plugins/tpm" + dest: "{{ user.home_dir | default('/home/' + user.username) }}/.tmux/plugins/tpm" + version: v3.0.0 + + when: + - user.state | default('present') == 'present' diff --git a/templates/AccountsService b/templates/AccountsService new file mode 100644 index 0000000..f2e704e --- /dev/null +++ b/templates/AccountsService @@ -0,0 +1,2 @@ +[User] +Icon=/usr/share/pixmaps/faces/{{ user.username }} diff --git a/templates/dmrc b/templates/dmrc new file mode 100644 index 0000000..23cccc3 --- /dev/null +++ b/templates/dmrc @@ -0,0 +1,3 @@ +[Desktop] +Session={{ user.destkop_session | default('gnome') }} +Language={{ common_locale }} diff --git a/templates/sudoers b/templates/sudoers new file mode 100644 index 0000000..efca2d9 --- /dev/null +++ b/templates/sudoers @@ -0,0 +1,5 @@ +{% if user.sudoers is defined %} +{{ user.sudoers }} +{% else %} +{{ user.username }} ALL=(ALL) {% if user.sudo == 'nopasswd' %}NOPASSWD:{% endif %}ALL +{% endif %} diff --git a/vars/os_Arch.yml b/vars/os_Arch.yml new file mode 100644 index 0000000..5d27aaa --- /dev/null +++ b/vars/os_Arch.yml @@ -0,0 +1 @@ +group_sudo: wheel diff --git a/vars/os_Debian.yml b/vars/os_Debian.yml new file mode 100644 index 0000000..9e11934 --- /dev/null +++ b/vars/os_Debian.yml @@ -0,0 +1 @@ +group_sudo: sudo diff --git a/vars/os_Raspbian.yml b/vars/os_Raspbian.yml new file mode 100644 index 0000000..9e11934 --- /dev/null +++ b/vars/os_Raspbian.yml @@ -0,0 +1 @@ +group_sudo: sudo