💾 Archived View for idiomdrottning.org › no_hup captured on 2023-07-10 at 14:03:17. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

No, you hang up!

Today I learned about how in zsh you can write &! after a command to have it be both backgrounded and disowned at the same time. Wow, I would’ve wanted to know that for a long time. I’ve been using cockamamie solutions like dtach (which I’m still gonna keep around for when I want to be able to actually reattach).

And then three seconds later the &! trick was obsoleted when I found out that I can put setopt NO_HUP in .zshrc to always get that behaviour. Which, I get that not everyone wants that, but… I do! It lets me close terminals without fear of killing backgrounded stuff! Still have to worry about suspended things though...💔

Anyway, with NO_HUP set I found that I also wanted to change the dwm scratchpad because otherwise if the launched app is still running but the console is closed, I can’t open new consoles. Here is what I changed it to (where “console” is the window title of the console app I use):

void
togglescratch(const Arg *arg)
{
    Client *c;
    unsigned int found = 0;
    XClassHint ch = { NULL, NULL };

    for (c = selmon->clients; c
           && !(XGetClassHint(dpy, c->win, &ch)
            && strstr(c->name, "console")
            && (found = c->tags & scratchtag)); c = c->next);

    if (found) {
        unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
        if (newtagset) {
            selmon->tagset[selmon->seltags] = newtagset;
            focus(NULL);
            arrange(selmon);
        }
        if (ISVISIBLE(c)) {
            focus(c);
            restack(selmon);
        }
    } else
        spawn(arg);
}

Also until now, I’ve been using this convoluted prompt: %(1j.[%j] .)ellen%%

It displays as ellen% (my hostname) when I have no backgrounded jobs but if I do, it displays as [2] ellen% where the number is how many jobs I have running. Just because I was getting sick and tired of shutting down terminals that also shut down something I cared about. I’m gonna keep using that prompt because unlike the NO_HUP solution, it also cares about suspended jobs, not just backgrounded jobs.

dwm scratchpad