summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@fretlink.com>2018-11-18 13:14:33 +0100
committerIsmaël Bouya <ismael.bouya@fretlink.com>2018-11-18 13:20:49 +0100
commit853c14457ef51fbca58f9c4fb5c1a255e68d7c87 (patch)
tree28d3760ae94b3c13942d71ac75bf65b985f1dd3c /roles
parent1a48017dde54325c5619f45f925478e7c3143ba8 (diff)
downloadAnsible-853c14457ef51fbca58f9c4fb5c1a255e68d7c87.tar.gz
Ansible-853c14457ef51fbca58f9c4fb5c1a255e68d7c87.tar.zst
Ansible-853c14457ef51fbca58f9c4fb5c1a255e68d7c87.zip
Make bash xdg-compliant
Diffstat (limited to 'roles')
-rw-r--r--roles/init/tasks/main.yml1
-rw-r--r--roles/init/templates/pam_environment.j23
-rw-r--r--roles/shell/bash/files/inputrc7
-rw-r--r--roles/shell/bash/tasks/main.yml12
-rw-r--r--roles/shell/bash/templates/bash_profile.j24
-rw-r--r--roles/shell/bash/templates/bashrc.j220
6 files changed, 36 insertions, 11 deletions
diff --git a/roles/init/tasks/main.yml b/roles/init/tasks/main.yml
index a52f3cd..e60bb2a 100644
--- a/roles/init/tasks/main.yml
+++ b/roles/init/tasks/main.yml
@@ -9,7 +9,6 @@
9 - "$XDG_STATE_HOME/bash" 9 - "$XDG_STATE_HOME/bash"
10 - "$XDG_DATA_HOME" 10 - "$XDG_DATA_HOME"
11 - "$XDG_CACHE_HOME" 11 - "$XDG_CACHE_HOME"
12 - "$HOME/Desktop"
13 - "$HOME/Downloads" 12 - "$HOME/Downloads"
14- name: Get gnupg runtime folder name 13- name: Get gnupg runtime folder name
15 shell: 'GNUPGHOME=$XDG_CONFIG_HOME/gnupg gpgconf --list-dirs socketdir | sed -e "s@$XDG_RUNTIME_DIR/gnupg/@@"' 14 shell: 'GNUPGHOME=$XDG_CONFIG_HOME/gnupg gpgconf --list-dirs socketdir | sed -e "s@$XDG_RUNTIME_DIR/gnupg/@@"'
diff --git a/roles/init/templates/pam_environment.j2 b/roles/init/templates/pam_environment.j2
index 5bb8895..c257045 100644
--- a/roles/init/templates/pam_environment.j2
+++ b/roles/init/templates/pam_environment.j2
@@ -19,6 +19,9 @@ BROWSER DEFAULT="firefox"
19# replace GIO with xdg-open, see tools/files/gio_unwrapper.sh 19# replace GIO with xdg-open, see tools/files/gio_unwrapper.sh
20GIO_LAUNCH_DESKTOP DEFAULT=gio_unwrapper 20GIO_LAUNCH_DESKTOP DEFAULT=gio_unwrapper
21 21
22# Readline
23INPUTRC DEFAULT="${XDG_CONFIG_HOME}/inputrc"
24
22# Ansible 25# Ansible
23ANSIBLE_CONFIG DEFAULT="${XDG_CONFIG_HOME}/ansible/ansible.cfg" 26ANSIBLE_CONFIG DEFAULT="${XDG_CONFIG_HOME}/ansible/ansible.cfg"
24 27
diff --git a/roles/shell/bash/files/inputrc b/roles/shell/bash/files/inputrc
new file mode 100644
index 0000000..111f8dd
--- /dev/null
+++ b/roles/shell/bash/files/inputrc
@@ -0,0 +1,7 @@
1$include /etc/inputrc
2# Readline configuration
3# Can also be specified in bashrc with: bind "..."
4set colored-completion-prefix on
5# TAB: menu-complete
6set show-all-if-ambiguous on
7set show-all-if-unmodified on
diff --git a/roles/shell/bash/tasks/main.yml b/roles/shell/bash/tasks/main.yml
index d74421a..6bf3859 100644
--- a/roles/shell/bash/tasks/main.yml
+++ b/roles/shell/bash/tasks/main.yml
@@ -1,12 +1,20 @@
1--- 1---
2- name: Create config dir
3 file:
4 path: $XDG_CONFIG_HOME/bash
5 state: directory
2- name: Add bashrc config 6- name: Add bashrc config
3 template: 7 template:
4 src: bashrc.j2 8 src: bashrc.j2
5 dest: $HOME/.bashrc 9 dest: $XDG_CONFIG_HOME/bash/bashrc
6- name: Add bash_profile config 10- name: Add bash_profile config
7 template: 11 template:
8 src: bash_profile.j2 12 src: bash_profile.j2
9 dest: $HOME/.bash_profile 13 dest: $XDG_CONFIG_HOME/bash/bash_profile
14- name: Add inputrc config
15 copy:
16 src: inputrc
17 dest: $XDG_CONFIG_HOME/inputrc
10- name: Create bash state dir 18- name: Create bash state dir
11 file: 19 file:
12 path: $XDG_STATE_HOME/bash 20 path: $XDG_STATE_HOME/bash
diff --git a/roles/shell/bash/templates/bash_profile.j2 b/roles/shell/bash/templates/bash_profile.j2
index 8ffd818..4bcd09c 100644
--- a/roles/shell/bash/templates/bash_profile.j2
+++ b/roles/shell/bash/templates/bash_profile.j2
@@ -1,6 +1,8 @@
1# Some variables are loaded via pam (see .config/pam_environment) 1# Some variables are loaded via pam (see .config/pam_environment)
2# This file is loaded thanks to as line in /etc/profile
3# test "$BASH" && test -r "$XDG_CONFIG_HOME/bash/bash_profile" && . $XDG_CONFIG_HOME/bash/bash_profile
2 4
3[[ -f ~/.bashrc ]] && . ~/.bashrc 5[[ -f $XDG_CONFIG_HOME/bash/bashrc ]] && . $XDG_CONFIG_HOME/bash/bashrc
4{% if "graphical_vt" in features.get(profile, []) %} 6{% if "graphical_vt" in features.get(profile, []) %}
5 7
6if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then 8if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2
index 08518c9..b717f0e 100644
--- a/roles/shell/bash/templates/bashrc.j2
+++ b/roles/shell/bash/templates/bashrc.j2
@@ -27,7 +27,7 @@ alias mv="mv -i"
27alias cp="cp -i" 27alias cp="cp -i"
28alias rm="rm -i" 28alias rm="rm -i"
29alias psp="pstree -aUp $USER" 29alias psp="pstree -aUp $USER"
30alias dotdrop="dotdrop --cfg $XDG_CONFIG_HOME/dotdrop/config.yaml" 30alias info='info -v active-link-style=yellow,bold -v link-style=yellow'
31 31
32[[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash 32[[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash
33 33
@@ -125,6 +125,7 @@ function git_prompt() {
125 echo -e "($gitinfo) " 125 echo -e "($gitinfo) "
126 fi 126 fi
127} 127}
128{% set ps1_git = '\[$(git_prompt_color)\]$(git_prompt)' %}
128 129
129function error_code() { 130function error_code() {
130 ret=$? 131 ret=$?
@@ -139,14 +140,19 @@ function running_jobs() {
139 echo "[$ret] " 140 echo "[$ret] "
140 fi 141 fi
141} 142}
143{% set ps1_status = '\[\\033[01;31m\]$(error_code)\[\\033[00;00m\]$(running_jobs)' -%}
142 144
143{% if role.get(profile) == "fretlink" %} 145{# Ensure new line before the prompt #}
144PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[\033[01;32m\]$(dev_prompt)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] ' 146{% set ps1_newline = '$(printf "%$((`tput cols`-1))s\\r")' -%}
145{% else %} 147
146PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] ' 148{% set ps1_other = '' %}
147{% endif %} 149{% if role.get(profile) == "fretlink" -%}
150 {% set ps1_other = '\[\\033[01;32m\]$(dev_prompt)' %}
151{%- endif %}
152
153PS1='{{ ps1_newline }}{{ ps1_status }}{{ ps1_other }}{{ ps1_git }}\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] '
148 154
149PROMPT_COMMAND="[[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && . $XDG_STATE_HOME/bash/bashrc_temp" 155PROMPT_COMMAND="[[ -f $XDG_STATE_HOME/bash/bashrc_temp ]] && . $XDG_STATE_HOME/bash/bashrc_temp"
150 156
151{% if "nodejs" in features.get(profile, []) %} 157{% if "nodejs" in features.get(profile, []) %}
152source /usr/share/nvm/init-nvm.sh 158source /usr/share/nvm/init-nvm.sh