-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Vision Discussion: History #66
Comments
Just iterating on history a bit here. An idea I had was to make reedline write a global history in a sqlite3 db (in WAL mode to handle concurrent reads & writes). Then we make each individual session write a local history that writes to reedline_history_sessionid.txt and then send that history item to sqlite. This way, you'd only see commands in your session when you use up/down but if you search history, it would search the sqlite db. The benefit is that you solve the concurrency problem where you have 10 open tabs of shells using reedline at one time trying to write to the same single history.txt file. Another option is to use the sqlite3 db, as described above, but also have a session id column in the table so every session would always update this singular sqlite db using it's own session id and never write a reedline_history_sessionid.txt file at all. Then make up/down just query out of that db based on it's sessionid and allow the search to query globally without the sessionid. This would probably simplify things but it moves all history to one sqlite db. These sqlite options also tick some of the boxes above by having a |
Current votingVote for the topic(s) you care about by selecting the corresponding emoji. (No judgement based on the emojis sentiment!)
|
As a way of being more verbose and transparent. Below are some of the ideas I've had with history. please add your own vision/ideas so we can collaborate and come up with something beyond cool. The most important thing to me, other than having it function the way it should normally with up/down arrows, is that we have enough information to do fancy things in the future. To that end, let's list some fancy things we'd like to do to ensure we have enough information captured. For reference this is that struct that I envisioned starting off with. I numbered them for easier reference. #[derive(Debug, Clone, Ord, PartialOrd)]
pub struct HistoryItem {
/// Primary Key, Unique Id
0. pub history_id: Option<i64>,
/// Entire command line
1. pub command_line: String,
/// Command part of the command line
2. pub command: String,
/// Parameters part of the command line
3. pub command_params: Option<String>,
/// Current working directory
4. pub cwd: String,
/// How long it took to run the command
5. pub duration: i64,
/// The exit status / return status of the command
6. pub exit_status: i64,
/// The pid of the running process
7. pub session_id: i64,
/// When the command was run
8. pub timestamp: chrono::DateTime<Utc>,
/// How many times was this command ran
9. pub run_count: i64,
}
|
As far as an implementation detail is concerned.... I think each one of the fields of the HistoryItem struct /// This trait represents additional context to be added to a history (see [SqliteBackedHistory])
pub trait HistoryEntryContext: Serialize + DeserializeOwned + Default + Send {}
impl<T> HistoryEntryContext for T where T: Serialize + DeserializeOwned + Default + Send {}
/// A history that stores the values to an SQLite database.
/// In addition to storing the command, the history can store an additional arbitrary HistoryEntryContext,
/// to add information such as a timestamp, running directory, result...
I am not completely convinced of this though... But it just seems simpler to me to understand... The downside is that if you want to add more stuff later... |
I'm leaning this way too. I'd rather keep it as simple and approachable as possible. |
Having something simular to |
@FilipAndersson245 It's possible I think. The one thing missing is that we don't have how many times a command has been run and that's a key metric in zoxide's database and how they figure out which commands to run. We could put that information in the "more_info" column of the db, but someone would have to figure some things out. |
This issue is part of the larger vision discussion managed in #63 to brainstorm and prioritize ideas around features that would make
reedline
as a line editor for you both viable as well as pleasant to use. Feel free to up-vote features you depend on in other tools/shells as well as suggest new ideas!History Features
rich
data within the history, such as:ms
plugable
technologies to make history searching and recall extensibleThe text was updated successfully, but these errors were encountered: