-
Notifications
You must be signed in to change notification settings - Fork 51
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
add support for fish and tcsh shells #1347
base: main
Are you sure you want to change the base?
Conversation
d05824d
to
fa5fd87
Compare
3c3e633
to
f9caf58
Compare
1071e76
to
65e11a2
Compare
779a4b9
to
67a0e41
Compare
3118022
to
d4d4a0b
Compare
7c03ba1
to
44b7b6d
Compare
The perils of creating our own quoting function is that we're destined to repeat lessons of the past, but of course the advantage is that we have more precise control of the outcome. This patch adds logic to similarly escape the backtick (`) character. (I rather suspect our next step will be to escape the single quote ('), followed by conditional logic to avoid escaping when within them.)
Following PR#1299 it was fairly straightforward to add support for the fish and tcsh shells. This patch adds this support along with tests that mirror those that already exist for bash and zsh. Also removed `posixIfThen` and `posixSetEnv` C++ macros no longer required since merging PR#1299.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only made it through the Rust - I'll pick up with the pkgdb changes next week (that's where all the real logic is 😆 )
indoc! {r#" | ||
echo "Activating poetry virtual environment" >&2 | ||
source "$(poetry env info --path)/bin/activate.csh""#} | ||
.to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question blocking: how prominent do we want tcsh to be in docs and init hooks? I'm not really sure how much it's used, so I'm not sure if most people will see it as boilerplate or actually helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know at least two firms in which it's still used extensively, but regardless we should maintain a low bar for the addition of shell support (and it should be easier and better factored to involve modifications to fewer than 30 files in future!).
As for the prominence of its mention in the template, that's somewhat of an implementation detail; direnv supports 9 shells, and I agree at some point that we'll want to change the manifest template to be less verbose once there are that many to be listed.
But is there a reason you made the comment here in the python.rs
file? This is one place where we definitely need to explicitly emit code for each of the supported shells - I can see your question pertaining to the template manifest.toml
but not here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even in init hooks, we could just add hooks for the most popular shells - with 3 examples (bash, zsh, and fish) I don't think it would be too difficult for a tcsh user to figure out what to add in a tcsh hook.
@ghudgins @jennymahmoudi any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, just fish is good
I'm about half-way done with my review, I'll probably try to finish on Monday |
Thanks @mkenigs for the eagle eye. Clearly did that in a batch of bulk changes and just missed it ... curious why that wasn't caught in tests but happy to move on ... Co-authored-by: Matthew Kenigsberg <matthew@floxdev.com>
set prompt = "$_flox $FLOX_SAVE_TCSH_PROMPT" | ||
endif | ||
|
||
unset _flox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion blocking: when "${FLOX_PROMPT_ENVIRONMENTS:-}" == ""
, the prompt shouldn't be changed at all
# these files ourselves prior to setting up the environment. | ||
foreach f ( /etc/csh.login /etc/csh.cshrc ~/.cshrc ~/.tcshrc ) | ||
if ( -f $f ) then | ||
source $f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question blocking: could we hit the same infinite looping bug as with .bashrc?
|
||
# Bring in the Nix and Flox environment customizations. | ||
if ( $?FLOX_TCSH_INIT_SCRIPT ) then | ||
source "$FLOX_TCSH_INIT_SCRIPT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question blocking: looks like above you source e.g. $HOME/.cshrc
, but then doesn't FLOX_TCSH_INIT_SCRIPT
source ~/.cshrc
again? Not sure if I'm reading that right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what it looks like to me
@@ -365,6 +365,12 @@ impl Activate { | |||
.arg("--rcfile") | |||
.arg(activation_path.join("activate").join("bash")); | |||
}, | |||
Shell::Fish(_) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: it's probably worth suggesting to the user that they rebuild the environment to gain support for the new shells. If this is a remote environment that belongs to someone else then it's out of their hands, but otherwise they may not understand why we say we support fish
, etc and then get this error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect there will be approximately zero people wanting to use fish with environments rendered before version 1.0.5, but I see your point. What if we update the error message to read "fish not supported with environments rendered before version 1.0.5; please update environment and try again" - does that work for you?
|
||
# Bring in the Nix and Flox environment customizations. | ||
if ( $?FLOX_TCSH_INIT_SCRIPT ) then | ||
source "$FLOX_TCSH_INIT_SCRIPT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what it looks like to me
s/flox_save_fish_prompt/flox_saved_fish_prompt/g
Proposed Changes
This PR adds support for the
fish
andtcsh
shells based on the refactoring offlox activate
performed in #1299.Also removed
posixIfThen
andposixSetEnv
C++ macros no longer required since merging PR#1299.Release Notes
fish
andtcsh
shells.