-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow history file name customization #102
Comments
I would also very much like this feature 👍 @ridiculousfish - would you consider a pull request for it? This milestone was assigned a while back, so I thought I would double check. My use case is the same as this one, and I was thinking of the same approach. Rather than making it specifically configurable, you could just set an environment variable to essentially namespace the histories. With a slightly tweaked implementation, I believe this would also solve #1156 too if it could be set to Thanks, |
An environment variable is certainly easy to implement on the fish side. Out of curiosity, how do you plan to set the variable? Would you do it manually ( |
Music to my ears :) My initial use case is within
Then I'd have that profile as a launcher shortcut somewhere. |
Thanks, that makes sense. |
Sorry, but I vote no to this request. Three and a half years after the issue was opened only one person has said "me too". If you really need isolated history files then you should be using Linux containers or a similar technology to create a namespace for the shell. |
I think this may help implement sessions with working suspend/resume for OS X's Terminal.app. (see /etc/bashrc_Apple_Terminal for what Apple does with bash.) I'm a "Me Too!", I want to try to make local sessions work from within fish by manually managing/abusing the history. |
Okay, I've changed my mind. However, I think this should use the same HISTFILE env var name that bash and zsh use. Thanks for PR#1940, @jaysh, but it has some problems with the code not to mention the lack of unit tests and changes to the documentation. If you don't mind I'll borrow your idea and fix the problems. |
If someone sets
This is something of a rhetorical question because I think it's pretty clear option 1 will cause so many problems it's not even worth considering. I only ask because the original pull-request implemented that behavior. As did my first rewrite of that change. Unless someone can explain why option 1 is preferable I'm going to implement option 2. |
That's a pretty funny question. What do bash and zsh do? |
Also if I set FISH_HISTFILE, do I lose my history from this session and instead pick up whatever was in that other file? |
I have no idea what bash/zsh do. Zsh in particular is such a rat maze of behavior I wouldn't even pretend that I knew how it behaves despite using it for 7+ years and you'd have to pay me to figure out what it does. Your second question is more interesting. It's not clear to me what happens or should happen. Any new commands are logged to the new Which means I don't really understand when the history file is rewritten and neither did the person who created the original change. It also means the documentation doesn't answer this question unless I have a reading comprehension problem. |
P.S., for anyone paying attention. The dialog on this issue is a canonical example of why seemingly simple enhancement requests are almost never simple. |
Every 25 ( The history is conceptually just a list of commands. Running a command appends to that list, and up-arrow traverses backwards through them. It seems natural that setting FISH_HISTFILE switches over to a different list, so it would not contain any prior commands. If we believe this (and I do) then the implementation is very straightforward. History is already instanced (see e.g. A minor change required is to replace |
One of the usecases that were mentioned for this was screencasting, where you don't want your old commands to show up. So:
Yes. Others were also going for the privacy angle. |
I am now leaning towards a hybrid solution. Augment the builtin |
Below is the text I'm tentatively planning on adding to the Obviously using the
|
@krader1961 this looks good. I think having standard support for a variable might be useful, but not necessary. It would (probably) primarily be used by scripts that call fish, but given that fish is intended for interactive sessions, that's shouldn't be all that common. |
I think it would be worth noting that using "none" allows you to enter a private/incognito session, ala browsers. |
@zanchey: Excellent suggestion. Thx. I'm also going to make it clear that only regular files can be used. Attempting to specify a device file like /dev/null will be rejected. I know I suggested using /dev/null in other comments but I now believe that is a bad idea. Not least because it complicates the history rewrite logic. |
@krader1961 Any plan on picking this back up? Would be really awesome to support this in fish! |
Introduce a HISTFILE variable in the same vein as bash and zsh to allow the user to specify where interactive commands are logged. The default file name is unchanged. Resolves fish-shell#102.
If there are no objections, I'm happy to take this on. For a WIP implementation, see #4024 and the associated comments. |
Based on the comments on the pull request above, here's the proposed implementation: The history file will be controlled solely by the The location of the history file will be:
Couple of examples:
As you can see, setting If If the value changes in a single shell session, the location will be updated accordingly. |
Using the FISH_HISTFILE variable will let people customise the session to use for the history file. The resulting history file is: `$XDG_DATA_HOME/fish/name_history` Where `name` is the name of the session. The default value is `fish` which results in the current history file. If it's set to an empty string, the history will not be stored to a file. Fixes fish-shell#102
Why was a session ID chosen over being able to set a file path? Edit: sorry for thread necro, I missed the reference to #4024, checking that out now. |
For posterity: The variable was renamed to |
In private mode, access to previous history is blocked and new history is directed immediately to /dev/null. Note that in this current implementation, history is available _within_ the private session, but cannot (well, should not) leak from it. This mode can be used when it is not desirable for commandline history to leak into a session, e.g. via autocomplete or when it is desirable to test the behavior of fish in the absence of history items without permanently clearing the history. I'm sure there are a lot more features that can be incorporated into private mode, such as restricting access to certain user-specific configuration files, etc. This addresses a lot of the concerns raised in fish-shell#1363 (which was later changed to track mosh-specific problems). See also fish-shell#102. (Note that $fish_history is not used as that causes data to persist to disk.)
In private mode, access to previous history is blocked and new history does not persist and is only available for the duration of the current session. This mode can be used when it is not desirable for commandline history to leak into a session, e.g. via autocomplete or when it is desirable to test the behavior of fish in the absence of history items without permanently clearing the history. I'm sure there are a lot more features that can be incorporated into private mode, such as restricting access to certain user-specific configuration files, etc. This addresses a lot of the concerns raised in fish-shell#1363 (which was later changed to track mosh-specific problems). See also fish-shell#102.
In private mode, access to previous history is blocked and new history does not persist and is only available for the duration of the current session. This mode can be used when it is not desirable for commandline history to leak into a session, e.g. via autocomplete or when it is desirable to test the behavior of fish in the absence of history items without permanently clearing the history. I'm sure there are a lot more features that can be incorporated into private mode, such as restricting access to certain user-specific configuration files, etc. This addresses a lot of the concerns raised in fish-shell#1363 (which was later changed to track mosh-specific problems). See also fish-shell#102.
In private mode, access to previous history is blocked and new history does not persist and is only available for the duration of the current session. This mode can be used when it is not desirable for commandline history to leak into a session, e.g. via autocomplete or when it is desirable to test the behavior of fish in the absence of history items without permanently clearing the history. I'm sure there are a lot more features that can be incorporated into private mode, such as restricting access to certain user-specific configuration files, etc. This addresses a lot of the concerns raised in fish-shell#1363 (which was later changed to track mosh-specific problems). See also fish-shell#102.
In private mode, access to previous history is blocked and new history does not persist and is only available for the duration of the current session. This mode can be used when it is not desirable for commandline history to leak into a session, e.g. via autocomplete or when it is desirable to test the behavior of fish in the absence of history items without permanently clearing the history. I'm sure there are a lot more features that can be incorporated into private mode, such as restricting access to certain user-specific configuration files, etc. This addresses a lot of the concerns raised in #1363 (which was later changed to track mosh-specific problems). See also #102.
Works for bash and zsh now. Not implemented for fish, but it's possible. The problem is that history files must be located in $XDG_DATA_HOME (fish-shell/fish-shell#102 (comment)) and currently, history files are located in IDE's config directory.
Works for bash and zsh now. Not implemented for fish, but it's possible. The problem is that history files must be located in $XDG_DATA_HOME (fish-shell/fish-shell#102 (comment)) and currently, history files are located in IDE's config directory. (cherry picked from commit cc3f407) https://upsource.jetbrains.com/IDEA/review/IDEA-CR-39138
In private mode, access to previous history is blocked and new history does not persist and is only available for the duration of the current session. This mode can be used when it is not desirable for commandline history to leak into a session, e.g. via autocomplete or when it is desirable to test the behavior of fish in the absence of history items without permanently clearing the history. I'm sure there are a lot more features that can be incorporated into private mode, such as restricting access to certain user-specific configuration files, etc. This addresses a lot of the concerns raised in fish-shell#1363 (which was later changed to track mosh-specific problems). See also fish-shell#102.
To have separate histories when using e.g. screen or logging in to a machine via multiple sessions, it should be possible to customize the history file name, for example using an environment variable. See ekoeppen@ccfac2c for a possible implementation.
The text was updated successfully, but these errors were encountered: