diff --git a/roles/dotfiles/defaults/main.yml b/roles/dotfiles/defaults/main.yml index 984e286..42e4d77 100644 --- a/roles/dotfiles/defaults/main.yml +++ b/roles/dotfiles/defaults/main.yml @@ -41,7 +41,7 @@ l3d_users__dotfiles__aliases: - {alias: "lz", command: "ls -Z", color: false} - {alias: "EDITOR", command: "/usr/bin/vim", color: false} - {alias: "VISUAL", command: "/usr/bin/gedit", color: false} - - {alias: "gitsubpull", command: "git submodule foreach '(git checkout \\$(git symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@'); git pull)'", color: false} + - {alias: "gitsubpull", command: "git submodule foreach '(git checkout $(git symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@'); git pull ; git submodule foreach \"(git checkout $(git symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@'); git pull)\")'", color: false} - {alias: "pwgen", command: "/usr/bin/pwgen --num-passwords=3000 --numerals --capitalize --secure --no-vowels --ambiguous 95 1", color: false} - {alias: "gdiff", command: "git diff --submodule=diff", color: false} dotfiles__additional_user_bashrc_lines: [] @@ -57,5 +57,8 @@ l3d_users__dotfiles__history_control: 'ignoreboth' l3d_users__dotfiles__history_size: '-1' l3d_users__dotfiles__history_file_size: '-1' +# vim config +l3d_users__vimrc: true + # run simple versionscheck submodules_versioncheck: false diff --git a/roles/dotfiles/tasks/main.yml b/roles/dotfiles/tasks/main.yml index c44f1fd..3e35b8c 100644 --- a/roles/dotfiles/tasks/main.yml +++ b/roles/dotfiles/tasks/main.yml @@ -12,3 +12,8 @@ ansible.builtin.include_tasks: file: 'bashrc.yml' when: l3d_users__bashrc | bool + +- name: Setup and configure vimrc + ansible.builtin.include_tasks: + file: 'vimrc.yml' + when: l3d_users__vimrc | bool diff --git a/roles/dotfiles/tasks/vimrc.yml b/roles/dotfiles/tasks/vimrc.yml new file mode 100644 index 0000000..f13c327 --- /dev/null +++ b/roles/dotfiles/tasks/vimrc.yml @@ -0,0 +1,23 @@ +--- +- name: Create vimrc configuration for root + become: true + ansible.builtin.template: + src: 'templates/vimrc.j2' + dest: '/root/.vimrc' + owner: 'root' + group: 'root' + mode: 'u=rw,g=r,o=r' + +- name: Create global bashrc configuration + become: true + ansible.builtin.template: + src: 'templates/dotbashrc.j2' + dest: "{{ user.home | default('/home/' + user.name) }}/.bashrc" + owner: "{{ user.name }}" + group: "{{ user.name }}" + mode: '0640' + loop: "{{ _l3d_users__merged_users }}" + loop_control: + label: "user={{ user.name }}" + loop_var: user + when: user.state | default ('present') == 'present' diff --git a/roles/dotfiles/templates/bash.bashrc.j2 b/roles/dotfiles/templates/bash.bashrc.j2 index 03d237c..3832631 100644 --- a/roles/dotfiles/templates/bash.bashrc.j2 +++ b/roles/dotfiles/templates/bash.bashrc.j2 @@ -8,19 +8,19 @@ if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" {% for alias in dotfiles__aliases %} -{% if alias.color %} +{% if alias.color %} alias {{ alias.alias }}="{{ alias.command }} --color=auto" -{% endif%} +{% endif %} {% endfor %} fi {% for alias in l3d_users__dotfiles__aliases %} -{% if not alias.color %} +{% if not alias.color %} alias {{ alias.alias }}="{{ alias.command }}" -{% endif%} +{% endif %} {% endfor %} -{%if l3d_users__dotfiles__bash_completion_enabled %} +{% if l3d_users__dotfiles__bash_completion_enabled %} if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion @@ -28,7 +28,6 @@ if ! shopt -oq posix; then . /etc/bash_completion fi fi - {% endif %} # fancy Prompt diff --git a/roles/dotfiles/templates/dotbashrc.j2 b/roles/dotfiles/templates/dotbashrc.j2 index 600c40a..7999b3f 100644 --- a/roles/dotfiles/templates/dotbashrc.j2 +++ b/roles/dotfiles/templates/dotbashrc.j2 @@ -4,7 +4,7 @@ # Source global definitions if [ -f /etc/bash.bashrc ]; then - . /etc/bash.bashrc + source /etc/bash.bashrc fi # User specific environment @@ -15,19 +15,19 @@ export PATH if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" {% for alias in dotfiles__aliases %} -{% if alias.color %} +{% if alias.color %} alias {{ alias.alias }}="{{ alias.command }} --color=auto" -{% endif%} +{% endif %} {% endfor %} fi {% for alias in l3d_users__dotfiles__aliases %} -{% if not alias.color %} +{% if not alias.color %} alias {{ alias.alias }}="{{ alias.command }}" -{% endif%} +{% endif %} {% endfor %} -{%if l3d_users__dotfiles__bash_completion_enabled %} +{% if l3d_users__dotfiles__bash_completion_enabled %} if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion @@ -35,6 +35,7 @@ if ! shopt -oq posix; then . /etc/bash_completion fi fi +{% endif %} # fancy Prompt export PS1='{{ l3d_users__dotfiles__user_prompt }} ' @@ -59,7 +60,7 @@ HISTFILESIZE={{ dotfiles__history_file_size }} {% endfor %} # additional user rules -{% for custom in {{ user.bashrc | default([]) }} %} +{% for custom in user.bashrc | default([]) %} {{ custom }} {% endfor %} diff --git a/roles/dotfiles/templates/vimrc.j2 b/roles/dotfiles/templates/vimrc.j2 new file mode 100644 index 0000000..b274040 --- /dev/null +++ b/roles/dotfiles/templates/vimrc.j2 @@ -0,0 +1,49 @@ +{{ ansible_managed | comment }} + +" gopass secure editor +au BufNewFile,BufRead /dev/shm/gopass.* setlocal noswapfile nobackup noundofile + +" vim layout +syntax on " enable syntax highlighting +set cursorline " highlight the current line +set fileencoding=utf-8 +set encoding=utf-8 +colorscheme elflord +set cursorline " highlight the current line + +" tabs and indenting +set autoindent " auto indenting +set smartindent " smart indenting +set expandtab " spaces instead of tabs +set tabstop=2 " 2 spaces for tabs +set shiftwidth=2 " 2 spaces for indentation + +" mouse +set mouse-=a " disable weird mouse behavior +nnoremap :tabprevious +nnoremap :tabprevious +nnoremap :tabnext +nnoremap :tabnext + +" bells +set noerrorbells " turn off audio bell +set visualbell " but leave on a visual bell + +" search +set hlsearch " highlighted search results +set showmatch " show matching bracket + +" behavior +filetype on " enable filetype detection +set scrolloff=5 " show at least 5 lines above/below +set showcmd " show selection metadata +set showmode " show INSERT, VISUAL, etc. mode +set showmatch " show matching brackets +set autoindent smartindent " auto/smart indent +set smarttab " better backspace and tab functionali +set nobackup " don't create pointless backup files; Use VCS instead +set autoread " watch for file changes + +" extra whitespace +highlight ExtraWhitespace ctermbg=red guibg=red +match ExtraWhitespace /\s\+$/ diff --git a/roles/dotfiles/vars/main.yml b/roles/dotfiles/vars/main.yml index 1cdd8e7..c0ea3ec 100644 --- a/roles/dotfiles/vars/main.yml +++ b/roles/dotfiles/vars/main.yml @@ -3,7 +3,6 @@ l3d_users__dotfiles_packages: - bash - vim - htop - - ranger -playbook_version_number: 2 +playbook_version_number: 4 playbook_version_path: 'l3d.users.dotfiles.version'