mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
refactor: ✨ (#418)
* refactor: ✨ move in one commit Eveything in modules should probably be changed to `exported` defs. The idea is to move everything first to keep proper history. * refactor: 📝 add modules readme (wip) * refactor: ✨ small move * refactor: 📝 changed nestring, updated modules readme * refactor: 📝 to document or not to document * fix: 🐛 themes replaced the template to use `main` and regenerated them from lemnos themes. * Revert "fix: 🐛 themes" This reverts commit 4918d3633c8d2d81950a0ed0cfd9eb84241bc886. * refactor: ✨ introduce sourced - Created a source `root` in which sourcable demos are stored. Some might get converted to modules later on. - Moved some files to bin too. * fix: 🐛 fehbg.nu * fix: 🐛 modules/after.nu * moved some other stuff around --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
parent
382696cd21
commit
c47ccd42b8
128 changed files with 185 additions and 12 deletions
4
modules/network/sockets/README.md
Normal file
4
modules/network/sockets/README.md
Normal file
|
@ -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">
|
32
modules/network/sockets/sockets.nu
Normal file
32
modules/network/sockets/sockets.nu
Normal file
|
@ -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 -c ['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] {
|
||||
into df | join ($table | into df) $left_on $right_on | into nu
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue