source ~/.config/nushell/init.nu # Change default config $env.config.cursor_shape = { emacs: block vi_insert: block vi_normal: underscore } $env.config.history = { max_size: 100_000_000_000_000 sync_on_enter: true file_format: "sqlite" isolation: false } $env.config.filesize = { metric: false format: "auto" } $env.config.table.mode = none # ls aliases alias _ls = ls def _ls_format_mode [mode: string] { let chars = echo $mode | split chars let r1 = (if (echo $chars | get 0) == "r" { [(ansi yellow_bold), "r", (ansi reset)] } else { [(ansi grey), "-"] } | str join) let w1 = (if (echo $chars | get 1) == "w" { [(ansi red_bold), "w", (ansi reset)] } else { [(ansi grey), "-"] } | str join) let x1 = (if (echo $chars | get 2) == "x" { [(ansi green_bold), "x", (ansi reset)] } else { [(ansi grey), "-"] } | str join) let r2 = (if (echo $chars | get 3) == "r" { [(ansi yellow), "r", (ansi reset)] } else { [(ansi grey), "-"] } | str join) let w2 = (if (echo $chars | get 4) == "w" { [(ansi red), "w"] } else { [(ansi grey), "-"] } | str join) let x2 = (if (echo $chars | get 5) == "x" { [(ansi green), "x"] } else { [(ansi grey), "-"] } | str join) let r3 = (if (echo $chars | get 6) == "r" { [(ansi yellow), "r", (ansi reset)] } else { [(ansi grey), "-"] } | str join) let w3 = (if (echo $chars | get 7) == "w" { [(ansi red), "w"] } else { [(ansi grey), "-"] } | str join) let x3 = (if (echo $chars | get 8) == "x" { [(ansi green), "x"] } else { [(ansi grey), "-"] } | str join) [ $r1 $w1 $x1 $r2 $w2 $x2 $r3 $w3 $x3 ] | str join } def l [dir?: string] { _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i | grid -c -s " " } def ls [dir?: string] { _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i | grid -c -s " " } def la [dir?: string] { _ls -al (if $dir == null { "" } else { $dir }) | sort-by type name -i | each {|x| return (echo $x | update mode (_ls_format_mode $x.mode))} | select mode name target user size modified } def ll [dir?: string] { _ls -l (if $dir == null { "" } else { $dir }) | each {|x| return (echo $x | update mode (_ls_format_mode $x.mode))} | sort-by type name -i | select mode name target user size modified } # cool df def df [] { ^df -h | str replace "Sys. de fichiers" "@" | str replace "Monté sur" "@" | 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) } # ssh completion def _ssh_hosts [] { open .ssh/config | lines | find -ir "host " | each {|x| echo $x | split row " " | get 1 } } export extern "ssh" [ host?: string@_ssh_hosts ] # update completion def _update_args [] { [ system rust wasm npm dotfiles neovim check startup last-update postpone force-unlock ] } def u [arg?: string@_update_args] { ^update $arg } # gclone aliases def _gclone_dirs [] { let slashes = ($env.GCLONE_PATH | split row "/" | length) + 2 open ([$env.GCLONE_PATH, .cdgcache] | path join) | lines | where {|x| (echo $x | split row "/" | length) >= $slashes } | each {|x| $x | split row "/" | last } | sort | uniq } def-env cdg [key: string@_gclone_dirs] { cd (CLICOLOR_FORCE=1 pgd $key) } # docker aliases alias ld = lazydocker alias dc = docker-compose alias dcb = docker-compose build def dcp [] { docker-compose build; docker-compose push } alias dcu = docker-compose up -d --build --remove-orphans alias dcd = docker-compose down def dcr [] { docker-compose down; docker-compose up -d --build --remove-orphans } # kubernetes aliases $env.KUBECONFIG = if ([$env.HOME, .kubes, current-cube] | path join | path exists) { open ([$env.HOME, .kubes, current-cube] | path join) } else { "" } def _kube_kubes [] { _ls ~/.kubes | where type == dir | get name | path basename } def-env kube [name?: string@_kube_kubes] { use assert let kubes_path = [$env.HOME, .kubes] | path join if $name == null { rm ([$kubes_path, current-cube] | path join) $env.KUBECONFIG = "" return } let kube_config = [$kubes_path, $name, config] | path join if not ($kube_config | path exists) { error make {msg: ([$kube_config, " does not exist"] | str join)} } echo $kube_config | save -f ([$kubes_path, current-cube] | path join) $env.KUBECONFIG = $kube_config } alias kns = k9s # Useful aliases alias :q = exit alias pdf = evince alias rg = rg -uu alias p = pass alias pc = pass --clip def-env mkcd [dir: string] { mkdir $dir; cd $dir } # Start tfetch tfetch