diff --git a/bundles/users/files/bashrc b/bundles/users/files/bashrc new file mode 100644 index 0000000..4c4446a --- /dev/null +++ b/bundles/users/files/bashrc @@ -0,0 +1,26 @@ +[ -z "$PS1" ] && return + +__node_name="${node.name}" + +<%text> +if [[ "$(id -u)" -eq 0 ]] +then + export PS1='\[\e[1;34m\][\[\e[1;32m\]'"$__node_name"'\[\e[1;34m\]][\[\e[1;32m\]\u\[\e[1;34m\]@\[\e[1;32m\]\w\[\e[1;34m\]] $PRODWARNING> \[\e[0m\]' +else + export PS1='\[\e[1;0m\]['"$__node_name"'][\u@\w]\[\e[1;34m\] $PRODWARNING\[\e[1;0m\]> ' +fi +case $TERM in + xterm*|rxvt*) + export PROMPT_COMMAND='echo -ne "\a\e]0;'"$__node_name"':${PWD/$HOME/~}\a"' + ;; + screen*) + export PROMPT_COMMAND='echo -ne "\a\ek'"$__node_name"':${PWD/$HOME/~}\e\\"' + ;; + *) + unset PROMPT_COMMAND + ;; +esac + +uptime +last | grep 'still logged in' + diff --git a/bundles/users/files/config.fish b/bundles/users/files/config.fish new file mode 100644 index 0000000..ddf576b --- /dev/null +++ b/bundles/users/files/config.fish @@ -0,0 +1,23 @@ +function fish_greeting + uptime + last | grep 'still logged in' +end + +function fish_prompt + set -l last_status $status + + echo -n "$USER@${node.name}:" + + set_color $fish_color_cwd + echo -n (pwd) + set_color normal + + if not test $last_status -eq 0 + set_color $fish_color_error + echo -n " [$status]" + set_color normal + end + + echo -n '➤ ' + set_color normal +end diff --git a/bundles/users/items.py b/bundles/users/items.py index 7e954aa..444f844 100644 --- a/bundles/users/items.py +++ b/bundles/users/items.py @@ -14,6 +14,11 @@ users['root'] = { 'password': repo.vault.human_password_for('root on {}'.format(node.name)), } +files['/etc/bash.bashrc'] = { + 'source': 'bashrc', + 'content_type': 'mako', +} + for username, attrs in node.metadata['users'].items(): home = attrs.get('home', '/home/{}'.format(username)) @@ -46,3 +51,12 @@ for username, attrs in node.metadata['users'].items(): else: files[home + '/.ssh/authorized_keys'] = {'delete': True} + files[home + '/.config/fish/config.fish'] = { + 'content_type': 'mako', + } + + +for user, config in users.items(): + files[config['home'] + '/.bashrc'] = { + 'delete': True, + }