jonas-pietzsch / fish-history-to-zsh

Migrate the Fish shell history to Zsh history format
32 stars 6 forks source link

`Parser.js` error on Node.js v10.16.0 and `yamljs@0.3.0` #5

Open gabroo opened 1 year ago

gabroo commented 1 year ago
(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 commented 1 year ago

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
fish-history-to-zsh@0.0.1 /tmp/fish-history-to-zsh
└─┬ yamljs@0.3.0
  ├─┬ argparse@1.0.10
  │ └── sprintf-js@1.0.3
  └─┬ glob@7.1.4
    ├── fs.realpath@1.0.0
    ├─┬ inflight@1.0.6
    │ ├── once@1.4.0 deduped
    │ └── wrappy@1.0.2
    ├── inherits@2.0.4
    ├─┬ minimatch@3.0.4
    │ └─┬ brace-expansion@1.1.11
    │   ├── balanced-match@1.0.0
    │   └── concat-map@0.0.1
    ├─┬ once@1.4.0
    │ └── wrappy@1.0.2 deduped
    └── path-is-absolute@1.0.1
nick-at-dave commented 2 months ago

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 commented 2 months ago

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
systembell commented 1 month ago

@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