Hiset – Multiple history file’s and sessions for bash and other tinkering

Generally i use several terminals at the same time, generally one per project or task, i’ve always been annoyed that i either loose history or it becomes hard to find so i created hiset (history set) pronounced hi-set. It allows you to easily assign a history per shell sessions and then manage the multiple history files . Hiset works by modifying the HISFILE environment variable meaning that the history command works as usual within the session.

Using hiset

Installation is simple get a copy of the hiset.sh file from https://github.com/simotek/scripts-config then source it in your .bashrc or /etc/profile.d/:

source hiset.sh

below is the output for “hiset -s git” it shows i have several history files with git in them, there is some other screenshots at the bottom
Searching through hiset's history


It also has a HISET environment variable that you can add to your prompt with:

PS1="$PS1 $(echo $HISET)"

I’ve been tinkering with prompts in bash over the last few weeks as well and mine is now considerably more advanced its based off http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt
which has some cool git integration.

  • Hiset – Multiple history file’s and sessions for bash and other tinkering
    • Fred Jackson
    • June 27th, 2014

    Hiset – what a dandy utility! Extremely useful. I was distressed to find it didn’t work in bash on FreeBSD because of FreeBSD’s crude version of getopt. Here is my hack that that allows it to work – replace the only line containing “getopt” with:

    # This hack by fnj to deal with BSD getopt not being able to deal with long options
    # In BSD you must either “pkg add getopt”, or build and install /usr/ports/misc/getopt
    # This adds /usr/local/bin/getopt but leaves /usr/bin/getopt in place
    # Normally /usr/bin will come first in PATH, so /usr/local/bin/getopt will never be used
    # Hence the hack
    # In linux this does no harm unless you have a rogue version of getopt in /usr/local/bin
    if [ -f /usr/local/bin/getopt ] ; then
    OPTS=`/usr/local/bin/getopt -o :D:hHlrs: -l delete:,help,history,History,list,reset,search: — “$@”`
    OPTS=`getopt -o :D:hHlrs: -l delete:,help,history,History,list,reset,search: — “$@”`

    Hopefully you can come up with a better fix, but if not, feel free to incorporate my hack, but document the prerequisite!

      • admin
      • June 27th, 2014

      Thanks for the Report + Patch, i modified it slightly to firstly use $OSTYPE to only apply the patch to bsd systems and with that if the version of getopt you suggested wasn’t in the path it disables short options.
      I have pushed the change to github if you could test it that would be fantastic.

  1. No trackbacks yet.

Return top