add custom prompt
This commit is contained in:
parent
b4588d3445
commit
6ea2858495
5 changed files with 100 additions and 0 deletions
2
prompt/.gitignore
vendored
Normal file
2
prompt/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
target/
|
||||
Cargo.lock
|
11
prompt/Cargo.toml
Normal file
11
prompt/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "prompt"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies.powerline]
|
||||
git = "https://github.com/Gajus84/powerline-rust.git"
|
||||
default-features = false
|
||||
features = ["bare-shell", "libgit"]
|
20
prompt/src/main.rs
Normal file
20
prompt/src/main.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use powerline::{Powerline, modules::{Cmd, Cwd, ExitCode, Git, ReadOnly}};
|
||||
|
||||
use crate::theme::Theme;
|
||||
|
||||
mod theme;
|
||||
|
||||
fn main() {
|
||||
let mut main_prompt = Powerline::new();
|
||||
|
||||
main_prompt.add_module(Cwd::<Theme>::new(40, 5, false));
|
||||
main_prompt.add_module(Git::<Theme>::new());
|
||||
|
||||
let mut aux_prompt = Powerline::new();
|
||||
|
||||
aux_prompt.add_module(ExitCode::<Theme>::new());
|
||||
aux_prompt.add_module(ReadOnly::<Theme>::new());
|
||||
aux_prompt.add_module(Cmd::<Theme>::new());
|
||||
|
||||
println!("{}\n{}", main_prompt, aux_prompt);
|
||||
}
|
55
prompt/src/theme.rs
Normal file
55
prompt/src/theme.rs
Normal file
|
@ -0,0 +1,55 @@
|
|||
use powerline::{modules::{CmdScheme, CwdScheme, ExitCodeScheme, GitScheme, ReadOnlyScheme}, terminal::Color};
|
||||
|
||||
// convenience alias
|
||||
const fn c(color: u8) -> Color {
|
||||
Color(color)
|
||||
}
|
||||
|
||||
pub struct Theme;
|
||||
|
||||
impl CmdScheme for Theme {
|
||||
const CMD_PASSED_FG: Color = c(4);
|
||||
const CMD_PASSED_BG: Color = c(2);
|
||||
const CMD_FAILED_BG: Color = c(1);
|
||||
const CMD_FAILED_FG: Color = c(7);
|
||||
}
|
||||
|
||||
impl CwdScheme for Theme {
|
||||
const CWD_FG: Color = c(0);
|
||||
const PATH_FG: Color = c(0);
|
||||
const PATH_BG: Color = c(3);
|
||||
const HOME_FG: Color = c(0);
|
||||
const HOME_BG: Color = c(5);
|
||||
const SEPARATOR_FG: Color = c(4);
|
||||
}
|
||||
|
||||
impl GitScheme for Theme {
|
||||
const GIT_AHEAD_BG: Color = c(2);
|
||||
const GIT_AHEAD_FG: Color = c(0);
|
||||
const GIT_BEHIND_BG: Color = c(4);
|
||||
const GIT_BEHIND_FG: Color = c(0);
|
||||
const GIT_STAGED_BG: Color = c(6);
|
||||
const GIT_STAGED_FG: Color = c(0);
|
||||
const GIT_NOTSTAGED_BG: Color = c(4);
|
||||
const GIT_NOTSTAGED_FG: Color = c(0);
|
||||
const GIT_UNTRACKED_BG: Color = c(69);
|
||||
const GIT_UNTRACKED_FG: Color = c(0);
|
||||
const GIT_CONFLICTED_BG: Color = c(1);
|
||||
const GIT_CONFLICTED_FG: Color = c(0);
|
||||
const GIT_REPO_CLEAN_BG: Color = c(4);
|
||||
const GIT_REPO_CLEAN_FG: Color = c(0);
|
||||
const GIT_REPO_DIRTY_BG: Color = c(250);
|
||||
const GIT_REPO_DIRTY_FG: Color = c(0);
|
||||
const GIT_REPO_ERROR_BG: Color = c(196);
|
||||
const GIT_REPO_ERROR_FG: Color = c(0);
|
||||
}
|
||||
|
||||
impl ExitCodeScheme for Theme {
|
||||
const EXIT_CODE_BG: Color = c(4);
|
||||
const EXIT_CODE_FG: Color = c(0);
|
||||
}
|
||||
|
||||
impl ReadOnlyScheme for Theme {
|
||||
const READONLY_FG: Color = c(1);
|
||||
const READONLY_BG: Color = c(0);
|
||||
}
|
12
rustfmt.toml
Normal file
12
rustfmt.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
unstable_features = true
|
||||
binop_separator = "Back"
|
||||
format_code_in_doc_comments = true
|
||||
format_macro_matchers = true
|
||||
format_strings = true
|
||||
imports_layout = "HorizontalVertical"
|
||||
match_block_trailing_comma = true
|
||||
merge_imports = true
|
||||
normalize_comments = true
|
||||
use_field_init_shorthand = true
|
||||
use_try_shorthand = true
|
||||
wrap_comments = true
|
Loading…
Reference in a new issue