Created
December 21, 2016 22:59
-
-
Save PetrGlad/39dc2482e77f48ab1845147670c31bf7 to your computer and use it in GitHub Desktop.
Rust prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "my-prompt" | |
version = "0.1.0" | |
authors = ["Petr Gladkikh <[email protected]>"] | |
[dependencies] | |
nix = "0.7.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate nix; | |
use nix::unistd::*; | |
fn main() { | |
if geteuid() == 0 { | |
println!("\x1b[01;31m⚠\x1b[00m"); // ☠ | |
} else { | |
println!("\x1b[01;32m☯\x1b[00m"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment