Skip to content

Add support for '~' as a shortcut for home directory (#149) #156

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

Conversation

BiswajitThakur
Copy link

No description provided.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow https://man7.org/linux/man-pages/man3/glob.3.html's GLOB_TILDE here and make this an off-by-default setting on MatchOptions. This is a breaking change but we want to make it #[non_exhaustive] anyway.

Comment on lines +609 to +634
if let (Some(first_char), second_char) = (chars.first(), chars.get(1)) {
#[cfg(not(windows))]
match (*first_char, second_char) {
('~', None) | ('~', Some(&'/')) => {
if let Ok(home_dir) = std::env::var("HOME") {
for ch in home_dir.chars() {
tokens.push(PatternToken::Char(ch));
}
i += 1;
}
}
_ => {}
}
#[cfg(windows)]
match (*first_char, second_char) {
('~', None) | ('~', Some(&'/')) | ('~', Some(&'\\')) => {
if let Ok(home_dir) = std::env::var("USERPROFILE") {
for ch in home_dir.chars() {
tokens.push(PatternToken::Char(ch));
}
i += 1;
}
}
_ => {}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few simplifications:

@tgross35 tgross35 added this to the 1.x milestone Aug 11, 2025
@BiswajitThakur BiswajitThakur closed this by deleting the head repository Aug 13, 2025
@reneleonhardt
Copy link

Why has this been closed? The review sounded like it would be nearly ready for merging.

@BiswajitThakur
Copy link
Author

BiswajitThakur commented Aug 13, 2025

sorry for closing. i got error when i send pull request thats why i closed it and i resend a pull request again.

@reneleonhardt
Copy link

Thank you for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants