-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Git config inside $XDG_CONFIG_HOME/git is not highlighted #1191
Comments
Thank you for reporting this. If we feel this is something that should be fixed inside
For now, you can add --map-syntax '$XDG_CONFIG_HOME/git/config:Git Config' to your config file, where you would have to replace |
@sharkdp I can open a PR but I will need some help with this logic.
How can I do that? (Rust noob here) This is the diff I currently have locally diff --git a/src/syntax_mapping.rs b/src/syntax_mapping.rs
index 96ce7fc..9029c02 100644
--- a/src/syntax_mapping.rs
+++ b/src/syntax_mapping.rs
@@ -101,6 +101,10 @@ impl<'a> SyntaxMapping<'a> {
// pacman hooks
mapping.insert("*.hook", MappingTarget::MapTo("INI")).unwrap();
+ mapping.insert("$XDG_CONFIG_HOME/git/config", MappingTarget::MapTo("Git Config")).unwrap();
+ mapping.insert("$XDG_CONFIG_HOME/git/ignore", MappingTarget::MapTo("Git Ignore")).unwrap();
+ mapping.insert("$XDG_CONFIG_HOME/git/attributes", MappingTarget::MapTo("Git Attributes")).unwrap();
+
mapping
}
Also, how to test that with |
this will not work. |
Yes. A test for this would be a bit more involved. Cleanup would not be needed as changes to the environment would only be visible to the child |
I'm trying something like this but it's not working, is this even the right approach? if std::env::var_os("XDG_CONFIG_HOME").is_some() {
let xdg_config_home = std::env::var_os("XDG_CONFIG_HOME").unwrap();
mapping
.insert(
std::env::join_paths([xdg_config_home, Path.new("/git/config")]),
MappingTarget::MapTo("Git Config"),
)
.unwrap();
} |
You want if let Some(xdg_config_home) = std::env::var_os("XDG_CONFIG_HOME") {
mapping
.insert(
Path::new(xdg_config_home).join("git").join("config"),
MappingTarget::MapTo("Git Config"),
)
.unwrap();
} |
Fixed in v0.16.0. |
What version of
bat
are you using?bat 0.15.4
Describe the bug you encountered:
Git configuration files inside
$XDG_CONFIG_HOME/git/{ignore,config,attributes}
are not highlightedFrom
man git-config
Describe what you expected to happen?
They should be highlighted
How did you install
bat
?homebrew
system
$ uname -srm
Darwin 19.6.0 x86_64
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.6
BuildVersion: 19G2021
bat
$ bat --version
bat 0.15.4
$ env
BAT_CONFIG_PATH=/Users/ahmed/.config/bat/config
PAGER=less
bat_config
$ cat /Users/ahmed/.config/bat/config
bat_wrapper
No wrapper script for 'bat'.
bat_wrapper_function
No wrapper function for 'bat'.
$ /usr/local/bin/zsh --login -i -c type cat
tool
$ less --version
less 487 (POSIX regular expressions)
The text was updated successfully, but these errors were encountered: