mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
Merge pull request #26 from fdncred/main
updated prompt with abbreviated home path
This commit is contained in:
commit
3e4394b378
1 changed files with 17 additions and 1 deletions
|
@ -2,7 +2,8 @@
|
||||||
def construct_prompt [] {
|
def construct_prompt [] {
|
||||||
let decorator = $(char prompt)
|
let decorator = $(char prompt)
|
||||||
# let machine_name = $(sys | get host.hostname)
|
# let machine_name = $(sys | get host.hostname)
|
||||||
let current_dir = $(pwd)
|
# let current_dir = $(pwd)
|
||||||
|
let current_dir = $(home_abbrev)
|
||||||
let git_info = $(do -i { git rev-parse --abbrev-ref HEAD } | str trim | str collect )
|
let git_info = $(do -i { git rev-parse --abbrev-ref HEAD } | str trim | str collect )
|
||||||
let title_bar = $(set_title)
|
let title_bar = $(set_title)
|
||||||
# let git_status = $(git -c core.quotepath=false -c color.status=false status -uall --short --branch)
|
# let git_status = $(git -c core.quotepath=false -c color.status=false status -uall --short --branch)
|
||||||
|
@ -27,6 +28,21 @@ def construct_prompt [] {
|
||||||
|
|
||||||
## put this in your config.toml
|
## put this in your config.toml
|
||||||
# prompt = "construct_prompt"
|
# prompt = "construct_prompt"
|
||||||
|
|
||||||
|
## also you need to source the file in your startup like
|
||||||
|
# "source C:\\Users\\username\\source\\some\\folder\\nu_scripts\\prompt\\left_and_right_prompt.nu",
|
||||||
|
}
|
||||||
|
|
||||||
|
# Abbreviate home path
|
||||||
|
def home_abbrev [] {
|
||||||
|
let is_home_in_path = $(echo $(pwd) | str starts-with $nu.home-dir)
|
||||||
|
if $is_home_in_path {
|
||||||
|
let lin-home = $(echo $nu.home-dir | str find-replace -a '\\' '/' | str downcase)
|
||||||
|
let lin-pwd = $(echo $(pwd) | str find-replace -a '\\' '/' | str downcase)
|
||||||
|
echo $lin-pwd | str find-replace $lin-home '~'
|
||||||
|
} {
|
||||||
|
echo $(pwd)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get Git Info custom commands
|
# Get Git Info custom commands
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue