Code Monkey home page Code Monkey logo

Comments (33)

ellie avatar ellie commented on September 28, 2024 7

Not yet - the README represents the documentation for the latest master

It'll be released this weekend :)

from atuin.

pitr avatar pitr commented on September 28, 2024 6

was able to get it working with the following in my config.fish:

function _atuin_preexec --on-event fish_preexec
  set -gx ATUIN_HISTORY_ID (atuin history start "$argv[1]")
end

function _atuin_postexec --on-event fish_postexec
  set s $status
  if test -n "$ATUIN_HISTORY_ID"
    RUST_LOG=error atuin history end $ATUIN_HISTORY_ID --exit $s &; disown
  end
end


function _atuin_history
  set h (RUST_LOG=error atuin search -i (commandline -b) 3>&1 1>&2 2>&3)
  commandline -f repaint
  if test -n "$h"
    commandline -r $h
  end
end

bind \cr '_atuin_history'

from atuin.

NOBLES5E avatar NOBLES5E commented on September 28, 2024 5

Just want to remind people here that fish history file is not a standard yaml, users will experience parse error if we just use serde_yaml. See fish-shell/fish-shell#2759.

from atuin.

ellie avatar ellie commented on September 28, 2024 5

I've been giving this a think and I'd be happy to merge partial support for Fish

We could support switching to Atuin for all future history, and then follow up with adding a history importer. I think that would sort the use case for a lot of users

From what I can tell, and from what's been shared here earlier, we have enough to support the former right now.

Hopefully we can get the "YAML" parsing sorted soon too :)

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024 5

All we need now is the importer :D

It only took 7 months

from atuin.

ellie avatar ellie commented on September 28, 2024 4

No worries @bl-ue! Thank you for your effort in any case!

I'll get this sorted for the next release unless anyone else wants to give it a go 😄

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024 3

@bl-ue #71 is in now :)

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024 3

We just need to get the importer working. It looks like there was an attempt to switch fish from using it's broken YAML format to a new JSONLines format fish-shell/fish-shell#6493 but it got stale.

I'll give it a shot at parsing the YAML format if I can find some good resources on it.

from atuin.

bl-ue avatar bl-ue commented on September 28, 2024 2

