|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +echo "Activating feature 'terminal-history'" |
| 5 | +echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" |
| 6 | + |
| 7 | +mkdir -p $CONFIG_STAGING |
| 8 | + |
| 9 | +# ------------------------------------------------------------------------------- |
| 10 | +cat > $CONFIG_STAGING/onCreateCommand.sh \ |
| 11 | +<< EOF |
| 12 | +#!/bin/bash |
| 13 | +
|
| 14 | +# copy in the opinionated default settings from the feature |
| 15 | +cp $CONFIG_STAGING/feature_settings_rc $CONFIG_FOLDER/feature_settings_rc |
| 16 | +
|
| 17 | +# copy in the user editable settings unless they already exist |
| 18 | +if [[ ! -f $CONFIG_FOLDER/bashrc ]] ; then |
| 19 | + cp $CONFIG_STAGING/bashrc $CONFIG_FOLDER |
| 20 | + cp $CONFIG_STAGING/inputrc $CONFIG_FOLDER |
| 21 | +fi |
| 22 | +
|
| 23 | +# hook in the config to the root account |
| 24 | +ln -s $CONFIG_FOLDER/inputrc /root/.inputrc |
| 25 | +echo "source $CONFIG_FOLDER/bashrc" >> /root/.bashrc |
| 26 | +EOF |
| 27 | + |
| 28 | +# ------------------------------------------------------------------------------- |
| 29 | +cat > $CONFIG_STAGING/inputrc \ |
| 30 | +<< EOF |
| 31 | +# Readline configuration for bash shell. |
| 32 | +
|
| 33 | +# Incremental history searching with up and down arrows (C-P and C-N for old |
| 34 | +# style navigation). |
| 35 | +"\e[A": history-search-backward |
| 36 | +"\e[B": history-search-forward |
| 37 | +
|
| 38 | +# Control left and right for word movement |
| 39 | +"\e[5C": forward-word |
| 40 | +"\e[5D": backward-word |
| 41 | +EOF |
| 42 | + |
| 43 | +# ------------------------------------------------------------------------------- |
| 44 | +cat > $CONFIG_STAGING/bashrc \ |
| 45 | +<< EOF |
| 46 | +#!/bin/bash |
| 47 | +
|
| 48 | +# execute default opinionated settings - delete this line to remove defaults |
| 49 | +source $CONFIG_FOLDER/feature_settings_rc |
| 50 | +
|
| 51 | +# add your personal custom settings below |
| 52 | +EOF |
| 53 | + |
| 54 | +# ------------------------------------------------------------------------------- |
| 55 | +cat > $CONFIG_STAGING/feature_settings_rc \ |
| 56 | +<< EOF |
| 57 | +#!/bin/bash |
| 58 | +
|
| 59 | +# default opinioned bash configuration |
| 60 | +
|
| 61 | +# set the prompt |
| 62 | +export PS1="\[\033[1;34m\]\W \[\033[0m\]# " |
| 63 | +
|
| 64 | +# enable enternal shared history |
| 65 | +export HISTCONTROL=ignoreboth:erasedups |
| 66 | +export HISTFILESIZE=-1 |
| 67 | +export SAVEHIST=-1 |
| 68 | +export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history |
| 69 | +PROMPT_COMMAND="history -a; $PROMPT_COMMAND" |
| 70 | +EOF |
0 commit comments