vantage icon indicating copy to clipboard operation
vantage copied to clipboard

Persistent history

Open slezica opened this issue 9 years ago • 6 comments

Command history is handy, but it doesn't live beyond a session. It would be awesome if vantage had persistent history. As of now, this can only be achieved by loading entries into vagrant.session._hist.

History could be kept server-side on a per-user basis, or client-side on a per-host basis.

For a server-side implementation, instead of bundling this functionality with vantage itself, a public history API could be exposed for extensions to manage and provide history, with session history as the default implementation.

A client-side implementation could provide a vantage command-line flag to pick a history file, defaulting to something like ~/.vantage/history/<host> (for system-wide, per-host history) or ./vantage/history (for directory-based history).

slezica avatar Aug 10 '15 04:08 slezica

I totally agree this should be added to Vantage.

I also think it should be built-in native, not as an extension.

There are a ton of ways to do it, which makes me uneasy. It should be done exactly the way Linux/SSH sessions handle persistent command history, so there is consistency - it should behave exactly the way people are used to it behaving.

I'll have to find out how it's done (i.e. when SSHing to another terminal, the commands are persisted locally, etc., as well as what primary keys are used to match up users and terminals to a given history, etc.).

If there's any way you could help do research on that, it would definitely help speed up the implementation!

dthree avatar Aug 10 '15 16:08 dthree

ssh doesn't keep history: the shell does. When you start a remote shell via SSH, history is managed normally, local to the shell process. bash, for example, writes to ~/bash_history.

In other words, you could say history is stored remotely, on a per-user basis, in a plain file.

vantage could manage this, as it does have authentication. Unauthenticated accesses could share history. It would be a matter of picking a default directory, exposing a configuration function in the vantage object, and storing history in plain-text files.

For example, I can picture this kind of interface:

vantage.history(".vantage-history") // current directory storage, shared
vantage.history(".vantage/<user>-history") // current directory, per-user
vantage.history("/vantage/<app>/<user>-history") // system-wide, per-app + per-user

I could spare some free time to implement this and submit a pull request. If you're short on time, let me know and give me a few days =)

slezica avatar Aug 11 '15 23:08 slezica

Nice and thanks for the data - I didn't know those things. Your idea sounds right. On unauthenticated access, I think I assign a user account as guest or something, so it could store it under that name.

I'm very short on time, so it would be totally awesome if you could spare time to do this!

I should probably fill you in on some more details as to how Vantage handles sessions, etc. as getting this working is going to require modifications across the code base, particularly adding content to:

./lib/vantage.js
./lib/client.js
./lib/server.js

Feel free to ask me any questions or confusions - don't hesitate at all!

In regards interface, I think we should go with Convention over Configuration and not try to expose it that publicly to users, unless they really need to change it. It should just work as a default, I think.

dthree avatar Aug 11 '15 23:08 dthree

@slezica does it look like you're going to be able to work on this?

dthree avatar Aug 24 '15 19:08 dthree

@dthree I'm sorry for the dissapearance. I switched jobs, working both during the transition, and have been unable to spare time for any of my personal projects.

I'd love to contribute this feature (I use vantage and feel the need for it myself), but I'm 200% swamped. I have to be realistic and pass. Sorry I didn't tell you earlier, I honestly forgot.

I hope I can come back and contribute some solid code to this project in the future.

slezica avatar Sep 04 '15 18:09 slezica

No probs and thanks for letting me know.

dthree avatar Sep 04 '15 18:09 dthree