]> git.immae.eu Git - perso/Immae/Config/Ansible.git/commitdiff
Move bashrc temporary file to state dir
authorIsmaël Bouya <ismael.bouya@fretlink.com>
Tue, 13 Nov 2018 00:01:36 +0000 (01:01 +0100)
committerIsmaël Bouya <ismael.bouya@fretlink.com>
Tue, 13 Nov 2018 00:01:36 +0000 (01:01 +0100)
roles/init/tasks/main.yml
roles/shell/bash/templates/bash_profile.j2
roles/shell/bash/templates/bashrc.j2

index ce56ec4f7104ce4f3781757b58291bba135de46b..a52f3cdd250c38fdfec12b89234b4e736f4136d3 100644 (file)
@@ -1,4 +1,16 @@
 ---
+- name: Create XDG dirs
+  file:
+    path: "{{ item }}"
+    state: directory
+  loop:
+    - "$XDG_CONFIG_HOME"
+    - "$XDG_STATE_HOME"
+    - "$XDG_STATE_HOME/bash"
+    - "$XDG_DATA_HOME"
+    - "$XDG_CACHE_HOME"
+    - "$HOME/Desktop"
+    - "$HOME/Downloads"
 - name: Get gnupg runtime folder name
   shell: 'GNUPGHOME=$XDG_CONFIG_HOME/gnupg gpgconf --list-dirs socketdir | sed -e "s@$XDG_RUNTIME_DIR/gnupg/@@"'
   changed_when: false
@@ -12,7 +24,7 @@
 - name: Remove old lines in bashrc_temp
   lineinfile:
     line: "{{ ('unset ' ~ item | regex_replace('=.*')) if item != '' and item.0 != '#' else '' }}"
-    dest: $HOME/.bashrc_temp
+    dest: $XDG_STATE_HOME/bash/bashrc_temp
     insertafter: EOF
     create: true
     state: present
@@ -21,7 +33,7 @@
 - name: Add new lines in bashrc_temp
   lineinfile:
     line: "{{ ('export ' ~ item) if item != '' and item.0 != '#' else '' }}"
-    dest: $HOME/.bashrc_temp
+    dest: $XDG_STATE_HOME/bash/bashrc_temp
     insertafter: EOF
     create: true
     state: present
   when: pam_environment.changed
   debug:
     msg: "\u26A0\uFE0F \u26A0\uFE0F  You need to log out and back in to update your environment \u26A0\uFE0F \u26A0\uFE0F"
-- name: Create XDG dirs
-  file:
-    path: "{{ item }}"
-    state: directory
-  loop:
-    - "$XDG_CONFIG_HOME"
-    - "$XDG_STATE_HOME"
-    - "$XDG_DATA_HOME"
-    - "$XDG_CACHE_HOME"
-    - "$HOME/Desktop"
-    - "$HOME/Downloads"
index 9b9e86c9df32bdbe80ab15988e9f14d241d146a2..8ffd818a57714441b94cc3d66afdf2da5e1db44e 100644 (file)
@@ -4,7 +4,7 @@
 {% if "graphical_vt" in features.get(profile, []) %}
 
 if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
-  [[ -f "$HOME/.bashrc_temp" ]] && rm -f $HOME/.bashrc_temp
+  [[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && rm -f $XDG_STATE_HOME/bash/bashrc_temp
   exec startx $XDG_CONFIG_HOME/xinitrc > $XDG_STATE_HOME/xsession_errors 2>&1
 fi
 {% endif %}
index fff19f762624f64731767fdc92db6c4f8de0d8a4..91334b735225dc28871d9604e50295011dda5901 100644 (file)
@@ -2,7 +2,7 @@
 # ~/.bashrc
 #
 
-[[ -f "$HOME/.bashrc_temp" ]] && . $HOME/.bashrc_temp
+[[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && . $XDG_STATE_HOME/bash/bashrc_temp
 
 if [ -n "$HOME/.local/bin" ]; then
   PATH="$HOME/.local/bin:$PATH"
@@ -137,6 +137,8 @@ PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[\033[01;32m\]$(
 PS1='\[\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\] '
 {% endif %}
 
+PROMPT_COMMAND="[[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && . $XDG_STATE_HOME/bash/bashrc_temp"
+
 {% if "nodejs" in features.get(profile, []) %}
 source /usr/share/nvm/init-nvm.sh
 {% endif %}