From 4116dc127f8a78b3acbebe0912f7fcb47a929129 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Tue, 7 Nov 2023 17:53:57 +0100 Subject: [PATCH] Working on config --- nushell/config.nu | 61 ++++++++++++++++++++++++++++++++++++++++++----- nushell/env.nu | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 6 deletions(-) diff --git a/nushell/config.nu b/nushell/config.nu index cef53ba..9a49f9d 100644 --- a/nushell/config.nu +++ b/nushell/config.nu @@ -1,19 +1,68 @@ source ~/.config/nushell/init.nu +# Change default config +$env.config.cursor_shape = { + emacs: block + vi_insert: block + vi_normal: underscore +} + +# ls aliases alias builtin_ls = ls -def ls [] { - builtin_ls | sort-by type name -i | grid -c +def l [dir?: string] { + builtin_ls (if $dir == null { "" } else { $dir }) | sort-by type name -i | grid -c } -def ll [] { - builtin_ls | sort-by type name -i +def ls [dir?: string] { + builtin_ls (if $dir == null { "" } else { $dir }) | sort-by type name -i | grid -c } +def la [dir?: string] { + builtin_ls -a (if $dir == null { "" } else { $dir }) | sort-by type name -i +} + +def ll [dir?: string] { + builtin_ls (if $dir == null { "" } else { $dir }) | sort-by type name -i +} + +# cool df def df [] { ^df -h - | str replace "Sys. de fichiers" "Filesystem" - | str replace "Monté sur" "Mountpoint" + | str replace "Sys. de fichiers" "@1" + | str replace "Monté sur" "@2" | detect columns + | rename "Sys. de fichiers" "Taille" "Utilisé" "Dispo" "Uti%" "Monté sur" } +# vim aliases +alias v = nvim + +# git aliases +alias g = git +alias ga = git add +alias gaa = git add --all +alias gco = git checkout +alias gcb = git checkout -b +alias gc = git commit --verbose +alias gca = git commit --verbose --all +alias gd = git diff +alias glog = git log --oneline --decorate --graph +alias gl = git pull +alias gp = git push +alias gst = git status +alias gs = git status +def gpsup [] { git push --set-upstream origin (git rev-parse --abbrev-ref HEAD) } + +# Useful aliases +alias :q = exit +alias pdf = evince +alias u = update +alias rg = rg -uu +alias p = pass +alias pc = pass --clip +export def-env mkcd [dir: string] { mkdir $dir; cd $dir } +export def-env cdg [key: string] { cd (CLICOLOR_FORCE=1 pgd $key) } + +# Start tfetch +tfetch diff --git a/nushell/env.nu b/nushell/env.nu index d951118..fd7e14a 100644 --- a/nushell/env.nu +++ b/nushell/env.nu @@ -42,6 +42,25 @@ def create_left_prompt [] { let dir_color = ansi blue_bold let reset_ansi = ansi reset + let git_color = [(ansi reset), (ansi yellow)] | str join + let git_branch = do { git rev-parse --abbrev-ref HEAD } + | complete + | update stdout (echo $in.stdout | str trim -c "\n") + + let git_status = do { git status -s } | complete + + let git_changed = if git_status.stdout == "" { + "" + } else { + "*" + } + + let git_branch_content = if $git_branch.exit_code == 0 { + [$git_color, " ‹", $git_branch.stdout, $git_changed, "› "] | str join + } else { + "" + } + [ $arrow_color $first_line_arrow @@ -57,6 +76,7 @@ def create_left_prompt [] { $second_delimiter $dir_color $dir + $git_branch_content "\n" $reset_ansi $arrow_color @@ -66,11 +86,13 @@ def create_left_prompt [] { def create_right_prompt [] { let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([ + "\e[B" (ansi red_bold) ($env.LAST_EXIT_CODE) " ↵ " ] | str join) } else {([ + "\e[B" (ansi green_bold) ($env.LAST_EXIT_CODE) " ↵ " @@ -131,5 +153,26 @@ $env.NU_PLUGIN_DIRS = [ ($nu.default-config-dir | path join 'plugins') # add /plugins ] +# Text file editor +$env.EDITOR = nvim + +# Backtrace for rust +$env.RUST_BACKTRACE = full + +# Gclone env +$env.GCLONE_PATH = '/home/thomas/.git' +$env.GCLONE_FORCE_SSH = 'true' + +# Python virtual env +$env.VIRTUAL_ENV = '/home/thomas/.venv' + # 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') +$env.PATH = ($env.PATH + | split row (char esep) + | 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' +)