fish-history-to-zsh icon indicating copy to clipboard operation
fish-history-to-zsh copied to clipboard

`Parser.js` error on Node.js v10.16.0 and `[email protected]`

Open gabroo opened this issue 2 years ago • 4 comments

(base)  % node index.js > test                                                                                                                                                                  /tmp/fish-history-to-zsh (master ⚡) sajeevs

/tmp/fish-history-to-zsh/node_modules/yamljs/lib/Parser.js:404
            throw e;
            ^
Error: Unexpected characters near " \\}".

gabroo avatar Sep 26 '23 00:09 gabroo

after running

(base)  % nvm use                                                                                                                                                                               /tmp/fish-history-to-zsh (master ⚡) sajeevs
Found '/tmp/fish-history-to-zsh/.nvmrc' with version <v10.16.0>
Now using node v10.16.0 (npm v6.9.0)

also

(base)  % npm list                                                                                                                                                                              /tmp/fish-history-to-zsh (master ⚡) sajeevs
[email protected] /tmp/fish-history-to-zsh
└─┬ [email protected]
  ├─┬ [email protected]
  │ └── [email protected]
  └─┬ [email protected]
    ├── [email protected]
    ├─┬ [email protected]
    │ ├── [email protected] deduped
    │ └── [email protected]
    ├── [email protected]
    ├─┬ [email protected]
    │ └─┬ [email protected]
    │   ├── [email protected]
    │   └── [email protected]
    ├─┬ [email protected]
    │ └── [email protected] deduped
    └── [email protected]

gabroo avatar Sep 26 '23 00:09 gabroo

I'm inclined to believe that fish_history is not actually proper YAML. Running it through a parser netted me this error:

Error: bad file 'fish_history': yaml: line 262: mapping values are not allowed in this context

nick-at-dave avatar Sep 04 '24 17:09 nick-at-dave

Here's a quick command you can run in your terminal that will achieve the same thing:

grep -e "^- cmd: .*" $HOME/.local/share/fish/fish_history | awk '{print $3;}' >> ~/.zsh_history

nick-at-dave avatar Sep 04 '24 17:09 nick-at-dave

@nick-at-dave awk print $3 will ensure that just the first word in each command makes it into your destination zhistory you'd need to do something like this to capture the entire command

grep -e "^- cmd: .*" $HOME/.local/share/fish/fish_history | awk '{for(i=3; i<=NF; i++) printf "%s%s", $i, (i<NF?OFS:"\n")}' >> ~/.zsh_history

systembell avatar Oct 17 '24 19:10 systembell