I have created two functions that would be interesting to have ported as plugins. One is a precision calculator directly from the prompt (ex. running 3*(1/2) returns 1.5 instead of expanding globbing and command substitution), and the other corrects automatically on the fish_command_not_found event.
Now, both of them write to the history file, and would benefit greatly from a history insert command. I'm currently using the following:
if set -q XDG_DATA_HOME
set __fish_history $XDG_DATA_HOME/fish/fish_history
else
set __fish_history ~/.local/share/fish/fish_history
end
echo -e '- cmd: '(commandline)'\n when: '(date +%s) >>$__fish_history
history --merge
The problem with this approach is that commandline is written to the history file as is (without considering newlines, without escaping special characters, etc.) and, of course, history --merge brings the undesired side-effect of merging history from all other sessions.
I have created two functions that would be interesting to have ported as plugins. One is a precision calculator directly from the prompt (ex. running
3*(1/2)returns1.5instead of expanding globbing and command substitution), and the other corrects automatically on the fish_command_not_found event.Now, both of them write to the history file, and would benefit greatly from a
history insertcommand. I'm currently using the following:The problem with this approach is that
commandlineis written to the history file as is (without considering newlines, without escaping special characters, etc.) and, of course,history --mergebrings the undesired side-effect of merging history from all other sessions.