Hi all,
For preserving eternal bash history commands typed by myself, I created
the following script named as bash_eternal_history.sh which is located in
~/.profile.d. The content of ~/.profile.d/bash_eternal_history.sh is as
follows:
------------
#!/bin/bash
export history_dir=${HOME}
run_on_prompt_command()
{
local HISTTIMEFORMAT="[%F %T] "
[[
$(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$
]]
local date_command_part="${BASH_REMATCH[0]}"
local date_part="${BASH_REMATCH[1]}"
local command_part="${BASH_REMATCH[2]}"
if [ "$command_part" != "$PERSISTENT_HISTORY_LAST_ME" ]
then
echo $$ $USER "$(history 1)" >> "$history_dir"/.bash_eternal_history
PERSISTENT_HISTORY_LAST_ME="$command_part"
fi
}
export -f run_on_prompt_command
export PROMPT_COMMAND="run_on_prompt_command"
bhgrep() { awk 'sub(/([^ ]+ +){5}/,"") && !a[$0]++'
"$history_dir"/.bash_eternal_history |grep -E --color "$@" ; }
export -f bhgrep
------------
Then I appened the following contents to ~/.profile:
----------
if [ -d $HOME/.profile.d ]; then
for i in $HOME/.profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
----------
Now I logout and re-login, my pc just gets stuck at login prompt -
showing it over and over again.
Why does this happen? How to solve this issue?
Regards
--
.: Hongyi Zhao [ hongyi.zhao AT
gmail.com ] Free as in Freedom :.