2023-11-07 13:26:22 +00:00
|
|
|
|
# Nushell Environment Config File
|
|
|
|
|
#
|
|
|
|
|
# version = "0.86.0"
|
|
|
|
|
|
|
|
|
|
def create_left_prompt [] {
|
|
|
|
|
let home = $nu.home-path
|
|
|
|
|
|
|
|
|
|
# Perform tilde substitution on dir
|
|
|
|
|
# To determine if the prefix of the path matches the home dir, we split the current path into
|
|
|
|
|
# segments, and compare those with the segments of the home dir. In cases where the current dir
|
2023-11-07 14:48:00 +00:00
|
|
|
|
# is a parent of the home dir (e.g. `/home`, homedir is `/home/user`), this comparison will
|
2023-11-07 13:26:22 +00:00
|
|
|
|
# also evaluate to true. Inside the condition, we attempt to str replace `$home` with `~`.
|
|
|
|
|
# Inside the condition, either:
|
|
|
|
|
# 1. The home prefix will be replaced
|
|
|
|
|
# 2. The current dir is a parent of the home dir, so it will be uneffected by the str replace
|
|
|
|
|
let dir = (
|
|
|
|
|
if ($env.PWD | path split | zip ($home | path split) | all { $in.0 == $in.1 }) {
|
|
|
|
|
($env.PWD | str replace $home "~")
|
|
|
|
|
} else {
|
|
|
|
|
$env.PWD
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2023-11-07 22:41:30 +00:00
|
|
|
|
# Arrow of prompt
|
|
|
|
|
let arrow_color = if "SSH_CLIENT" in $env {
|
|
|
|
|
ansi green_bold
|
|
|
|
|
} else {
|
|
|
|
|
ansi magenta_bold
|
|
|
|
|
}
|
2023-11-07 14:48:00 +00:00
|
|
|
|
|
|
|
|
|
let first_line_arrow = "┌──"
|
|
|
|
|
let second_line_arrow = "└▷"
|
|
|
|
|
|
2023-11-07 22:41:30 +00:00
|
|
|
|
# Time
|
|
|
|
|
let time_color = ansi magenta_bold
|
|
|
|
|
let time_segment = date now | format date ' [%H:%M] '
|
|
|
|
|
|
|
|
|
|
# Name of the current user
|
2023-11-07 14:48:00 +00:00
|
|
|
|
let username_color = ansi magenta_bold
|
|
|
|
|
let username = $env.USER
|
|
|
|
|
|
2023-11-07 22:41:30 +00:00
|
|
|
|
# Delimiter between user and hostname, then hostname and cwd
|
2023-11-07 14:48:00 +00:00
|
|
|
|
let delimiter_color = ansi yellow_bold
|
|
|
|
|
let first_delimiter = "@"
|
|
|
|
|
let second_delimiter = "::"
|
|
|
|
|
|
2023-11-07 22:41:30 +00:00
|
|
|
|
# Hostname
|
2023-11-07 14:48:00 +00:00
|
|
|
|
let hostname_color = ansi green_bold
|
|
|
|
|
let hostname = (sys).host.hostname
|
2023-11-07 13:26:22 +00:00
|
|
|
|
|
2023-11-07 22:41:30 +00:00
|
|
|
|
# Current director
|
2023-11-07 14:48:00 +00:00
|
|
|
|
let dir_color = ansi blue_bold
|
|
|
|
|
let reset_ansi = ansi reset
|
|
|
|
|
|
2023-11-07 22:41:30 +00:00
|
|
|
|
# Current git branch, with * if things are not commited
|
2023-11-07 16:53:57 +00:00
|
|
|
|
let git_color = [(ansi reset), (ansi yellow)] | str join
|
|
|
|
|
let git_branch = do { git rev-parse --abbrev-ref HEAD }
|
|
|
|
|
| complete
|
2023-11-08 15:55:17 +00:00
|
|
|
|
| update stdout ($in.stdout | str trim -c "\n")
|
2023-11-07 16:53:57 +00:00
|
|
|
|
|
2023-11-07 17:30:41 +00:00
|
|
|
|
let git_status = do { git status -s } | complete | get stdout | str trim -c "\n"
|
2023-11-07 16:53:57 +00:00
|
|
|
|
|
2023-11-07 17:32:03 +00:00
|
|
|
|
let git_changed = if $git_status == "" {
|
2023-11-07 22:41:30 +00:00
|
|
|
|
""
|
2023-11-07 16:53:57 +00:00
|
|
|
|
} else {
|
2023-11-07 22:41:30 +00:00
|
|
|
|
"*"
|
2023-11-07 16:53:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let git_branch_content = if $git_branch.exit_code == 0 {
|
2023-11-07 22:41:30 +00:00
|
|
|
|
[$git_color, " ‹", $git_branch.stdout, $git_changed, "›"] | str join
|
|
|
|
|
} else {
|
|
|
|
|
""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Current kube
|
|
|
|
|
let kube_color = ansi cyan_bold
|
2023-11-08 15:55:17 +00:00
|
|
|
|
let kube = if ("~/.kubes/current-cube" | path exists) {
|
2023-11-07 22:41:30 +00:00
|
|
|
|
let kube_name = open ~/.kubes/current-cube | path dirname | path basename
|
|
|
|
|
[$kube_color, " ‹", $kube_name, "›"] | str join
|
|
|
|
|
|
2023-11-07 16:53:57 +00:00
|
|
|
|
} else {
|
2023-11-07 22:41:30 +00:00
|
|
|
|
""
|
2023-11-07 16:53:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 14:48:00 +00:00
|
|
|
|
[
|
2023-11-07 22:41:30 +00:00
|
|
|
|
$arrow_color
|
|
|
|
|
$first_line_arrow
|
|
|
|
|
$time_color
|
|
|
|
|
$time_segment
|
|
|
|
|
$username_color
|
|
|
|
|
$username
|
|
|
|
|
$delimiter_color
|
|
|
|
|
$first_delimiter
|
|
|
|
|
$hostname_color
|
|
|
|
|
$hostname
|
|
|
|
|
$delimiter_color
|
|
|
|
|
$second_delimiter
|
|
|
|
|
$dir_color
|
|
|
|
|
$dir
|
|
|
|
|
$git_branch_content
|
|
|
|
|
$kube
|
|
|
|
|
"\n"
|
|
|
|
|
$reset_ansi
|
|
|
|
|
$arrow_color
|
|
|
|
|
$second_line_arrow
|
2023-11-07 14:48:00 +00:00
|
|
|
|
] | str join
|
2023-11-07 13:26:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def create_right_prompt [] {
|
|
|
|
|
let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([
|
2023-11-07 16:53:57 +00:00
|
|
|
|
"\e[B"
|
2023-11-07 14:48:00 +00:00
|
|
|
|
(ansi red_bold)
|
|
|
|
|
($env.LAST_EXIT_CODE)
|
|
|
|
|
" ↵ "
|
|
|
|
|
] | str join)
|
|
|
|
|
} else {([
|
2023-11-07 16:53:57 +00:00
|
|
|
|
"\e[B"
|
2023-11-07 14:48:00 +00:00
|
|
|
|
(ansi green_bold)
|
2023-11-07 13:26:22 +00:00
|
|
|
|
($env.LAST_EXIT_CODE)
|
2023-11-07 14:48:00 +00:00
|
|
|
|
" ↵ "
|
2023-11-07 13:26:22 +00:00
|
|
|
|
] | str join)
|
2023-11-07 14:48:00 +00:00
|
|
|
|
}
|
2023-11-07 13:26:22 +00:00
|
|
|
|
|
2023-11-07 14:48:00 +00:00
|
|
|
|
([$last_exit_code] | str join)
|
2023-11-07 13:26:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Use nushell functions to define your right and left prompt
|
|
|
|
|
$env.PROMPT_COMMAND = {|| create_left_prompt }
|
|
|
|
|
# FIXME: This default is not implemented in rust code as of 2023-09-08.
|
|
|
|
|
$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt }
|
|
|
|
|
|
|
|
|
|
# The prompt indicators are environmental variables that represent
|
|
|
|
|
# the state of the prompt
|
2023-11-07 14:48:00 +00:00
|
|
|
|
$env.PROMPT_INDICATOR = {|| " " }
|
2023-11-07 13:26:22 +00:00
|
|
|
|
$env.PROMPT_INDICATOR_VI_INSERT = {|| ": " }
|
|
|
|
|
$env.PROMPT_INDICATOR_VI_NORMAL = {|| "> " }
|
|
|
|
|
$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " }
|
|
|
|
|
|
|
|
|
|
# If you want previously entered commands to have a different prompt from the usual one,
|
|
|
|
|
# you can uncomment one or more of the following lines.
|
|
|
|
|
# This can be useful if you have a 2-line prompt and it's taking up a lot of space
|
|
|
|
|
# because every command entered takes up 2 lines instead of 1. You can then uncomment
|
|
|
|
|
# the line below so that previously entered commands show with a single `🚀`.
|
|
|
|
|
# $env.TRANSIENT_PROMPT_COMMAND = {|| "🚀 " }
|
|
|
|
|
# $env.TRANSIENT_PROMPT_INDICATOR = {|| "" }
|
|
|
|
|
# $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = {|| "" }
|
|
|
|
|
# $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = {|| "" }
|
|
|
|
|
# $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = {|| "" }
|
|
|
|
|
# $env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| "" }
|
|
|
|
|
|
|
|
|
|
# Specifies how environment variables are:
|
|
|
|
|
# - converted from a string to a value on Nushell startup (from_string)
|
|
|
|
|
# - converted from a value back to a string when running external commands (to_string)
|
|
|
|
|
# Note: The conversions happen *after* config.nu is loaded
|
|
|
|
|
$env.ENV_CONVERSIONS = {
|
|
|
|
|
"PATH": {
|
|
|
|
|
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
|
|
|
|
|
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
|
|
|
|
|
}
|
|
|
|
|
"Path": {
|
|
|
|
|
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
|
|
|
|
|
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Directories to search for scripts when calling source or use
|
|
|
|
|
$env.NU_LIB_DIRS = [
|
|
|
|
|
# FIXME: This default is not implemented in rust code as of 2023-09-06.
|
|
|
|
|
($nu.default-config-dir | path join 'scripts') # add <nushell-config-dir>/scripts
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# Directories to search for plugin binaries when calling register
|
|
|
|
|
$env.NU_PLUGIN_DIRS = [
|
|
|
|
|
# FIXME: This default is not implemented in rust code as of 2023-09-06.
|
|
|
|
|
($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins
|
|
|
|
|
]
|
|
|
|
|
|
2023-11-08 11:19:09 +00:00
|
|
|
|
# LS_COLORS so that ls mimics the colors of exa
|
|
|
|
|
$env.LS_COLORS = ([
|
|
|
|
|
# File types
|
|
|
|
|
"ex=1;32" # Executables
|
|
|
|
|
"di=1;34" # Directories
|
|
|
|
|
"ln=36" # Links
|
|
|
|
|
"or=31" # Orphan
|
|
|
|
|
|
|
|
|
|
# Media types
|
|
|
|
|
"*.pdf=32" # PDF files
|
|
|
|
|
|
|
|
|
|
# Images
|
|
|
|
|
"*.webp=35" # Webp image
|
|
|
|
|
"*.png=35" # PNG image
|
|
|
|
|
"*.jpg=35" # JPG image
|
|
|
|
|
|
|
|
|
|
# Music
|
|
|
|
|
"*.ogg=36" # OGG sound
|
|
|
|
|
"*.mp3=36" # MP3 sound
|
|
|
|
|
|
|
|
|
|
# Videos
|
|
|
|
|
"*.mp4=1;35" # MP4 video
|
|
|
|
|
"*.avi=1;35" # AVI video
|
|
|
|
|
"*.webm=1;35" # WebM video
|
|
|
|
|
|
|
|
|
|
# Bold yellow: source code
|
|
|
|
|
"*.c=1;33" # C source
|
|
|
|
|
"*.h=1;33" # C header
|
|
|
|
|
"*.cpp=1;33" # C++ source
|
|
|
|
|
"*.hpp=1;33" # C++ header
|
|
|
|
|
"*.inl=1;33" # C++ include
|
|
|
|
|
"*.cxx=1;33" # C++ include
|
|
|
|
|
"*.py=1;33" # Python
|
|
|
|
|
"*.js=1;33" # JavaScript
|
|
|
|
|
"*.ts=1;33" # TypeScript
|
|
|
|
|
"*.rs=1;33" # Rust
|
|
|
|
|
"*.elm=1;33" # Elm
|
2023-11-08 11:58:43 +00:00
|
|
|
|
"*.nu=1;33" # Nushell
|
2023-11-08 11:19:09 +00:00
|
|
|
|
|
|
|
|
|
# Build / doc files
|
|
|
|
|
"*Makefile=1;4;33" # Makefile
|
|
|
|
|
"*Dockerfile=1;4;33" # Dockerfile
|
|
|
|
|
"*.md=1;4;33" # Markdown
|
|
|
|
|
"*.toml=1;4;33" # Toml
|
|
|
|
|
] | str join ":")
|
|
|
|
|
|
2023-11-07 22:41:30 +00:00
|
|
|
|
# French by default
|
|
|
|
|
$env.LANG = fr_FR.UTF-8
|
|
|
|
|
|
2023-11-21 09:13:44 +00:00
|
|
|
|
# Gnome Keyring Daemon
|
|
|
|
|
$env.GNOME_KEYRING_DAEMON = '/run/user/1000/keyring'
|
|
|
|
|
|
2023-11-07 16:53:57 +00:00
|
|
|
|
# Text file editor
|
|
|
|
|
$env.EDITOR = nvim
|
|
|
|
|
|
|
|
|
|
# Backtrace for rust
|
|
|
|
|
$env.RUST_BACKTRACE = full
|
|
|
|
|
|
|
|
|
|
# Gclone env
|
2023-11-07 22:41:30 +00:00
|
|
|
|
$env.GCLONE_PATH = '/home/thomas/git'
|
2023-11-17 15:25:05 +00:00
|
|
|
|
$env.GCLONE_FORCE_SSH = true
|
2023-11-07 16:53:57 +00:00
|
|
|
|
|
|
|
|
|
# Python virtual env
|
|
|
|
|
$env.VIRTUAL_ENV = '/home/thomas/.venv'
|
|
|
|
|
|
2023-11-24 09:14:42 +00:00
|
|
|
|
# Typst font path
|
|
|
|
|
$env.TYPST_FONT_PATHS = '/home/thomas/.typst'
|
|
|
|
|
|
|
|
|
|
# S3
|
|
|
|
|
$env.AWS_ACCESS_KEY_ID = 'GK534f16d2c3cad87fb41f9b4f'
|
|
|
|
|
$env.AWS_SECRET_ACCESS_KEY = 'ef2b45df075ca20846f7524aac4abe014a68b5d3d338023a40f7ec540f4afdc9'
|
|
|
|
|
$env.AWS_DEFAULT_REGION = 'garage'
|
|
|
|
|
$env.AWS_ENDPOINT = 'https://s3.tforgione.fr'
|
|
|
|
|
|
|
|
|
|
def aws [...args] {
|
|
|
|
|
^aws --endpoint-url $env.AWS_ENDPOINT $args
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 13:26:22 +00:00
|
|
|
|
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
|
|
|
|
|
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
|
2023-11-07 16:53:57 +00:00
|
|
|
|
$env.PATH = ($env.PATH
|
|
|
|
|
| split row (char esep)
|
2023-11-13 10:54:39 +00:00
|
|
|
|
| prepend '/home/thomas/.config/polymny/bin'
|
2023-11-07 16:53:57 +00:00
|
|
|
|
| prepend '/home/thomas/.config/dotfiles/bin'
|
|
|
|
|
| prepend '/home/thomas/.config/dotfiles/bin-extra'
|
|
|
|
|
| prepend '/home/thomas/.cargo/bin'
|
|
|
|
|
| prepend '/home/thomas/.npmbin/bin'
|
|
|
|
|
| prepend '/home/thomas/.venv/bin'
|
|
|
|
|
)
|