11pub fn config_file() -> PathBuf {
12 PROJECT_DIRS.config_dir().join("config")
15pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseError> {
17 fs::read_to_string(config_file())
19 .map(|content| get_args_from_str(&content)),
24pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {
25 env::var("BAT_OPTS").ok().map(|s| get_args_from_str(&s))
28fn get_args_from_str<'a>(content: &'a str) -> Result<Vec<OsString>, shell_words::ParseError> {
29 let args_per_line = content
31 .map(|line| line.trim())
32 .filter(|line| !line.is_empty())
33 .filter(|line| !line.starts_with("#"))
34 .map(|line| shell_words::split(line))
35 .collect::<Result<Vec<_>, _>>()?;
40 .map(|line| line.into())
46 let args = get_args_from_str("").unwrap();
47 assert!(args.is_empty());
52 assert_eq!(vec!["--plain"], get_args_from_str("--plain").unwrap());
58 vec!["--plain", "--language=cpp"],
59 get_args_from_str("--plain --language=cpp").unwrap()
66 vec!["--theme", "Sublime Snazzy"],
67 get_args_from_str("--theme \"Sublime Snazzy\"").unwrap()
75 --style numbers,changes
80 vec!["-p", "--style", "numbers,changes", "--color=always"],
81 get_args_from_str(config).unwrap()
91 # show line numbers and Git modifications
92 --style numbers,changes
94 # Always show ANSI colors
98 vec!["-p", "--style", "numbers,changes", "--color=always"],
99 get_args_from_str(config).unwrap()
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list