Skip to content

Instantly share code, notes, and snippets.

@q60
Last active March 9, 2025 10:10
Show Gist options
  • Save q60/9f3f64e50495d7b25b253b0f80cc49c2 to your computer and use it in GitHub Desktop.
Save q60/9f3f64e50495d7b25b253b0f80cc49c2 to your computer and use it in GitHub Desktop.
nushell fg - job unfreeze but better
module fg-jobs {
export def fg [
id?: int@"jobs completions" # job id
] {
let jobs = jobs
match $id {
null => {
$jobs
}
_ => {
job unfreeze $id
}
}
}
def "jobs completions" [] {
jobs
| each { |row|
{value: $row.id, description: $row.command, style: yellow}
}
}
def jobs [] {
job list
| update pids { |row| $row.pids | first }
| rename --column {pids: pid}
| insert command { |row| add-command $row }
| move command --after id
| sort-by id
}
def add-command [row: record] {
let command =|
ps -l
| where pid == $row.pid
| get command
| first
| split row " "
$"($command.0 | path basename) ($command | skip 1 | str join ' ')"
| str trim
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment