forked from nushell/nu_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example engine-q config script with a module (nushell#108)
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# ~/.config/nushell/config.nu | ||
# | ||
# Nushell-s config file used in engine-q. | ||
# | ||
# It fethes all definitions and environment variables from the `init` module. | ||
|
||
use ~/.config/nushell/init.nu * | ||
|
||
let config = build-config | ||
|
||
alias gd = git diff |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ~/.config/nushell/init.nu | ||
# | ||
# Init module that exports commands and environment variables wanted at startup | ||
|
||
# commands | ||
export def build-config [] { { footer_mode: "50" } } | ||
|
||
export def egd [...rest] { | ||
with-env [GIT_EXTERNAL_DIFF 'difftastic'] { git diff $rest } | ||
} | ||
|
||
# env | ||
export env LS_COLORS { | ||
[ | ||
"di=01;34;2;102;217;239" | ||
"or=00;40;31" | ||
"mi=00;40;31" | ||
"ln=00;36" | ||
"ex=00;32" | ||
] | str collect ':' | ||
} | ||
export env BROWSER { "firefox" } | ||
export env CARGO_TARGET_DIR { "~/.cargo/target" } | ||
export env EDITOR { "nvim" } | ||
export env VISUAL { "nvim" } | ||
export env PAGER { "less" } | ||
export env SHELL { "~/.cargo/bin/nu" } | ||
export env JULIA_NUM_THREADS { (nproc) } | ||
export env HOSTNAME { (hostname | split row '.' | first | str trim) } | ||
export env SHOW_USR { "true" } | ||
|
||
# prompt | ||
export env PROMPT_COMMAND { "build-prompt" } | ||
export def build-prompt [] { | ||
let usr-str = (if $nu.env.SHOW_USR == "true" { | ||
[ | ||
$nu.env.USER | ||
'@' | ||
$nu.env.HOSTNAME | ||
':' | ||
] | str collect | ||
} else { | ||
'' | ||
}) | ||
|
||
let pwd-str = (if (pwd | str starts-with $nu.env.HOME).0 { | ||
(pwd | str find-replace $nu.env.HOME '~' | str trim).0 | ||
} else { | ||
pwd | ||
}) | ||
|
||
[ $usr-str $pwd-str ' ' ] | str collect | ||
} |