Working on nushell
This commit is contained in:
		
							parent
							
								
									e7c5979936
								
							
						
					
					
						commit
						8e4f32e9b9
					
				| @ -20,30 +20,37 @@ $env.config.filesize = { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # ls aliases | # ls aliases | ||||||
| alias builtin_ls = ls | alias _ls = ls | ||||||
| 
 | 
 | ||||||
| def l [dir?: string] { | 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] { | 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] { | 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] { | 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 | # cool df | ||||||
| def df [] { | def df [] { | ||||||
|     ^df -h |     ^df -h | ||||||
|         | str replace "Mounted on" "@" |         | str replace "Sys. de fichiers" "@" | ||||||
|  |         | str replace "Monté sur" "@" | ||||||
|         | detect columns |         | detect columns | ||||||
|         | rename "Filesystem" "Size" "Used" "Avail" "Use%" "Mounted on" |         | rename "Sys. de fichiers" "Taille" "Utilisé" "Dispo" "Uti%" "Monté sur" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # vim aliases | # vim aliases | ||||||
| @ -65,15 +72,82 @@ alias gst = git status | |||||||
| alias gs = git status | alias gs = git status | ||||||
| def gpsup [] { git push --set-upstream origin (git rev-parse --abbrev-ref HEAD) } | 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 | # Useful aliases | ||||||
| alias :q = exit | alias :q = exit | ||||||
| alias pdf = evince | alias pdf = evince | ||||||
| alias u = update | alias u = ^update | ||||||
| alias rg = rg -uu | alias rg = rg -uu | ||||||
| alias p = pass | alias p = pass | ||||||
| alias pc = pass --clip | alias pc = pass --clip | ||||||
| export def-env mkcd [dir: string] { mkdir $dir; cd $dir } | def-env mkcd [dir: string] { mkdir $dir; cd $dir } | ||||||
| export def-env cdg [key: string] { cd (CLICOLOR_FORCE=1 pgd $key) } |  | ||||||
| 
 | 
 | ||||||
| # Start tfetch | # Start tfetch | ||||||
| tfetch | tfetch | ||||||
|  | |||||||
| @ -21,27 +21,38 @@ def create_left_prompt [] { | |||||||
|         } |         } | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     # create a right prompt in magenta with green separators and am/pm underlined |     # Arrow of prompt | ||||||
|     let time_color = ansi magenta_bold |     let arrow_color = if "SSH_CLIENT" in $env { | ||||||
|     let time_segment = date now | format date ' [%H:%M] ' |         ansi green_bold | ||||||
|  |     } else { | ||||||
|  |         ansi magenta_bold | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     let arrow_color = ansi magenta_bold |  | ||||||
|     let first_line_arrow = "┌──" |     let first_line_arrow = "┌──" | ||||||
|     let second_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_color = ansi magenta_bold | ||||||
|     let username = $env.USER |     let username = $env.USER | ||||||
| 
 | 
 | ||||||
|  |     # Delimiter between user and hostname, then hostname and cwd | ||||||
|     let delimiter_color = ansi yellow_bold |     let delimiter_color = ansi yellow_bold | ||||||
|     let first_delimiter = "@" |     let first_delimiter = "@" | ||||||
|     let second_delimiter = "::" |     let second_delimiter = "::" | ||||||
| 
 | 
 | ||||||
|  |     # Hostname | ||||||
|     let hostname_color = ansi green_bold |     let hostname_color = ansi green_bold | ||||||
|     let hostname = (sys).host.hostname |     let hostname = (sys).host.hostname | ||||||
| 
 | 
 | ||||||
|  |     # Current director | ||||||
|     let dir_color = ansi blue_bold |     let dir_color = ansi blue_bold | ||||||
|     let reset_ansi = ansi reset |     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_color = [(ansi reset), (ansi yellow)] | str join | ||||||
|     let git_branch = do { git rev-parse --abbrev-ref HEAD } |     let git_branch = do { git rev-parse --abbrev-ref HEAD } | ||||||
|       | complete |       | complete | ||||||
| @ -50,37 +61,48 @@ def create_left_prompt [] { | |||||||
|     let git_status = do { git status -s } | complete | get stdout | str trim -c "\n" |     let git_status = do { git status -s } | complete | get stdout | str trim -c "\n" | ||||||
| 
 | 
 | ||||||
|     let git_changed = if $git_status == "" { |     let git_changed = if $git_status == "" { | ||||||
|       "" |         "" | ||||||
|     } else { |     } else { | ||||||
|       "*" |         "*" | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     let git_branch_content = if $git_branch.exit_code == 0 { |     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 { |     } 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 { | ||||||
|  |         "" | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     [ |     [ | ||||||
|       $arrow_color |         $arrow_color | ||||||
|       $first_line_arrow |         $first_line_arrow | ||||||
|       $time_color |         $time_color | ||||||
|       $time_segment |         $time_segment | ||||||
|       $username_color |         $username_color | ||||||
|       $username |         $username | ||||||
|       $delimiter_color |         $delimiter_color | ||||||
|       $first_delimiter |         $first_delimiter | ||||||
|       $hostname_color |         $hostname_color | ||||||
|       $hostname |         $hostname | ||||||
|       $delimiter_color |         $delimiter_color | ||||||
|       $second_delimiter |         $second_delimiter | ||||||
|       $dir_color |         $dir_color | ||||||
|       $dir |         $dir | ||||||
|       $git_branch_content |         $git_branch_content | ||||||
|       "\n" |         $kube | ||||||
|       $reset_ansi |         "\n" | ||||||
|       $arrow_color |         $reset_ansi | ||||||
|       $second_line_arrow |         $arrow_color | ||||||
|  |         $second_line_arrow | ||||||
|     ] | str join |     ] | str join | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -153,6 +175,9 @@ $env.NU_PLUGIN_DIRS = [ | |||||||
|     ($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins |     ($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
|  | # French by default | ||||||
|  | $env.LANG = fr_FR.UTF-8 | ||||||
|  | 
 | ||||||
| # Text file editor | # Text file editor | ||||||
| $env.EDITOR = nvim | $env.EDITOR = nvim | ||||||
| 
 | 
 | ||||||
| @ -160,7 +185,7 @@ $env.EDITOR = nvim | |||||||
| $env.RUST_BACKTRACE = full | $env.RUST_BACKTRACE = full | ||||||
| 
 | 
 | ||||||
| # Gclone env | # Gclone env | ||||||
| $env.GCLONE_PATH = '/home/thomas/.git' | $env.GCLONE_PATH = '/home/thomas/git' | ||||||
| $env.GCLONE_FORCE_SSH = 'true' | $env.GCLONE_FORCE_SSH = 'true' | ||||||
| 
 | 
 | ||||||
| # Python virtual env | # Python virtual env | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user