2023-11-07 15:48:00 +01:00
|
|
|
source ~/.config/nushell/init.nu
|
2023-11-07 14:26:22 +01:00
|
|
|
|
2023-11-07 17:53:57 +01:00
|
|
|
# Change default config
|
|
|
|
$env.config.cursor_shape = {
|
|
|
|
emacs: block
|
|
|
|
vi_insert: block
|
|
|
|
vi_normal: underscore
|
|
|
|
}
|
|
|
|
|
2023-11-07 18:27:51 +01:00
|
|
|
$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"
|
|
|
|
}
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
$env.config.table.mode = light
|
2023-11-08 14:05:43 +01:00
|
|
|
|
2023-11-07 17:53:57 +01:00
|
|
|
# ls aliases
|
2023-11-07 23:41:30 +01:00
|
|
|
alias _ls = ls
|
2023-11-07 14:26:22 +01:00
|
|
|
|
2023-11-08 12:19:09 +01:00
|
|
|
def _ls_format_mode [mode: string] {
|
2023-11-08 16:55:17 +01:00
|
|
|
let chars = $mode | split chars
|
2023-11-08 12:19:09 +01:00
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let r1 = (if ($chars | get 0) == "r" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi yellow_bold), "r", (ansi reset)]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let w1 = (if ($chars | get 1) == "w" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi red_bold), "w", (ansi reset)]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let x1 = (if ($chars | get 2) == "x" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi green_bold), "x", (ansi reset)]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let r2 = (if ($chars | get 3) == "r" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi yellow), "r", (ansi reset)]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let w2 = (if ($chars | get 4) == "w" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi red), "w"]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let x2 = (if ($chars | get 5) == "x" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi green), "x"]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let r3 = (if ($chars | get 6) == "r" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi yellow), "r", (ansi reset)]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let w3 = (if ($chars | get 7) == "w" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi red), "w"]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
let x3 = (if ($chars | get 8) == "x" {
|
2023-11-08 12:19:09 +01:00
|
|
|
[(ansi green), "x"]
|
|
|
|
} else {
|
|
|
|
[(ansi grey), "-"]
|
|
|
|
} | str join)
|
|
|
|
|
|
|
|
[
|
|
|
|
$r1
|
|
|
|
$w1
|
|
|
|
$x1
|
|
|
|
$r2
|
|
|
|
$w2
|
|
|
|
$x2
|
|
|
|
$r3
|
|
|
|
$w3
|
|
|
|
$x3
|
|
|
|
] | str join
|
|
|
|
}
|
|
|
|
|
2023-11-07 17:53:57 +01:00
|
|
|
def l [dir?: string] {
|
2023-11-07 23:41:30 +01:00
|
|
|
_ls (if $dir == null { "" } else { $dir })
|
2023-11-08 12:19:09 +01:00
|
|
|
| sort-by type name -i
|
2023-11-08 14:47:17 +01:00
|
|
|
| grid -c -s " "
|
2023-11-09 14:35:06 +01:00
|
|
|
| cat
|
2023-11-07 14:26:22 +01:00
|
|
|
}
|
|
|
|
|
2023-11-07 17:53:57 +01:00
|
|
|
def ls [dir?: string] {
|
2023-11-07 23:41:30 +01:00
|
|
|
_ls (if $dir == null { "" } else { $dir })
|
2023-11-08 12:19:09 +01:00
|
|
|
| sort-by type name -i
|
2023-11-08 14:47:17 +01:00
|
|
|
| grid -c -s " "
|
2023-11-09 14:35:06 +01:00
|
|
|
| cat
|
2023-11-07 14:26:22 +01:00
|
|
|
}
|
2023-11-07 15:48:00 +01:00
|
|
|
|
2023-11-07 17:53:57 +01:00
|
|
|
def la [dir?: string] {
|
2023-11-07 23:41:30 +01:00
|
|
|
_ls -al (if $dir == null { "" } else { $dir })
|
|
|
|
| sort-by type name -i
|
2023-11-08 16:55:17 +01:00
|
|
|
| each { $in | update mode (_ls_format_mode $in.mode) }
|
2023-11-07 23:41:30 +01:00
|
|
|
| select mode name target user size modified
|
2023-11-07 17:53:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
def ll [dir?: string] {
|
2023-11-07 23:41:30 +01:00
|
|
|
_ls -l (if $dir == null { "" } else { $dir })
|
2023-11-08 16:55:17 +01:00
|
|
|
| each { $in | update mode (_ls_format_mode $in.mode) }
|
2023-11-07 23:41:30 +01:00
|
|
|
| sort-by type name -i
|
2023-11-08 12:19:09 +01:00
|
|
|
| select mode name target user size modified
|
2023-11-07 17:53:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# cool df
|
2023-11-07 15:48:00 +01:00
|
|
|
def df [] {
|
|
|
|
^df -h
|
2023-11-07 23:41:30 +01:00
|
|
|
| str replace "Sys. de fichiers" "@"
|
|
|
|
| str replace "Monté sur" "@"
|
2023-11-07 15:48:00 +01:00
|
|
|
| detect columns
|
2023-11-07 23:41:30 +01:00
|
|
|
| rename "Sys. de fichiers" "Taille" "Utilisé" "Dispo" "Uti%" "Monté sur"
|
2023-11-07 15:48:00 +01:00
|
|
|
}
|
|
|
|
|
2023-11-08 20:17:13 +01:00
|
|
|
# easy markdown formamtter
|
|
|
|
def to-md [] {
|
|
|
|
let arg = $in
|
|
|
|
$env.config.table.mode = markdown;
|
|
|
|
echo $arg
|
|
|
|
}
|
|
|
|
|
2023-11-07 17:53:57 +01:00
|
|
|
# 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) }
|
|
|
|
|
2023-11-07 23:41:30 +01:00
|
|
|
# ssh completion
|
|
|
|
def _ssh_hosts [] {
|
|
|
|
open .ssh/config
|
|
|
|
| lines
|
|
|
|
| find -ir "host "
|
2023-11-08 16:55:17 +01:00
|
|
|
| each { $in | split row " " | get 1 }
|
2023-11-07 23:41:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export extern "ssh" [
|
|
|
|
host?: string@_ssh_hosts
|
|
|
|
]
|
|
|
|
|
2023-11-08 14:39:39 +01:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2023-11-07 23:41:30 +01:00
|
|
|
# gclone aliases
|
|
|
|
def _gclone_dirs [] {
|
|
|
|
let slashes = ($env.GCLONE_PATH | split row "/" | length) + 2
|
|
|
|
open ([$env.GCLONE_PATH, .cdgcache] | path join)
|
|
|
|
| lines
|
2023-11-08 16:55:17 +01:00
|
|
|
| where { ($in | split row "/" | length) >= $slashes }
|
|
|
|
| each { $in | split row "/" | last }
|
2023-11-07 23:41:30 +01:00
|
|
|
| sort
|
|
|
|
| uniq
|
|
|
|
}
|
|
|
|
|
|
|
|
def-env cdg [key: string@_gclone_dirs] { cd (CLICOLOR_FORCE=1 pgd $key) }
|
|
|
|
|
2023-11-09 12:15:45 +01:00
|
|
|
# pass aliases / completion
|
|
|
|
def _pass_completion [] {
|
|
|
|
_ls ~/.password-store/**/* | each { |x|
|
|
|
|
if $x.type == "file" {
|
|
|
|
$x.name
|
|
|
|
| path parse
|
|
|
|
| update extension ""
|
|
|
|
| get parent stem
|
|
|
|
| str join "/"
|
|
|
|
} else {
|
|
|
|
$x.name
|
|
|
|
}
|
|
|
|
| split row '/'
|
|
|
|
| skip 4
|
|
|
|
| str join "/"
|
|
|
|
}
|
|
|
|
| prepend git
|
|
|
|
| prepend insert
|
|
|
|
}
|
|
|
|
|
|
|
|
export extern "pass" [ host?: string@_pass_completion ]
|
2023-11-09 12:16:44 +01:00
|
|
|
def p [ arg: string@_pass_completion ] { pass $arg }
|
|
|
|
def pc [ arg: string@_pass_completion ] { pass --clip $arg }
|
2023-11-09 12:15:45 +01:00
|
|
|
|
2023-11-07 23:41:30 +01:00
|
|
|
# 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)}
|
|
|
|
}
|
|
|
|
|
2023-11-08 16:55:17 +01:00
|
|
|
$kube_config | save -f ([$kubes_path, current-cube] | path join)
|
2023-11-07 23:41:30 +01:00
|
|
|
$env.KUBECONFIG = $kube_config
|
|
|
|
}
|
|
|
|
|
|
|
|
alias kns = k9s
|
|
|
|
|
2023-11-07 17:53:57 +01:00
|
|
|
# Useful aliases
|
|
|
|
alias :q = exit
|
|
|
|
alias pdf = evince
|
|
|
|
alias rg = rg -uu
|
2023-11-07 23:41:30 +01:00
|
|
|
def-env mkcd [dir: string] { mkdir $dir; cd $dir }
|
2023-11-07 17:53:57 +01:00
|
|
|
|
|
|
|
# Start tfetch
|
|
|
|
tfetch
|