update role
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# No bash
|
||||
[ -n "${BASH_VERSION:-}" ] || exit 0
|
||||
|
||||
# Not an interactive session
|
||||
[[ $- == *i* ]] || exit 0
|
||||
|
||||
# History size in Memory and File
|
||||
export HISTSIZE=1000
|
||||
export HISTFILESIZE=50000
|
||||
|
||||
# append to history instead overwriting (e.g. multiple people on the same with same user at same time)
|
||||
shopt -s histappend
|
||||
# ignore duplicates and the ones starting with space
|
||||
export HISTCONTROL=ignoreboth
|
||||
# some additional commands to ignore
|
||||
export HISTIGNORE='ls:ll:ls -lah:pwd:clear:exit:history'
|
||||
# History Time format
|
||||
export HISTTIMEFORMAT='%F %T '
|
||||
# Split multiple commands from one line to multiple history entries
|
||||
shopt -s cmdhist
|
||||
# Append history lines, clear and reload history, then print the prompt command
|
||||
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
|
||||
@@ -0,0 +1,40 @@
|
||||
function set_bash_prompt () {
|
||||
# Color codes for easy prompt building
|
||||
COLOR_DIVIDER="\[\e[30;1m\]"
|
||||
COLOR_CMDCOUNT="\[\e[34;1m\]"
|
||||
COLOR_USERNAME="\[\e[34;1m\]"
|
||||
COLOR_USERHOSTAT="\[\e[34;1m\]"
|
||||
COLOR_HOSTNAME="\[\e[34;1m\]"
|
||||
COLOR_GITBRANCH="\[\e[33;1m\]"
|
||||
COLOR_VENV="\[\e[33;1m\]"
|
||||
COLOR_GREEN="\[\e[32;1m\]"
|
||||
COLOR_PATH_OK="\[\e[32;1m\]"
|
||||
COLOR_PATH_ERR="\[\e[31;1m\]"
|
||||
COLOR_NONE="\[\e[0m\]"
|
||||
# Change the path color based on return value.
|
||||
if test $? -eq 0 ; then
|
||||
PATH_COLOR=${COLOR_PATH_OK}
|
||||
else
|
||||
PATH_COLOR=${COLOR_PATH_ERR}
|
||||
fi
|
||||
# Set the PS1 to be "[workingdirectory:commandcount"
|
||||
PS1="${COLOR_DIVIDER}[${PATH_COLOR}\w${COLOR_DIVIDER}:${COLOR_CMDCOUNT}\#${COLOR_DIVIDER}"
|
||||
# Add git branch portion of the prompt, this adds ":branchname"
|
||||
if ! git_loc="$(type -p "$git_command_name")" || [ -z "$git_loc" ]; then
|
||||
# Git is installed
|
||||
if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
||||
# Inside of a git repository
|
||||
GIT_BRANCH=$(git symbolic-ref --short HEAD)
|
||||
PS1="${PS1}:${COLOR_GITBRANCH}${GIT_BRANCH}${COLOR_DIVIDER}"
|
||||
fi
|
||||
fi
|
||||
# Add Python VirtualEnv portion of the prompt, this adds ":venvname"
|
||||
if ! test -z "$VIRTUAL_ENV" ; then
|
||||
PS1="${PS1}:${COLOR_VENV}`basename \"$VIRTUAL_ENV\"`${COLOR_DIVIDER}"
|
||||
fi
|
||||
# Close out the prompt, this adds "]\n[username@hostname] "
|
||||
PS1="${PS1}]\n${COLOR_DIVIDER}[${COLOR_USERNAME}\u${COLOR_USERHOSTAT}@${COLOR_HOSTNAME}\h${COLOR_DIVIDER}]${COLOR_NONE} "
|
||||
}
|
||||
|
||||
# Tell Bash to run the above function for every prompt
|
||||
export PROMPT_COMMAND=set_bash_prompt
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Copy bash config files
|
||||
ansible.builtin.copy:
|
||||
src: ../files/profile.d/*
|
||||
dest: /etc/profile.d/
|
||||
become: true
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- name: Improve bash setup
|
||||
include_tasks: improved-bash.yml
|
||||
Reference in New Issue
Block a user