reujab / silver Goto Github PK
View Code? Open in Web Editor NEWA cross-shell customizable powerline-like prompt with icons
License: MIT License
A cross-shell customizable powerline-like prompt with icons
License: MIT License
I now have silver
working (kind of) on windows but only the left side seems to work.
Here's the toml I'm using
[[left]]
name = "dir"
color.background = "blue"
color.foreground = "white"
[[left]]
name = "git"
color.background = "green"
color.foreground = "black"
[[right]]
name = "status"
color.background = "white"
color.foreground = "black"
[[right]]
name = "cmdtime"
color.background = "magenta"
color.foreground = "black"
[[right]]
name = "shell"
color.background = "green"
color.foreground = "black"
You can see in the screenshot that I changed the toml from black foreground to white just to see if it was seeing my toml file properly and it seems to be. Any ideas where to start with this?
Hey,
The default bash has a nice little * that shows up when you are inside their little containerization system called "toolbox".
I'm a new user to this little tool, but am LOVING the minimalism and simplicity .. compared to some of the more "powerful" tools like this out there.
Aany-who. The one module that I would LOVE to see for my current environment is one for Silverblue's "toolbox". The default shell shows just an asterisk, but with "silver" it doesn't show anything when you are operating inside a toolbox container..
The asterisk is "nice" I guess, but what would be really nice is a "silver" module that actually tells you the name of the container you are inside!
What do you guys think? Is this do-able? I might give it a shot, rust seems neat ... but I've never used it before so..
Thanks Guys!
Couldn't compile silver to run on my mac, since I'd rather not install homebrew. Attached is the errors print.
Environment:
Darwin Malayo.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
rustup 1.19.0 (2af131cf9 2019-09-08)
cargo 1.37.0 (9edd08916 2019-08-02)
rustc 1.37.0 (eae3437df 2019-08-13)
elves/elvish#814 got closed
Change the program structure to make adding segments easier
This is mostly a feature request not really a bug. IMO it would be better to use integers to represent number of changes from upstream. I work with codebases which can diverge significantly from upstream. Currently number of stashed changes is represented by n
stash icons. Where n
is number of changes ( stashes += &icons::get("stash");
). Same goes for ahead
and behind
graph = icons::get("ahead").repeat(ahead)
+ &icons::get("behind").repeat(behind);
The problem with this approach is that it takes the screen space. It makes prompt taking few lines for some edge cases. It could be changed to show this info in colored sections like follows:
------\-----------------\----------------\------------------\
> :stash_icon: 5 > :ahead_icon: 8 > :behind_icon: 10 >
------/-----------------/----------------/------------------/
I can't seem to find a correct path, I've tried ~ and ~/.config with no success.
Thanks.
After installing silver using cargo install silver
on my Arch machine and editing of the .zshrc
file, I'm met with this:
$(build_left_prompt) $(build_right_prompt)
$reset_color
Now I'm not sure what went wrong if anything, but I'm slightly lost.
My .zshrc
:
export SILVER=(status:black:white dir:blue:black git:green:black cmdtime:magenta:black)
export SILVER_SHELL=zsh
source <(silver init)
setxkbmap si
setxkbmap -option kpdl:dot
export QT_QPA_PLUGIN="xcb"
export QT_QPA_PLATFORMTHEME="qt5ct"
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk/
unsetopt share_history
export PATH="/home/arch/.cargo/bin:"$PATH
export PATH="/home/arch/.local/bin:"$PATH
I'm using Konsole as the terminal application.
silver init
panics immediately for me:
$ source <(silver init)
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/main.rs:57:55
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Because I don't have config file or ?? Anyway I think it would be nice to handle this error.
It is hard coded to yellow, but would be nice, if it can be changed.
I primarily use ssh for git operations and the silver git module doesn't use the correct icon for git remotes like [email protected]:reujab/silver.git
.
Hi!
If you will want to add xonsh shell support I want to leave this the link to xonsh extension (xontrib) for Starship as an example - xontrib-prompt-starship. The core code is very simple - prompt_starship.py.
To create the xontrib we use cookiecutter template.
Thanks!
Add RPROMPT support for shells that support it (zsh, fish).
Support more shells like ion
, xonsh
etc.
https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
ESC[ 38;5;⟨n⟩ m Select foreground color
ESC[ 48;5;⟨n⟩ m Select background color
0- 7: standard colors (as in ESC [ 30–37 m)
8- 15: high intensity colors (as in ESC [ 90–97 m)
16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
232-255: grayscale from black to white in 24 steps
Currently, only 0-7 can be used.
Would be nice to be able to use 8-15 as well.
Maybe something like:
fn code(color: &str) -> Option<String> {
match color {
"none" => Some("0".to_owned()),
"black" => Some("30".to_owned()),
"red" => Some("31".to_owned()),
"green" => Some("32".to_owned()),
"yellow" => Some("33".to_owned()),
"blue" => Some("34".to_owned()),
"magenta" => Some("35".to_owned()),
"cyan" => Some("36".to_owned()),
"white" => Some("37".to_owned()),
"lightblack" => Some("90".to_owned()),
"lightred" => Some("91".to_owned()),
"lightgreen" => Some("92".to_owned()),
"lightyellow" => Some("93".to_owned()),
"lightblue" => Some("94".to_owned()),
"lightmagenta" => Some("95".to_owned()),
"lightcyan" => Some("96".to_owned()),
"lightwhite" => Some("97".to_owned()),
_ => None,
}
}
Automatically detect the shell silver init
was runned in if SILVER_SHELL
is not given. This could be done by looking up process parent.
Does silver support NuShell? If not can support be requested?
There have been a number of fixes and features added since the last release. It would be nice to get the latest from Fedora repos. :) The git icon for ssh repos is working btw. Thanks again!
The Configuration section of the README references a "screenshot above", but there isn't any screenshot 😬
Not sure if this is possible already, but I didn’t see it documented. Is there a way to pass no background color to a segment? If not, it would be a nice feature to have. I love silver, but I generally prefer a minimal prompt. Thanks for the great work!
Currently it's forked, would be better if it was transferred
As with most zsh themes, arrow up, insert, home, end, pos1 are not mapped.
Adding a switch to the eval subcommand would be awesome to autogenerate the expected key mappings.
Lines 81 to 88 in bb22207
When I open my terminal, I see:
precmd:1: bad math expression: operator expected at `N-15868274...'
In my .zshrc
, I have:
export SILVER_SHELL="zsh"
SILVER_START=$(date +%s%3N)
unsetopt prompt_subst
preexec() {
SILVER_START=$(date +%s%3N)
}
precmd() {
PROMPT="$(code=$? jobs=$(jobs | wc -l) cmdtime=$(($(date +%s%3N)-$SILVER_START)) silver print "${SILVER[@]}") "
SILVER_START=$(date +%s%3N)
}
If I change the date
in cmdtime
to gdate
, I just get:
precmd:1: bad math expression: operator expected at `N'
zsh 5.7.1 (x86_64-apple-darwin19.0)
on macOS 10.15.5 Beta
Use TOML for config instead of environment variables, this would allow more flexible setups. Maybe this will also deprecate $SILVER_SHELL
, see #42.$SILVER_SHELL
is already removed.
icon_set = "nerd"
[icons]
failed = "\u2717"
[separator.left]
thick = "\ue0b4"
thin = "\ue0b5"
[separator.right]
thick = "\ue0b6"
thin = "\ue0b7"
[[left]]
name = "dir"
color.background = "blue"
color.foreground = "black"
[[left]]
name = "git"
color.background = "green"
color.foreground = "black"
args = ["red"]
[[right]]
name = "status"
color.foreground = "white"
color.background = "black"
[[right]]
name = "cmdtime"
color.background = "magenta"
color.foreground = "black"
[[right]]
name = "shell"
color.background = "green"
color.foreground = "black"
In fish it would be
set -x SILVER_LEFT_SEPARATOR \ue0b4
set -x SILVER_THIN_LEFT_SEPARATOR \ue0b5
set -x SILVER_RIGHT_SEPARATOR \ue0b6
set -x SILVER_THIN_RIGHT_SEPARATOR \ue0b7
set -x SILVER_ICON_FAILED \u2717
set -x SILVER_ICONS nerd
set SILVER_LEFT dir:blue:black git:green:black:red
set SILVER_RIGHT status:black:white cmdtime:magenta:black shell:green:black
This is a feature that p10k provides. The primary use case would be if you have your home directory (dotfiles) in git.
Step to reproduce:
cd
into problematic git repository (*)Environment:
FreeBSD 12.1-STABLE amd64
rustc 1.41.1
(*): attached here: vim-prettier.tar.gz
Backtrace (RUST_BACKTRACE=full
) :
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 9, message: "object not found - no match for id (e5824806aef1edb462faf1dc540b6538ba3acb0e)" }', src/libcore/result.rs:1188:5
stack backtrace:
0: 0x170eec7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h32d82dc921588b09
1: 0x1728e71 - core::fmt::write::h3db4515aabc4ffad
2: 0x170ce12 - std::io::Write::write_fmt::h7fd707b71dba37a5
3: 0x170f8c6 - std::panicking::default_hook::{{closure}}::h611a75bca87583cb
4: 0x170f561 - std::panicking::default_hook::h73492732b8fc4af1
5: 0x170ff8f - std::panicking::rust_panic_with_hook::he2e64fc0f6c38bec
6: 0x170fb53 - rust_begin_unwind
7: 0x172b3dd - core::panicking::panic_fmt::h50e2d5c221f03579
8: 0x17286ba - core::result::unwrap_failed::h1e281a90569cce12
9: 0x12ab841 - core::result::Result<T,E>::unwrap::h302d8abdea227165
at /wrkdirs/usr/ports/lang/rust/work/rustc-1.41.1-src/src/libcore/result.rs:956
10: 0x12a4ee9 - silver::modules::git::segment::ha2446e0eba359d68
at src/modules/git.rs:38
11: 0x12abf69 - silver::modules::handle::ha81b7b61b1d87426
at src/modules/mod.rs:19
12: 0x129ca05 - silver::print::prompt::h3694d5e51ae69af8
at src/print.rs:19
13: 0x129ecff - silver::main::hea77f2ffdf7d4df9
at src/main.rs:67
14: 0x12b6d62 - std::rt::lang_start::{{closure}}::h3272b0ed79d86ac6
at /wrkdirs/usr/ports/lang/rust/work/rustc-1.41.1-src/src/libstd/rt.rs:67
15: 0x170f9d8 - std::panicking::try::do_call::hda18895706f3c060
16: 0x171087f - __rust_maybe_catch_panic
17: 0x1706a18 - std::rt::lang_start_internal::hc08c9bcf7cbc0352
18: 0x12b6d33 - std::rt::lang_start::h240f09e66096250f
at /wrkdirs/usr/ports/lang/rust/work/rustc-1.41.1-src/src/libstd/rt.rs:67
19: 0x129edeb - main
20: 0x129a10d - _start
at /usr/src/lib/csu/amd64/crt1.c:76
Problem under fedora:
$ echo $SILVER_SHELL
/bin/bash
results in
thread 'main' panicked at 'unknown $SILVER_SHELL', src/main.rs:57:18
A possible solution for bash would be to modify in .bashrc
:
export SILVER_SHELL="$(basename $0)"
Another option would be to correctly parse the path of $0
in main.
By the way, the error message would be more helpful (i.e. the use does not need to look at the src), if it includes the current value of $SILVER_SHELL and the supported values.
I followed instructions and after checking with source <(silver init) :
thread 'main' panicked at 'invalid argument, ', /home/webkernel/.cargo/registry/src/github.com-1ecc6299db9ec823/silver-1.1.0/src/print.rs:11:13
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
$(git_prompt_string)
Is there a way to configure Silver in such a way that the prompt appears on a new line after Status line?
Is a similar way to powerline-go powerline-go -newline
for example.
I have this ~/.zshrc
configuration but no value for SILVER_SEPARATOR
appears to do anything:
SILVER=(os:white:blue dir:blue:black git:red:black)
SILVER_SEPARATOR="\ue0b8"
export SILVER_SHELL="zsh"
eval "$(silver init)"
Any ideas?
run cargo install --git https://github.com/reujab/silver run not found, I installed rust via rustup
Split config file in e.g. prompt.toml
and style.css
- first one is only for segment location and behavior settings, second is for style settings (including color)
Given the following config (fish):
set SILVER status:black:white dir:blue:black git:green:black cmdtime:magenta:black
set -x SILVER_DIR_LENGTH 1
set -x SILVER_DIR_ALIASES $HOME/Workspace:\ue796:$HOME/Workspace/go:\ue627
set -x SILVER_SHELL fish
eval (silver init)
I expected to see the go icon when navigating to ~/Workspace/go
.
But the prompt shows: /go 1ms
I am unsure if the output should be <workspace icon>/<go icon>
or simply <go icon>
.
Note: The home directory seems to be a special case here...
TUI for configuring silver
, something like p10k configure
The directory block panics when the current working directory gets deleted:
$ grep -i silver .bashrc
export SILVER_SHELL=bash
SILVER=(user:green:black dir:blue:black git:green:black:yellow virtualenv:white:black time:5e8d87:black status:red:black)
eval "$(silver init)"
dan@Boreas /tmp 9:12PM mkdir -p test && cd test/
dan@Boreas /tmp/test 9:13PM rmdir /tmp/test
dan@Boreas /tmp/test 9:13PM ll
total 0
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
My main issue here is not the panic per-se, but that you end up with a non-functioning shell. In "vanilla" bash you can still cd
into an existing directory, but with the silver prompt active you have to kill the current shell.
Nevertheless, still an awesome prompt: 10/10 will continue to use it ;-)
silver init
looks up the name of its parent process (or, in older versions, at the value of the SILVER_SHELL
environment variable, which you're expected to set to $0
, which comes to the same thing) and uses that to decide what type of shell is running.
If the parent process is a login shell (e.g. invoked by /usr/bin/login
when you log in on a text console, or by sshd
when you log in remotely) then the parent process will have a dash prepended to its name (e.g. -bash
instead of bash
). silver does not recognize this convention and will print a panic message to the effect of "unknown shell: -bash; supported shells: ..."
silver init
should trim a leading dash from the shell
variable before matching on it.
[N.B. with some implementations of su
it's possible for you to get "-su" as the name of the login shell. Rather than trying to deduce the actual identity of the shell from other clues I would suggest restoring the SILVER_SHELL
environment variable and treating it as a way for the user to override silver's idea of the shell in use; when it's set, don't muck around with sysinfo at all.]
Maybe change license to GNU GPLv3?
I added silver to elvish, and i get something like this displayed:
^[[47m^[[34m ^[[44m^[[37m^[[44m^[[30m deathtrip@deathtripPC ^[[42m^[[34m^[[42m^[[30m ^[[0m^[[32m^[[0m
However silver lprint
and silver rprint
display the prompt correctly.
Segment calls a command specified in the arguments, shows its output.
Segments are not dependent on each other, so they can be rendered simultaneously and the concatenated to increase speed
Setting the variable SILVER_CMDTIME_THRESHOLD
to seemingly any value, results in a panic on silver init
.
Values I tried:
thread 'main' panicked at 'invalid $SILVER_CMDTIME_THRESHOLD: UnknownUnit(3, 3)', src/libcore/result.rs:997:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:58
at src/libstd/panicking.rs:200
3: std::panicking::default_hook
at src/libstd/panicking.rs:215
4: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
5: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:385
6: rust_begin_unwind
at src/libstd/panicking.rs:312
7: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
8: core::result::unwrap_failed
9: silver::modules::cmdtime::segment
10: silver::print::prompt
11: silver::main
12: std::rt::lang_start::{{closure}}
13: std::panicking::try::do_call
at src/libstd/rt.rs:49
at src/libstd/panicking.rs:297
14: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:87
15: std::rt::lang_start_internal
at src/libstd/panicking.rs:276
at src/libstd/panic.rs:388
at src/libstd/rt.rs:48
16: main
17: __libc_start_main
18: _start
The reason seems to be, that I forgot to specify the time unit (ms).
Could you document the supported time units?
My system:
9ms silver -V
silver
5s 940ms neofetch
-`
.o+`
`ooo/ oli@x230
`+oooo: --------
`+oooooo: OS: Arch Linux x86_64
-+oooooo+: Host: 23255B2 ThinkPad X230
`/:-:++oooo+: Kernel: 5.0.10-arch1-1-ARCH
`/++++/+++++++: Uptime: 3 hours, 2 mins
`/++++++++++++++: Packages: 676 (pacman)
`/+++ooooooooooooo/` Shell: fish 3.0.2
./ooosssso++osssssso+` WM: sway
.oossssso-````/ossssss+` Theme: Adwaita [GTK2/3]
-osssssso. :ssssssso. Icons: Adwaita [GTK2/3]
:osssssss/ osssso+++. Terminal: alacritty
/ossssssss/ +ssssooo/- Terminal Font: monospace
`/ossssso+/:- -:/+osssso+- CPU: Intel i5-3320M (4) @ 3.300G
`+sso+:-` `.-/+oso: GPU: Intel 3rd Gen Core processo
`++:. `-/+/ Memory: 1626MiB / 15853MiB
.` `/
I tried couple and they don't seem to work. The ones I tried:
The color of the bar is bleeding across the terminal, you can see an image of what it looks like here: bleeding bar color.
It started happening when I upgraded to zsh 5.7
zshrc version: zsh 5.7 (x86_64-pc-linux-gnu)
.zshrc config:
##
# Silver Prompt https://github.com/reujab/silver
##
SILVER=(status:black:white dir:blue:black git:green:black virtualenv:yellow:blue cmdtime:magenta:black
env:red:white:AWS_SHELL)
export SILVER_SHELL=zsh
export SILVER_DIR_ALIASES=$HOME/Development:
eval "$(silver init)"
Bronze had this feature, so it could be added to silver. Note that it would use C ABI, since Rust doesn't have a stable ABI.
I was going to try silver out but I'm having problems. I did a cargo install silver and then init like this.
Invoke-Expression -Command $(silver init | Out-String)
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\silver-1.1.0\src\main.rs:57:55
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Invoke-Expression: Cannot bind argument to parameter 'Command' because it is an empty string.
any ideas what's going on?
Windows 10
Windows Terminal
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> src/main.rs:19:9
|
19 | confy::load("silver")
| ^^^^^^^^^^^ -------- supplied 1 argument
| |
| expected 2 arguments
error: aborting due to previous error
For more information about this error, try `rustc --explain E0061`.
error: failed to compile `silver v1.1.0 (https://github.com/reujab/silver#942e90b2)`
Confy changed the signature of confy::load
in rust-cli/confy#37
Hello,
I'm trying to install and use this prompt on a Mac with ZSH, but am running into issues when I try and run eval $(silver init)
.
I've installed rustup and then run rustup-init -y
and then cargo install silver
without issue.
At that point I set SILVER=(status:black:white dir:blue:black git:green:black cmdtime:magenta:black)
and export SILVER_SHELL=zsh
(both in my ~/.zshrc
file).
Then, when I open a new terminal window and run eval $(silver init)
I get the following:
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/cfdc84a009020c59e53e4039beae22eb59e41685/src/libcore/slice/mod.rs:2689:10
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
I set RUST_BACKTRACE=1
and tried again, with the following results:
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/cfdc84a009020c59e53e4039beae22eb59e41685/src/libcore/slice/mod.rs:2689:10
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::_print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::continue_panic_fmt
6: rust_begin_unwind
7: core::panicking::panic_fmt
8: core::panicking::panic_bounds_check
9: silver::modules::dir::segment
10: silver::print::prompt
11: silver::main
12: std::rt::lang_start::{{closure}}
13: std::panicking::try::do_call
14: __rust_maybe_catch_panic
15: std::rt::lang_start_internal
16: main
Please let me know what you'd recommend. Thanks in advance for the help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.