(sorry, I'm not totally sure:) So it's okay with you if I use your code?

(because you literally said "of course, I do mind if you include that fish shell snippet in your PR" 😄, so I want to make sure we're on the same page)

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024 2

but could there be memory issues if the file is huge?

Maybe? Let's say we have 100,000 entries and the average command is 100 ascii characters, that's 10,000,000 bytes (10MB). It's a fair amount to load in all at once, but it's not unrealistic

from atuin.

ellie avatar ellie commented on September 28, 2024 1

@pitr fantastic! thank you for sharing!

All we need now is the importer :D

from atuin.

bl-ue avatar bl-ue commented on September 28, 2024 1

Wow, thanks a lot @pitr — I'm still relatively new to fish and haven't done a lot of this type of stuff with it, so that was giving me some trouble. Fish uses YAML for its history format, so I'll be opening a PR with the importer soon!

@pitr do you mind if I include that fish shell snippet in my PR?

from atuin.

pitr avatar pitr commented on September 28, 2024 1

@bl-ue of course you can use this, sorry for confusion :)

from atuin.

sloane-shark avatar sloane-shark commented on September 28, 2024 1

@bl-ue looking forward to a PR for this!

from atuin.

sloane-shark avatar sloane-shark commented on September 28, 2024 1

@bl-ue are you implementing yaml parsing yourself? It seems like you could use serde to easily define a a type that you can marshal to and from YAML, then you can separate the concerns of parsing and iterating over entries.

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024 1

Just want to remind people here that fish history file is not a standard yaml, users will experience parse error if we just use serde_yaml. See fish-shell/fish-shell#2759.

Very sad :(

from atuin.

bl-ue avatar bl-ue commented on September 28, 2024

I'd be willing to give this a try.

  • Plugin
  • Importing history
  • Importing complex history (if fish supports that)

from atuin.

pitr avatar pitr commented on September 28, 2024

@bl-ue of course!

from atuin.

pitr avatar pitr commented on September 28, 2024

probably shouldn't be default for everyone, but an idea to consider - also store cancelled commands in history (ie when Ctrl-c is pressed):

function _atui_cancel
    set -l cmd (commandline)
    commandline -f cancel-commandline
    if test -n "$cmd"
        RUST_LOG=error atuin history end (atuin history start "$cmd") --exit 42 &; disown
    end
end

bind \cc '_atui_cancel'

from atuin.

bl-ue avatar bl-ue commented on September 28, 2024

I'll try to get a PR open within a few days — I've done some Rust development, but not enough to make me an expert like I am in other langs 😄

The fish history is a little different from the other shells' history, because a single command takes multiple lines (since it's YAML). For example:

- cmd: node
  when: 1618340414
- cmd: yes | wc -l &; sleep 1000; ps -ax | grep yes | grep -v grep | awk '{print $1}' | xargs kill; open .
  when: 1618340743
  paths:
    - .
- cmd: date
  when: 1618340762
- cmd: echo hello; exit
  when: 1618340779
- cmd: cd ~/Code; cd ~/Code/rust;
  when: 1618341861
  paths:
    - ~/Code
    - ~/Code/rust

And I'm a little unsure how to, in next() of impl<R: Read> Iterator for Fish<R>, check if the history entry is fully read. I was thinking to check if the line begins with - cmd and then self.file.seek(-1), if that's even possible... @conradludgate does that sound like a feasible solution?

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024

Yeah you can define a struct that matches the yaml, derive Deserialize, then use this function https://docs.serde.rs/serde_yaml/fn.from_reader.html to parse it :)

from atuin.

pitr avatar pitr commented on September 28, 2024

I took a quick stab at it also, but I am not sure how to use serde_yaml to read just one item from yaml array

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024

You don't have to. In the parse function you can just go ahead and read the entire file at once, then store it as a Vec<>, then the iterator implementation will just go through that vec.

I've been considering this for the zsh/bash implementations too.

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024

Ultimately, parsing several MB of yaml doesn't take very long in my experience, the lengthy part of importing is writing to the database

from atuin.

conradludgate avatar conradludgate commented on September 28, 2024

Yeah, on the back of this, I think i might re-approach the Importer trait. I think forcing the Iterator is a bit confusing and restricting. I might just enforce that a Vec is returned

from atuin.

bl-ue avatar bl-ue commented on September 28, 2024

You don't have to. In the parse function you can just go ahead and read the entire file at once, then store it as a Vec<>, then the iterator implementation will just go through that vec.

I was thinking of doing that, but could there be memory issues if the file is huge?

from atuin.

bl-ue avatar bl-ue commented on September 28, 2024

I'm sorry guys — I can't do this 😢

I don't have the Rust skills nor the time (especially the former) 😖

I'm sorry to have holded this up and kept others from working on, if I have :(

from atuin.

delneg avatar delneg commented on September 28, 2024

I was very happy to discover this project, but was brought down to earth when i saw it doesn't support fish yet..
If/when someone does this, it would be great to try it out!

from atuin.

 avatar commented on September 28, 2024

Fish support would me amazing 😃

from atuin.

s0 avatar s0 commented on September 28, 2024

was able to get it working with the following in my config.fish:

# ...

bind \cr '_atuin_history'

For anyone wanting to bind to up instead, as is done for the other shells by default, I've found this works:

bind -k up '_atuin_history'
bind \eOA '_atuin_history'
bind \e\[A '_atuin_history'

You need all 3, as I've found that bind -k up doesn't work for example in ubuntu in Windows Subsystem for Linux, seemingly down to different terminal modes, and I imagine there will be other places where this is the case.

from atuin.

mrjones2014 avatar mrjones2014 commented on September 28, 2024

Has this been released? when I add atuin init fish | source to my config.fish like the README says to, I get error: Found argument 'fish' which wasn't expected, or isn't valid in this context in atuin 0.7.2

from atuin.

panekj avatar panekj commented on September 28, 2024

no, fish support exists only in master main branch currently

from atuin.

mrjones2014 avatar mrjones2014 commented on September 28, 2024

Ah, no problem. I'll build from source for now then.

from atuin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.