Closed MalauD closed 2 years ago
This is a very interesting idea and worth completing. Having separate files for theming would be extremely useful. Would really make the user's prompt their own. Although having a separate file may be overkill. Having a multiline string in toml might be somewhat similar
Ok now you can test this it should be working. See: Config file:
[prompt]
theme="&[#7393B3]`[`{{current_dir}}`] `"
[misc]
alias = [
["", ""]
]
[effects]
underlined = false
bold = true
dimmed = false
suggestion_color = "red"
truecolors = false
true_suggestion_color = [255, 0, 0]
Result:
Add the mpl-2 license headers
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
Adding newline support would be usefull:
"&[#D8BFD8]{{username}}`@`{{hostname}}&[#7393B3]` `{{current_dir}}&[#FFFFFF]`$ `"
could be written down as:
"
&[#D8BFD8]{{username}}`@`{{hostname}}
&[#7393B3]` `{{current_dir}}
&[#FFFFFF]`$ `
"
Formatting would be better and would result in more readability
Well you can you the newline character: \n
what I meant was that the \n
character would be ignored if outside of the literal delimiters (i.e ``). As of now doing
theme = "`x`\n"
or:
theme = "`x`
"
both result in unwraps
So that's because \n
need to be inside the quote like any other string.
For example:
"&[#D8BFD8]{{username}}`@`{{hostname}}&[#7393B3]`\n`{{current_dir}}&[#FFFFFF]`$ `"
So that's because \n need to be inside the quote like any other string.
yes I know and I was requesting for it to be ignored if it is not inside the quote, that way the users can easily format their prompt as it grows larger in size
Ok i understand i'will try to add that
So know you can write your theme using multiple lines:
[prompt]
theme="""\
$[i]&[#D8BFD8]{{username}}`@`{{hostname}}$[c]&[#7393B3]` \
`{{current_dir}}&[#FFFFFF]`$ `\
"""
So this is related to #9 since it will be useful for formatting git infos. Objectives:
Implementation idea: So first of all i had the idea of using a runtime formatting library such as mustache but it would cause problem for text coloring since these formater just replace and not color anything. So we have to implement our parser to do some token recognition. For that there is a library nom well known for parsing byte data and also string. With that in mind i had to think about a theme file syntax. Here is an example i had in mind:
So
&[#FF00FF]
tells to color the next string with the corresponding hex color. Everything will have this color until the next&[#00FF00]
[
is a string literal so it would be display as[
{{home}}
is for variable it would be replace with the correct value (for example~/Documents/vsh
). There could be a lot of different variable like time, hostname, user, return code of previous program...Anyway here is the current roadmap: