This commit is contained in:
Thomas Forgione 2023-11-24 10:14:42 +01:00
parent 5140316764
commit d243a6e69c
8 changed files with 103 additions and 7 deletions

View File

@ -1,4 +1,4 @@
# tildize
# replace /home/$USER by ~
def tildize [] {
if ($in | path split | zip ($env.HOME | path split) | all { $in.0 == $in.1 }) {
($in | str replace $env.HOME "~")
@ -12,7 +12,7 @@ def rm-ext [] {
$in | path parse | udpate extension "" | get parent stem | str join "/"
}
# ls aliases
# ls builtin
alias _ls = ls
def _ls_format_mode [mode: string] {
@ -29,16 +29,19 @@ def _ls_format_mode [mode: string] {
[$r1, $w1, $x1, $r2, $w2, $x2, $r3, $w3, $x3] | each { $in | str join } | str join
}
# quick and easy ls
def l [dir?: string] {
let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i
if ($output | length) == 0 { "" | cat } else { $output | grid -c -s " " | cat }
}
# quick and easy ls
def ls [dir?: string] {
let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i
if ($output | length) == 0 { "" | cat } else { $output | grid -c -s " " | cat }
}
# ls with hidden files
def la [dir?: string] {
_ls -al (if $dir == null { "" } else { $dir })
| sort-by type name -i
@ -46,6 +49,7 @@ def la [dir?: string] {
| select mode name target user size modified
}
# ls with details
def ll [dir?: string] {
_ls -l (if $dir == null { "" } else { $dir })
| each { $in | update mode (_ls_format_mode $in.mode) }
@ -53,14 +57,16 @@ def ll [dir?: string] {
| select mode name target user size modified
}
# cool du (don't display everything)
# du builtin
alias _du = du
# non recursive du
def du [...args] {
let parsed_args = if ($args | is-empty) { ["*"] } else { $args }
$parsed_args | each { _du -a $in | select path apparent physical } | flatten
}
# cool df
# df
def df [] {
^df -h
| str replace "Sys. de fichiers" "@"
@ -77,13 +83,29 @@ def to-md [] {
}
# Useful aliases
# colored ip
alias ip = ip -c
# neovim
alias v = nvim
# quit
alias :q = exit
# evince in background
alias pdf = pueue add evince
# ripgrep
alias rg = rg -uu
# mkdir && cd
def --env mkcd [dir: string] { mkdir $dir; cd $dir }
# run command in background
alias pa = pueue add --immediate
# show background commands
def pst [] {
pueue status -j
| from json

View File

@ -1,10 +1,24 @@
# docker aliases
# lazydocker
alias ld = lazydocker
# docker-compose
alias dc = docker-compose
# docker-compose build
alias dcb = docker-compose build
# docker-compose build and push
def dcp [] { docker-compose build; docker-compose push }
# docker-compose up with build and remove-orphans
alias dcu = docker-compose up -d --build --remove-orphans
# docker-compose down
alias dcd = docker-compose down
# docker-compose down and up
def dcr [] { docker-compose down; docker-compose up -d --build --remove-orphans }
# kubernetes aliases
@ -18,6 +32,7 @@ def _kube_kubes [] {
_ls ~/.kubes | where type == dir | get name | path basename
}
# easily switch kube config
def --env kube [name?: string@_kube_kubes] {
use assert
@ -39,19 +54,22 @@ def --env kube [name?: string@_kube_kubes] {
$env.KUBECONFIG = $kube_config
}
# k9s
alias kns = k9s -n all
# minikube: don't erase my kubeconfig
# start minikube with test kube
def "minikube start" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube start
}
# stop minikube with test kube
def "minikube stop" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube stop
}
# delete minikube with test kube
def "minikube delete" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube delete

View File

@ -9,6 +9,7 @@ def _gclone_dirs [] {
| uniq
}
# cd to a git directory
def --env cdg [key: string@_gclone_dirs] {
let dir = _ls ($env.GCLONE_PATH + "/*")
| append (_ls ($env.GCLONE_PATH + "/*/*"))
@ -70,6 +71,7 @@ def --env cdg [key: string@_gclone_dirs] {
}
}
# clone repository in the right place
def gclone [repo_url: string] {
let attr = if ($repo_url | str starts-with "https://") {

View File

@ -1,16 +1,46 @@
# git aliases
# git
alias g = git
# git add
alias ga = git add
# git add --all
alias gaa = git add --all
# git checkout
alias gco = git checkout
# git checkout -b
alias gcb = git checkout -b
# git commit
alias gc = git commit --verbose
# git commit --all
alias gca = git commit --verbose --all
# git diff
alias gd = git diff
# git log
alias glog = git log --oneline --decorate --graph
# git pull
alias gl = git pull
# git push
alias gp = git push
# git status
alias gst = git status
# git status
alias gs = git status
# git merge
alias gm = git merge
# git push --set-upstream ...
def gpsup [] { git push --set-upstream origin (git rev-parse --abbrev-ref HEAD) }

View File

@ -1,4 +1,5 @@
# pass aliases / completion
def _pass_completion [] {
_ls ~/.password-store/**/* | each { |x|
if $x.type == "file" {
@ -20,8 +21,17 @@ def _pass_completion [] {
export extern "pass" [ host?: string@_pass_completion ]
def p [ arg: string@_pass_completion ] { pass $arg }
# pass shortcut
def p [ ...arg: string@_pass_completion ] {
for a in $arg {
pass $a
}
}
# pass with copy
def pc [ arg: string@_pass_completion ] { pass --clip $arg }
# open pdf encrypted file
def ppdf [p: string] {
pc thomas/key/pdf
pueue add evince $p

View File

@ -15,6 +15,7 @@ def _update_args [] {
]
}
# update system
def u [arg?: string@_update_args] {
if $arg == null {
^update

View File

@ -1,4 +1,4 @@
# nushell-ify xrandr
# xrandr wrapper for nushell
def xrandr [] {
mut output = []
mut current_screen: record<name: string, connected: bool, resolutions: list<string>> = {

View File

@ -240,6 +240,19 @@ $env.GCLONE_FORCE_SSH = true
# Python virtual env
$env.VIRTUAL_ENV = '/home/thomas/.venv'
# 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
}
# 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