mirror of
https://github.com/ddworken/hishtory.git
synced 2025-01-23 06:38:52 +01:00
Add the testing fish config
This commit is contained in:
parent
abe231f5b0
commit
db4295e745
@ -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)
|
||||||
|
18
client/lib/test_config.fish
Normal file
18
client/lib/test_config.fish
Normal 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
|
Loading…
Reference in New Issue
Block a user