1. 19

  2. 7

    disown was completely new to me. 25 years of Unix professionally and I’m still surprised (if more often horrified).

    1. 4

      I’ve always used nohup for this.

      1. 8

        Issue with nohup is that you have to know you want to nohup the thing BEFORE invoking it.

        Disown lets you retroactively do this, which is a win for people who aren’t always as mindful as they should be about long running process states :)

        1. 3

          Me too, but the idea that you can disown something that’s already running is neat.

        2. 2

          Ditto - I’ve always used nohup and don’t recall encountering disown before. Interestingly, it’s apparently a shell builtin in ksh93 too (as well as bash since 2.0 and zsh). I’m not sure when it was added to ksh93, but bash 2.0 was released in November 1996. Yikes.

        3. 3

          I read this expected some basics but some of it was new to me, such as pushd/popd. Good writeup.

          1. 3

            I remembered those from your comment, and was kind of expecting more. Recommend checking it out, it’s a fast read for anyone who knows this stuff, and useful to anyone else.

            disown was completely new to me, wonder if zsh has it ;)

            1. [Comment removed by author]

              1. 3

                cd - is actually very useful every time you work in a path location but a build, or something, you invoke elsewhere may remove and recreate the directory. Like with tmux panes, one for build and one for messing around.

                cd - && cd -

                1. 2

                  While I don’t use cd - that often I was quite happy to learn that git checkout - behaves the same but for branches. Also, have a look at ripgrep (discussed here).

              2. 2

                One nice thing not mentioned with the export HISTCONTROL=ignoreboth:erasedups setting is that along with ignoring duplicates (ignoreboth is shorthand for ignoredups and ignorespace) anything you type on the command line with at least one leading space will not be saved in your bash history - this is useful when you have to enter sensitive information like passwords as an option to a command.

                1. 1

                  Interesting article, like many here I didn’t know about disown.

                  To avoid the arrow keys, if you’re already a vi/vim user, it might be easier to set the bash vi option to on (set -o vi). You then have the modes as in vim, and pressing escape lets you use hjkl (so you can use k and j to move in your history), 0 to go to beginning of the line, $ for the end, move around words with w or e or b, etc. Pressing v brings your $EDITOR to edit the line.