Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check to make sure History is enabled. #10

Open
rcaloras opened this issue Jun 28, 2015 · 4 comments
Open

Check to make sure History is enabled. #10

rcaloras opened this issue Jun 28, 2015 · 4 comments

Comments

@rcaloras
Copy link
Owner

Several history features should be checked or enabled to make sure bash-preexec can operate correctly.

One example is simply making sure history is turned on.

history_check=$(set -o | grep history)
if [[ "$history_check" == "history off" ]]; then
   echo "Enable history to use bash preexec"
   return 1
fi;

Quoted by @evverx on #6 :

@rcaloras , thanks.
Could probably add a few more checks to make sure history is properly enabled

Too many checks: history on, HISTSIZE, history-size in ~/.inputrc...

I vote for auto enabling:)

I've collected some useful settings:

# enable access to the command history
set -o history

# save each line of a multi-line command in the same history entry
shopt -s cmdhist

# save the command with embedded newlines instead of semicolons
shopt -s lithist

# save lines which begin with a space character in the history list
# preserve dups!
HISTCONTROL= # already done

# save all lines in the history list
HISTIGNORE=

# every command being saved on the history list (there is no limit)
HISTSIZE=-1
bind 'set history-size -1'
@evverx
Copy link
Contributor

evverx commented Jun 29, 2015

See also: my bulletproof history collector :)

@mtesseracted
Copy link

What about if HISTCONTROL or HISTTIMEFORMAT is already set and a user has scripts that need those already set settings? I didn't see anything in the README that says it will overwrite user defined settings. I just found this repo and didn't look closely enough if it will check before overwriting but I don't think it checks.

@gaelicWizard
Copy link
Contributor

I vote very much against automatically and silently changing user settings. If a condition can't be worked around, then warn loudly before tweaking.

@rcaloras, is the purpose of the history check specifically just to make sure preexec runs once-per-interactive-line (rather than DEBUG per simple command)?

@gaelicWizard
Copy link
Contributor

I answered my own question by re-rereading and I have a separate PR open, so please disregard my comments here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants