Comments (33)
Not yet - the README represents the documentation for the latest master
It'll be released this weekend :)
from atuin.
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.
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.
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.
All we need now is the importer :D
It only took 7 months
from atuin.
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.
from atuin.
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.
(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.
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.
@pitr fantastic! thank you for sharing!
All we need now is the importer :D
from atuin.
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.
@bl-ue of course you can use this, sorry for confusion :)
from atuin.
@bl-ue looking forward to a PR for this!
from atuin.
@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.
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.
I'd be willing to give this a try.
- Plugin
- Importing history
- Importing complex history (if fish supports that)
from atuin.
@bl-ue of course!
from atuin.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Fish support would me amazing 😃
from atuin.
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.
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.
no, fish support exists only in master main branch currently
from atuin.
Ah, no problem. I'll build from source for now then.
from atuin.
Related Issues (20)
- [Bug]: 'atuin search -i' only returns entry to the console but doesn't execute it HOT 3
- [Bug]: How to bind keys HOT 1
- Unable to build from Git on Windows HOT 1
- [Bug]: Error: pool timed out while waiting for an open connection HOT 2
- Feature Request: Fully clear input on Control-C
- [Bug]: "Error: error returned from database: (code: 4847) disk I/O error" if no space left on device HOT 3
- [Bug]: atuin status with Error: the 'year' component could not be parsed
- [Bug]: Scrolling in tmux window invokes Atuin history panel
- [Bug]: Defaults to fish and conf.d ? HOT 4
- [Feature Request]: Allow to save locally command history having secrets but have an ooption to prevent from sending it over the server HOT 2
- Unable to import structured history data from hishtory into atuin and have the atuin program search it HOT 1
- [Bug]: typing more of a string makes it a worse match HOT 3
- Feature request: sync config.toml
- [Bug]: Atuin fzf search to behave the same like my zsh fzf search
- [Bug]: atuin status with Error: unexpected trailing characters; the end of input was expected HOT 1
- [Bug]: atuin + starship + zsh + accept-line override is clearing previous command? HOT 1
- [Bug]: sqlite database corruption on network filesystem AFS HOT 1
- [Bug]: Cannot install on NixOS
- [Bug]: some commands are missed by atuin for no apparent reason? HOT 3
- feature request: allow disable "/" keybind applicable when "ctrl+r" is enabled (for ble.sh compatibility)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atuin.