Ansible god!
Big rework! Control stuffs with variables! We still should do some movei'n around of roles before extending features.
This commit is contained in:
15
roles/shell/files/aliases.sh
Executable file
15
roles/shell/files/aliases.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
which lsd>/dev/null
|
||||
if [ "$?" = "0" ]; then
|
||||
alias ls="lsd -h --color=auto --group-dirs first"
|
||||
else
|
||||
alias ls="ls -h --color=auto --group-directories-first"
|
||||
fi
|
||||
# ([ "$?" = "0" ] && \
|
||||
# alias ls="lsd -h --color=auto --group-dirs first") || \
|
||||
# alias ls="ls -h --color=auto --group-directories-first"
|
||||
alias\
|
||||
ll="ls -l"\
|
||||
la="ls -a"\
|
||||
diff="diff --color=auto"\
|
||||
grep="grep --color=auto -n"
|
6
roles/shell/files/bat.conf
Normal file
6
roles/shell/files/bat.conf
Normal file
@@ -0,0 +1,6 @@
|
||||
--theme "Solarized (dark)"
|
||||
--style "numbers,changes,header"
|
||||
--map-syntax "*.ino:C++"
|
||||
--decorations auto
|
||||
--color auto
|
||||
--tabs 2
|
16
roles/shell/files/env.sh
Normal file
16
roles/shell/files/env.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
export LS_COLORS='di=1;35:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90:*.png=35:*.gif=36:*.jpg=35:*.c=92:*.jar=33:*.py=93:*.h=90:*.txt=94:*.doc=104:*.docx=104:*.odt=104:*.csv=102:*.xlsx=102:*.xlsm=102:*.rb=31:*.cpp=92:*.sh=92:*.html=96:*.zip=4;33:*.tar.gz=4;33:*.mp4=105:*.mp3=106'
|
||||
[ -d ~/.npm/node_modules/.bin ] && PATH=~/.npm/node_modules/.bin:$PATH
|
||||
[ -d ~/.go/bin ] && PATH=~/.go/bin:$PATH
|
||||
[ -d ~/.cargo/bin ] && PATH=~/.cargo/bin:$PATH
|
||||
[ -d ~/.local/bin ] && PATH=~/.local/bin:$PATH
|
||||
[ -d ~/.emacs.d/bin ] && PATH=~/.emacs.d/bin:$PATH
|
||||
[ -e ~/.aliases ] && source ~/.aliases
|
||||
export EDITOR=/usr/bin/vim
|
||||
export HISTFILE=~/.histfile
|
||||
export HISTSIZE=42069
|
||||
export SAVEHIST=42069
|
||||
export PAGER="less"
|
||||
export BAT_CONFIG_PATH=~/.bat.conf
|
||||
export GOPATH=~/.go
|
||||
export PATH
|
13
roles/shell/files/zstyles.zsh
Normal file
13
roles/shell/files/zstyles.zsh
Normal file
@@ -0,0 +1,13 @@
|
||||
zstyle ':completion:*' auto-description 'specify: %d'
|
||||
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
|
||||
zstyle ':completion:*' format 'Completing %d'
|
||||
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
||||
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
|
||||
zstyle ':completion:*' max-errors 1
|
||||
zstyle ':completion::complete:*' use-cache 1
|
||||
zstyle ':vcs_info:*' enable git
|
||||
zstyle ':vcs_info:git*+set-message:*' hooks untracked-git
|
||||
zstyle ':vcs_info:*' check-for-changes true
|
||||
zstyle ':vcs_info:*' unstagedstr '!'
|
||||
zstyle ':vcs_info:*' stagedstr '+'
|
||||
zstyle ':vcs_info:*' formats "%f%s(%F{red}%r/%b%f)%c "$'\n'" %F{#bb33bb}% %S%f"
|
26
roles/shell/tasks/extra.yml
Normal file
26
roles/shell/tasks/extra.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
- name: Add .aliases
|
||||
copy: src=aliases.sh dest=/home/{{ name }}/.aliases owner={{ name }} group={{ group }} mode=0644
|
||||
- name: Add .bat.conf
|
||||
copy: src=bat.conf dest=/home/{{ name }}/.bat.conf owner={{ name }} group={{ group }} mode=0644
|
||||
when: "'bat' in packages or 'bat' in extra_packages"
|
||||
|
||||
- name: Install zsh syntax highlighting (~/.zshrc.d folder)
|
||||
when: not zsh_opt_config
|
||||
git:
|
||||
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
dest: /home/{{ name }}/.zshrc.d/zsh-syntax-highlighting
|
||||
single_branch: yes
|
||||
version: master
|
||||
- name: Install zsh syntax highlighting (/opt/zsh folder)
|
||||
when: zsh_opt_config
|
||||
git:
|
||||
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
dest: /opt/zsh/zsh-syntax-highlighting
|
||||
single_branch: yes
|
||||
version: master
|
||||
become: true
|
||||
- name: Add ~/.zshrc.d -> /opt/zsh symbolic link
|
||||
when: zsh_opt_config
|
||||
file: state=link dest=/home/{{ name }}/.zshrc.d src=/opt/zsh owner={{ name }} group={{ group }} mode=0755
|
||||
- name: Set owner ship of zsh syntax highlighting files
|
||||
file: state=directory recurse=yes dest=/home/{{ name }}/.zshrc.d owner={{ name }} group={{ group }}
|
30
roles/shell/tasks/main.yml
Normal file
30
roles/shell/tasks/main.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
- name: Setup user zsh config
|
||||
when: "'zsh' in setup"
|
||||
tags: [user,zsh]
|
||||
block:
|
||||
- name: Add .zshrc
|
||||
template: src=zshrc.zsh.j2 dest=/home/{{ name }}/.zshrc owner={{ name }} group={{ group }} mode=0644
|
||||
- name: Add zsh zstyles config
|
||||
copy: src=zstyles.zsh dest=/home/{{ name }}/.zstyles owner={{ name }} group={{ group }} mode=0644
|
||||
|
||||
- name: Setup user bash config
|
||||
when: "'bash' in setup"
|
||||
tags: [user,bash]
|
||||
block:
|
||||
- name: Add .bashrc
|
||||
template: src=bashrc.sh.j2 dest=/home/{{ name }}/.bashrc owner={{ name }} group={{ group }} mode=0644
|
||||
|
||||
- name: Setup user extra config
|
||||
when: "'extra' in setup"
|
||||
tags: [user,extra]
|
||||
block:
|
||||
- import_tasks: extra.yml
|
||||
|
||||
- name: Add .env file
|
||||
when: not revert
|
||||
copy: src=env.sh dest=/home/{{ name }}/.env owner={{ name }} group={{ group }} mode=0644
|
||||
|
||||
- name: Revert ansible shell setup
|
||||
when: revert
|
||||
block:
|
||||
- import_tasks: revert.yml
|
27
roles/shell/tasks/revert.yml
Normal file
27
roles/shell/tasks/revert.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
- name: Remove user zsh config
|
||||
tags: [zsh]
|
||||
block:
|
||||
- name: Remove .zshrc
|
||||
file: state=absent path=/home/{{ name }}/.zshrc
|
||||
- name: Remove zsh zstyles config
|
||||
file: state=absent path=/home/{{ name }}/.zstyles
|
||||
- name: Remove .zshrc.d folder/link
|
||||
file: state=absent path=/home/{{ name }}/.zshrc.d
|
||||
|
||||
- name: Remove zsh syntax highlighting
|
||||
file: state=absent path=/home/{{ name }}/.zshrc.d/zsh-syntax-highlighting
|
||||
when: not zsh_opt_config
|
||||
- name: Remove zsh syntax highlighting (/opt/zsh)
|
||||
file: state=absent path=/opt/zsh/zsh-syntax-highlighting
|
||||
when: zsh_opt_config
|
||||
|
||||
- name: Remove extra user config
|
||||
when: "'extra' in setup"
|
||||
tags: [extra]
|
||||
block:
|
||||
- name: Remove .aliases
|
||||
file: state=absent path=/home/{{ name }}/.aliases
|
||||
- name: Remove .bat.conf
|
||||
file: state=absent path=/home/{{ name }}/.bat.conf
|
||||
- name: Remove .env file
|
||||
file: state=absent path=/home/{{ name }}/.env
|
25
roles/shell/templates/bashrc.sh.j2
Normal file
25
roles/shell/templates/bashrc.sh.j2
Normal file
@@ -0,0 +1,25 @@
|
||||
case $- in
|
||||
*i*) ;;
|
||||
*) return;;
|
||||
esac
|
||||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
shopt -s histappend checkwinsize globstar
|
||||
HISTFILESIZE=42069
|
||||
HISTSIZE=42069
|
||||
#PS1='${debian_chroot:+($debian_chroot)}{{ bash_prompt }} '
|
||||
PS1='{{ bash_prompt }} '
|
||||
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
|
||||
[ -f ~/.aliases ] && . ~/.aliases
|
||||
[ -f ~/.env ] && . ~/.env
|
||||
|
||||
if ! shopt -oq posix; then
|
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
elif [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
fi
|
15
roles/shell/templates/zshrc.zsh.j2
Normal file
15
roles/shell/templates/zshrc.zsh.j2
Normal file
@@ -0,0 +1,15 @@
|
||||
[[ $- != *i* ]] && return
|
||||
|
||||
PROMPT="{{ zsh_prompt }} "
|
||||
setopt autocd extendedglob nomatch notify prompt_subst
|
||||
autoload -Uz compinit && compinit
|
||||
unsetopt beep
|
||||
bindkey -v
|
||||
|
||||
[ -e ~/.zstyles ] && source ~/.zstyles
|
||||
[ -e ~/.env ] && source ~/.env
|
||||
|
||||
for src in `/bin/ls ~/.zshrc.d`; do
|
||||
[ -e $src ] && source $src
|
||||
done
|
||||
source ~/.zshrc.d/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
Reference in New Issue
Block a user