From 7f6e45f8411b3826b03026f676a1a57d6beee171 Mon Sep 17 00:00:00 2001 From: Tunui Franken Date: Fri, 29 Nov 2024 17:04:48 +0100 Subject: [PATCH] Add bashrc --- roles/common/tasks/main.yml | 11 +++++++++++ roles/common/templates/bash_aliases.j2 | 13 ++++++++++--- roles/common/templates/bashrc.j2 | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 roles/common/templates/bashrc.j2 diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index ccb88f1..0fc7a1d 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -26,6 +26,17 @@ mode: "644" when: (item.value | last) == '/bin/bash' +- name: Copy bashrc for accounts using bash + become: true + loop: "{{ ansible_facts.getent_passwd | dict2items }}" + ansible.builtin.template: + src: bashrc.j2 + dest: "{{ item.value.4 }}/.bashrc" + owner: "{{ item.key }}" + group: "{{ item.key }}" + mode: "644" + when: (item.value | last) == '/bin/bash' + - name: Setup etckeeper ansible.builtin.include_role: name: etckeeper diff --git a/roles/common/templates/bash_aliases.j2 b/roles/common/templates/bash_aliases.j2 index d1cf6f7..de05892 100644 --- a/roles/common/templates/bash_aliases.j2 +++ b/roles/common/templates/bash_aliases.j2 @@ -2,6 +2,13 @@ eval "$(dircolors)" -alias ll='ls --color=auto -lArth' -alias la='ls --color=auto -A' -alias l='ls --color=auto -CF' +alias ls='ls --color=auto' +alias ll='ls -lArth' +alias la='ls -A' +alias l='ls -CF' + +alias grep='grep --color=auto' +alias ip='ip --color=auto' +alias diff='diff --color=auto' + +alias rm='rm -I --preserve-root' diff --git a/roles/common/templates/bashrc.j2 b/roles/common/templates/bashrc.j2 new file mode 100644 index 0000000..76e529c --- /dev/null +++ b/roles/common/templates/bashrc.j2 @@ -0,0 +1,17 @@ +# {{ ansible_managed }} + +HISTCONTROL=ignoreboth # don't put duplicate lines or lines starting with space in the history. +shopt -s histappend # append to the history file, don't overwrite it +HISTSIZE=10000 +HISTFILESIZE=10000 +stty -ixon # Disable Ctrl-S and Ctrl-Q + +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 + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi