mirror of
https://github.com/Cian-H/dotfiles.git
synced 2026-01-06 00:51:57 +00:00
Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows) and improves grepability with neovim/telescope
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
The `sockets` command returns a table containing information on network sockets and the processes they belong to.
|
||||
It is basically a join of the tables produced by the `lsof` command, and the nushell `ps` command.
|
||||
|
||||
<img width="1486" alt="image" src="https://user-images.githubusercontent.com/52205/196287615-00e46f8e-06ed-45ce-8fe7-a5c5f38afaaa.png">
|
||||
@@ -0,0 +1,32 @@
|
||||
export def sockets [--abbreviate-java-class-paths (-j)] {
|
||||
let input = (^lsof +c 0xFFFF -i -n -P)
|
||||
let header = ($input | lines
|
||||
| take 1
|
||||
| each { str downcase | str replace ' name$' ' name state' })
|
||||
let body = ($input | lines
|
||||
| skip 1
|
||||
| each { str replace '([^)])$' '$1 (NONE)' | str replace ' \((.+)\)$' ' $1' })
|
||||
[$header] | append $body
|
||||
| to text
|
||||
| detect columns
|
||||
| upsert 'pid' { |r| $r.pid | into int }
|
||||
| rename --column { name: connection }
|
||||
| reject 'command'
|
||||
| join-table (ps -l) 'pid' 'pid'
|
||||
| if $abbreviate_java_class_paths {
|
||||
upsert 'classpath' { |r| $r.command | java-cmd classpath }
|
||||
| upsert 'command' { |r| $r.command | java-cmd abbreviate-classpath }
|
||||
} else { $in }
|
||||
}
|
||||
|
||||
export def 'java-cmd classpath' [] {
|
||||
str replace '.* -classpath +(.+\.jar) +.*' '$1' | split row ':'
|
||||
}
|
||||
|
||||
export def 'java-cmd abbreviate-classpath' [] {
|
||||
str replace '[^ ]*\.jar' '*.jar'
|
||||
}
|
||||
|
||||
export def join-table [table: table, left_on: string, right_on: string] {
|
||||
dfr into df | join ($table | dfr into df) $left_on $right_on | dfr into nu
|
||||
}
|
||||
Reference in New Issue
Block a user