nushell: utilize jobcontrol plugin

This commit is contained in:
LordMZTE 2024-05-20 19:09:44 +02:00
parent ccac84678e
commit c34fbf3504
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
3 changed files with 7 additions and 9 deletions

View file

@ -37,12 +37,6 @@ $env.config = {
]
}
# Run-in-Background function
def & [...argv] {
# TODO: Use a plugin to track number of running jobs
systemd-run --user --same-dir ...$argv
}
# Aliases
def l [path: glob = "."] { ls $path | sort-by type }
def ll [path: glob = "."] { ls -la $path | sort-by type }

View file

@ -22,7 +22,9 @@ pub fn main() !void {
const shell = std.meta.stringToEnum(Shell, std.mem.span(std.os.argv[2])) orelse
return error.InvalidShell;
try shell.writeInitCode(std.mem.span(std.os.argv[0]), stdout.writer());
var stdout_buf = std.io.bufferedWriter(stdout.writer());
try shell.writeInitCode(std.mem.span(std.os.argv[0]), stdout_buf.writer());
try stdout_buf.flush();
} else if (std.mem.eql(u8, verb, "show")) {
const options = prompt.Options{
.status = try std.fmt.parseInt(

View file

@ -12,12 +12,14 @@ const setup_fmtstrs = struct {
\\
;
const nu =
// https://git.mzte.de/LordMZTE/nu-plugin-jobcontrol
\\let mzprompt_has_jobcontrol = (which jobs | length) > 0
\\$env.PROMPT_COMMAND = {{ ||
\\ $env.MZPROMPT_SHELL = "nu"
\\ $env.MZPROMPT_STATUS = $env.LAST_EXIT_CODE
\\ $env.MZPROMPT_VI_MODE = "_none"
\\ $env.MZPROMPT_DURATION = $env.CMD_DURATION_MS
\\ $env.MZPROMPT_JOBS = 0
\\ $env.MZPROMPT_JOBS = if $mzprompt_has_jobcontrol {{ jobs | length }} else {{ 0 }}
\\ {[argv0]s} show
\\}}
\\
@ -26,7 +28,7 @@ const setup_fmtstrs = struct {
\\$env.PROMPT_INDICATOR = ""
\\$env.PROMPT_INDICATOR_VI_INSERT = ""
\\$env.PROMPT_INDICATOR_VI_NORMAL = "〉"
\\$env.PROMPT_MULTILINE_INDICATOR = "::: "
\\$env.PROMPT_MULTILINE_INDICATOR = " | "
\\$env.PROMPT_INDICATOR = ""
\\
;