pawamoy / shell-history

Visualize your shell usage with Highcharts!
ISC License
112 stars 2 forks source link

event not found: -0 #20

Closed sirfoga closed 5 years ago

sirfoga commented 5 years ago

my system

$ uname -a Linux novo 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ zsh --version zsh 5.4.2 (x86_64-ubuntu-linux-gnu)

my problem

when I open a shell (e.g gnome-terminal) 3 errors appear:

_shellhistory_last_command:fc:2: event not found: -0                            
_shellhistory_last_command_number:fc:1: event not found: -0
_shellhistory_last_command:fc:2: event not found: -0

I can keep using my shell, but no command data is logged.

solution

my solution

this PR

the question

why does fc not work with arg -0 ? Is there a problem with my shell setup?

@pawamoy thanks for your work

pawamoy commented 5 years ago

So indeed it seems that fc -lnr -0 does not work on zsh. But using -1 is not right either, because it gives the last command, not the one that is about to be executed.

It seems the behavior differs from Bash to Zsh: https://stackoverflow.com/questions/25295186/access-to-last-command-in-zsh-not-previous-command-line

A solution could be to use echo $history[$HISTCMD] instead of the fc command. I'm gonna run some tests and report back :slightly_smiling_face:

pawamoy commented 5 years ago

I think I have a working solution now. Could you discard your PR #21 as it contains fixes for two issues? I'm gonna open a new one to fix issue #20, so you can review it if you like.

You can also re-open a new PR containing just the fix for #22 (which I think will need just one or two small changes :slightly_smiling_face:)

sirfoga commented 5 years ago

yess, I've tried it (briefly) and it actually seems to be working :)

pawamoy commented 5 years ago

Solved by #23!