Add the testing fish config

This commit is contained in:
David Dworken 2022-10-18 20:16:58 -07:00
parent abe231f5b0
commit db4295e745
2 changed files with 24 additions and 0 deletions

View File

@ -52,6 +52,9 @@ var TestConfigZshContents string
//go:embed config.fish //go:embed config.fish
var ConfigFishContents string var ConfigFishContents string
//go:embed test_config.fish
var TestConfigFishContents string
var Version string = "Unknown" var Version string = "Unknown"
// 256KB ought to be enough for any reasonable cmd // 256KB ought to be enough for any reasonable cmd
@ -559,6 +562,9 @@ func configureFish(homedir, binaryPath string) error {
// Create the file we're going to source. Do this no matter what in case there are updates to it. // Create the file we're going to source. Do this no matter what in case there are updates to it.
fishConfigPath := path.Join(homedir, shared.HISHTORY_PATH, "config.fish") fishConfigPath := path.Join(homedir, shared.HISHTORY_PATH, "config.fish")
configContents := ConfigFishContents configContents := ConfigFishContents
if os.Getenv("HISHTORY_TEST") != "" {
configContents = TestConfigFishContents
}
err = ioutil.WriteFile(fishConfigPath, []byte(configContents), 0o644) err = ioutil.WriteFile(fishConfigPath, []byte(configContents), 0o644)
if err != nil { if err != nil {
return fmt.Errorf("failed to write config.zsh file: %v", err) return fmt.Errorf("failed to write config.zsh file: %v", err)

View File

@ -0,0 +1,18 @@
function _hishtory_post_exec --on-event fish_postexec
# Runs after <ENTER>, but before the command is executed
set --global _hishtory_command $argv
set --global _hishtory_start_time (date +%s)
end
set --global _hishtory_first_prompt 1
function __hishtory_on_prompt --on-event fish_prompt
# Runs after the command is executed in order to render the prompt
# $? contains the exit code
set _hishtory_exit_code $status
if [ -n "$_hishtory_first_prompt" ]
set --global -e _hishtory_first_prompt
else if [ -n "$_hishtory_command" ]
hishtory saveHistoryEntry fish $_hishtory_exit_code "$_hishtory_command" $_hishtory_start_time
end
end