Working on nushell
This commit is contained in:
parent
e7c5979936
commit
8e4f32e9b9
|
@ -20,30 +20,37 @@ $env.config.filesize = {
|
|||
}
|
||||
|
||||
# ls aliases
|
||||
alias builtin_ls = ls
|
||||
alias _ls = ls
|
||||
|
||||
def l [dir?: string] {
|
||||
builtin_ls (if $dir == null { "" } else { $dir }) | sort-by type name -i | grid -c
|
||||
_ls (if $dir == null { "" } else { $dir })
|
||||
| sort-by type name -i | grid -c
|
||||
}
|
||||
|
||||
def ls [dir?: string] {
|
||||
builtin_ls (if $dir == null { "" } else { $dir }) | sort-by type name -i | grid -c
|
||||
_ls (if $dir == null { "" } else { $dir })
|
||||
| sort-by type name -i | grid -c
|
||||
}
|
||||
|
||||
def la [dir?: string] {
|
||||
builtin_ls -al (if $dir == null { "" } else { $dir }) | sort-by type name -i | select mode name target user size modified
|
||||
_ls -al (if $dir == null { "" } else { $dir })
|
||||
| sort-by type name -i
|
||||
| select mode name target user size modified
|
||||
}
|
||||
|
||||
def ll [dir?: string] {
|
||||
builtin_ls -l (if $dir == null { "" } else { $dir }) | sort-by type name -i | select name type target user size modified
|
||||
_ls -l (if $dir == null { "" } else { $dir })
|
||||
| sort-by type name -i
|
||||
| select name type target user size modified
|
||||
}
|
||||
|
||||
# cool df
|
||||
def df [] {
|
||||
^df -h
|
||||
| str replace "Mounted on" "@"
|
||||
| str replace "Sys. de fichiers" "@"
|
||||
| str replace "Monté sur" "@"
|
||||
| detect columns
|
||||
| rename "Filesystem" "Size" "Used" "Avail" "Use%" "Mounted on"
|
||||
| rename "Sys. de fichiers" "Taille" "Utilisé" "Dispo" "Uti%" "Monté sur"
|
||||
}
|
||||
|
||||
# vim aliases
|
||||
|
@ -65,15 +72,82 @@ 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
|
||||
]
|
||||
|
||||
# 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 u = update
|
||||
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) }
|
||||
def-env mkcd [dir: string] { mkdir $dir; cd $dir }
|
||||
|
||||
# Start tfetch
|
||||
tfetch
|
||||
|
|
|
@ -21,27 +21,38 @@ def create_left_prompt [] {
|
|||
}
|
||||
)
|
||||
|
||||
# create a right prompt in magenta with green separators and am/pm underlined
|
||||
let time_color = ansi magenta_bold
|
||||
let time_segment = date now | format date ' [%H:%M] '
|
||||
# Arrow of prompt
|
||||
let arrow_color = if "SSH_CLIENT" in $env {
|
||||
ansi green_bold
|
||||
} else {
|
||||
ansi magenta_bold
|
||||
}
|
||||
|
||||
let arrow_color = ansi magenta_bold
|
||||
let first_line_arrow = "┌──"
|
||||
let second_line_arrow = "└▷"
|
||||
|
||||
# Time
|
||||
let time_color = ansi magenta_bold
|
||||
let time_segment = date now | format date ' [%H:%M] '
|
||||
|
||||
# Name of the current user
|
||||
let username_color = ansi magenta_bold
|
||||
let username = $env.USER
|
||||
|
||||
# Delimiter between user and hostname, then hostname and cwd
|
||||
let delimiter_color = ansi yellow_bold
|
||||
let first_delimiter = "@"
|
||||
let second_delimiter = "::"
|
||||
|
||||
# Hostname
|
||||
let hostname_color = ansi green_bold
|
||||
let hostname = (sys).host.hostname
|
||||
|
||||
# Current director
|
||||
let dir_color = ansi blue_bold
|
||||
let reset_ansi = ansi reset
|
||||
|
||||
# Current git branch, with * if things are not commited
|
||||
let git_color = [(ansi reset), (ansi yellow)] | str join
|
||||
let git_branch = do { git rev-parse --abbrev-ref HEAD }
|
||||
| complete
|
||||
|
@ -56,7 +67,17 @@ def create_left_prompt [] {
|
|||
}
|
||||
|
||||
let git_branch_content = if $git_branch.exit_code == 0 {
|
||||
[$git_color, " ‹", $git_branch.stdout, $git_changed, "› "] | str join
|
||||
[$git_color, " ‹", $git_branch.stdout, $git_changed, "›"] | str join
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
# Current kube
|
||||
let kube_color = ansi cyan_bold
|
||||
let kube = if (echo ~/.kubes/current-cube | path exists) {
|
||||
let kube_name = open ~/.kubes/current-cube | path dirname | path basename
|
||||
[$kube_color, " ‹", $kube_name, "›"] | str join
|
||||
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
@ -77,6 +98,7 @@ def create_left_prompt [] {
|
|||
$dir_color
|
||||
$dir
|
||||
$git_branch_content
|
||||
$kube
|
||||
"\n"
|
||||
$reset_ansi
|
||||
$arrow_color
|
||||
|
@ -153,6 +175,9 @@ $env.NU_PLUGIN_DIRS = [
|
|||
($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins
|
||||
]
|
||||
|
||||
# French by default
|
||||
$env.LANG = fr_FR.UTF-8
|
||||
|
||||
# Text file editor
|
||||
$env.EDITOR = nvim
|
||||
|
||||
|
@ -160,7 +185,7 @@ $env.EDITOR = nvim
|
|||
$env.RUST_BACKTRACE = full
|
||||
|
||||
# Gclone env
|
||||
$env.GCLONE_PATH = '/home/thomas/.git'
|
||||
$env.GCLONE_PATH = '/home/thomas/git'
|
||||
$env.GCLONE_FORCE_SSH = 'true'
|
||||
|
||||
# Python virtual env
|
||||
|
|
Loading…
Reference in New Issue