From b52d5f4b289fecca30b228b5cb19fff2fd0151be Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 15 Oct 2022 18:41:10 +0900 Subject: [PATCH 1/2] add: fish: function to save custom history file --- dotfiles/fish/config.fish | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index 09b6f19..921ed94 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -16,9 +16,17 @@ if status is-interactive set -x SHELL bash # opam - # source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true + source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true end # key bindings -bind \b backward-kill-word \ No newline at end of file +bind \b backward-kill-word + +# save fish log to my custom file +set -gx my_fish_history "$HOME/my_fish_history.txt" +function save_myhistory --on-event fish_prompt -d "Save custom shell log to $my_fish_history" + echo "$(date '+%Y-%m-%d %H:%M:%S') $hostname:$fish_pid $PWD [$status] $(history -1)" \ + >> $my_fish_history +end + From d68e0833dbdafd089a3129f172f0ba8877fa1859 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 15 Oct 2022 19:53:14 +0900 Subject: [PATCH 2/2] fix: fish: exit status logging of my custom history file --- dotfiles/fish/config.fish | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index 921ed94..aabc101 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -26,7 +26,8 @@ bind \b backward-kill-word # save fish log to my custom file set -gx my_fish_history "$HOME/my_fish_history.txt" function save_myhistory --on-event fish_prompt -d "Save custom shell log to $my_fish_history" - echo "$(date '+%Y-%m-%d %H:%M:%S') $hostname:$fish_pid $PWD [$status] $(history -1)" \ + set -l prev_status $status + echo "$(date '+%Y-%m-%d %H:%M:%S') $hostname:$fish_pid $PWD [$prev_status] $(history -1)" \ >> $my_fish_history end