.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "FISH_SHOULD_ADD_TO_HISTORY" "1" "Nov 13, 2025" "4.2" "fish-shell" .SH NAME fish_should_add_to_history \- decide whether a command should be added to the history .SH SYNOPSIS .nf \fBfish_should_add_to_history\fP .fi .sp .INDENT 0.0 .INDENT 3.5 .sp .EX function fish_should_add_to_history ... end .EE .UNINDENT .UNINDENT .SH DESCRIPTION .sp The \fBfish_should_add_to_history\fP function is executed before fish adds a command to history, and its return status decides whether that is done. .sp If it returns 0, the command is stored in history, when it returns anything else, it is not. In the latter case the command can still be recalled for one command. .sp The first argument to \fBfish_should_add_to_history\fP is the commandline. History is added \fIbefore\fP a command is run, so e.g. \fI\%status\fP can\(aqt be checked. This is so commands that don\(aqt finish like \fI\%exec \- execute command in current process\fP and long\-running commands are available in new sessions immediately. .sp If \fBfish_should_add_to_history\fP doesn\(aqt exist, fish will save a command to history unless it starts with a space. If it does exist, this function takes over all of the duties, so commands starting with space are saved unless \fBfish_should_add_to_history\fP says otherwise. .SH EXAMPLE .sp A simple example: .INDENT 0.0 .INDENT 3.5 .sp .EX function fish_should_add_to_history for cmd in vault mysql ls string match \-qr \(dq^$cmd\(dq \-\- $argv; and return 1 end return 0 end .EE .UNINDENT .UNINDENT .sp This refuses to store any immediate \(dqvault\(dq, \(dqmysql\(dq or \(dqls\(dq calls. Commands starting with space would be stored. .INDENT 0.0 .INDENT 3.5 .sp .EX function fish_should_add_to_history # I don\(aqt want \(gagit pull\(gas in my history when I\(aqm in a specific repository if string match \-qr \(aq^git pull\(aq \-\- \(dq$argv\(dq and string match \-qr \(dq^/home/me/my\-secret\-project/\(dq \-\- (pwd \-P) return 1 end return 0 end .EE .UNINDENT .UNINDENT .SH COPYRIGHT fish-shell developers .\" Generated by docutils manpage writer. .