Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: An example of writing a custom history file?



On Dec 15,  2:09am, Rocky Bernstein wrote:
}
} Thanks for the pointer. That program is too complicated and there is too
} much going on for me to understand which parts add to the history file. I'm
} guessing it has something to do with the
} zle .push-line.

Well, no, it doesn't have anything to do with that at all.

} Here is the 138 line program boiled down to less than 10,  the parts I'd
} like to focus on:
} 
}     #!/usr/bin/zsh
}     fc -ap /tmp/example_history 1000
}     # Read lines and add them to history
}     local sticky
}     while vared -h -p "hey: "  sticky
}     do
}         print $sticky
}         sticky=''
}     done

You've missed the important bit, which is the -s option to print.  THAT
is what adds lines to the history.

I probably should have pointed you to the example zshaddhistory hook in
the documentation.

} Additionally what I would like to do in the body of the loop decide whether
} or not to add this to the history.

    # Pseudo-code
    if this_line should be added to the history
    then print -sR "$this_line"
    fi



Messages sorted by: Reverse Date, Date, Thread, Author