mirror of
https://github.com/nushell/nushell.git
synced 2025-01-22 06:08:47 +01:00
45ff964cbd
# Description Adds: ```nushell $env.config.show_banner = "short" ``` This will display *only* the startup time. That was the only information from the banner that the user couldn't possibly include in their own config/banner (since it is `-1ns` during startup). This allows one to create their own banner and yet still show the startup time. Example (can be a file named `banner.nu` in autoloads: ```nushell $env.config.show_banner = "short" let ver = (version) print $"(ansi blue_bold)Nushell Release:(ansi reset) ($ver.version) \(($ver.build_os)\)" ``` ![image](https://github.com/user-attachments/assets/dd9d53a2-d89a-432e-8fa3-2d65072e08b1) --- `true` and `false` settings continue to work as they do today. `true` is still the default. # User-Facing Changes New configuration option: ```nushell $env.config.show_banner = "short" ``` # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting ◼️ Update doc ◼️ Update `doc_config.nu`
49 lines
1.7 KiB
Plaintext
49 lines
1.7 KiB
Plaintext
use std/dt [datetime-diff, pretty-print-duration]
|
|
|
|
# Print a banner for nushell with information about the project
|
|
export def banner [
|
|
--short # Only show startup time
|
|
] {
|
|
let dt = (datetime-diff (date now) 2019-05-10T09:59:12-07:00)
|
|
let ver = (version)
|
|
let startup_time = $"(ansi green_bold)Startup Time: (ansi reset)($nu.startup-time)"
|
|
|
|
let banner_msg = match $short {
|
|
true => $"($startup_time)(char newline)"
|
|
|
|
false => $"(ansi green) __ ,(ansi reset)
|
|
(ansi green) .--\(\)°'.' (ansi reset)Welcome to (ansi green)Nushell(ansi reset),
|
|
(ansi green)'|, . ,' (ansi reset)based on the (ansi green)nu(ansi reset) language,
|
|
(ansi green) !_-\(_\\ (ansi reset)where all data is structured!
|
|
|
|
Version: (ansi green)($ver.version) \(($ver.build_os)\)
|
|
Please join our (ansi purple)Discord(ansi reset) community at (ansi purple)https://discord.gg/NtAbbGn(ansi reset)
|
|
Our (ansi green_bold)GitHub(ansi reset) repository is at (ansi green_bold)https://github.com/nushell/nushell(ansi reset)
|
|
Our (ansi green)Documentation(ansi reset) is located at (ansi green)https://nushell.sh(ansi reset)
|
|
(ansi cyan)Tweet(ansi reset) us at (ansi cyan_bold)@nu_shell(ansi reset)
|
|
Learn how to remove this at: (ansi green)https://nushell.sh/book/configuration.html#remove-welcome-message(ansi reset)
|
|
|
|
It's been this long since (ansi green)Nushell(ansi reset)'s first commit:
|
|
(pretty-print-duration $dt)
|
|
|
|
($startup_time)
|
|
"
|
|
}
|
|
|
|
match $env.config?.use_ansi_coloring? {
|
|
false => { $banner_msg | ansi strip }
|
|
_ => $banner_msg
|
|
}
|
|
}
|
|
|
|
# Return the current working directory
|
|
export def pwd [
|
|
--physical (-P) # resolve symbolic links
|
|
] {
|
|
if $physical {
|
|
$env.PWD | path expand
|
|
} else {
|
|
$env.PWD
|
|
}
|
|
}
|