dtach(1)

🌸 NAME 🌸

dtach β€” bestie, it's a simple little program that emulates the detach feature of screen. that's it, that's the whole vibe πŸ’…


✨ SYNOPSIS ✨

dtach -a <socket> <options>
dtach -A <socket> <options> <command...>
dtach -c <socket> <options> <command...>
dtach -n <socket> <options> <command...>
dtach -N <socket> <options> <command...>
dtach -p <socket>

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so, dtach is a program that emulates the detach feature of screen. and the way it does it is SO smart β€” it's designed to be transparent and un-intrusive, like a chill friend who doesn't interrupt. it literally avoids interpreting the input and output between attached terminals and the program under its control. no meddling, no commentary, just vibes. consequently, it works best with full-screen applications such as emacs πŸ‘‘

dtach is intended for users who want the detach feature of screen without all the other overhead of screen. it is tiny, it does not use many libraries, and it stays out of the way as much as possible. lowkey the most respectful program ever 🫢

πŸŽ€ SESSIONS πŸŽ€

a session in dtach is a single instance in which a program is running under the control of dtach. the program is disassociated from the original terminal, and is thus protected from your original terminal being disconnected for some reason. so if your ssh decides to ghost you, your stuff is still fine. iconic behavior fr fr πŸ’–

other instances of dtach can attach themselves to a particular session. input and output is copied between the program running in the dtach session, and the attached terminals.

dtach avoids interpreting the communication stream between the program and the attached terminals; it instead relies on the ability of the attached terminals to manage the screen. it just trusts them. mutual respect, periodt ✨

sessions are represented by Unix-domain sockets in the filesystem. no other permission checking other than the filesystem access checks is performed. dtach creates a master process that monitors the session socket, the program, and any attached terminals β€” a true main character, holding it all together πŸ‘‘

🌈 MODES 🌈

dtach has several modes of operation. it can create a new session in which a program is executed, or it can attach to an existing session. the first argument specifies which mode dtach should operate in. so the very first thing you type? that's the whole plot twist.

  • -a β€” attach to an existing session. dtach attaches itself to the session specified by <socket>. after the attach is completed, the window size of the current terminal is sent to the master process, and a redraw is also requested. like, hi, i'm here, and here's my screen size bestie πŸͺŸ
  • -A β€” attach to an existing session, or create a new one. dtach first tries to attach to the session specified by <socket> if possible. if the attempt to open the socket fails, dtach tries to create a new session before attaching to it. it's giving "i'll meet you there, and if you're not there i'll just build the place myself" 😌
  • -c β€” creates a new session. a new session is created in which the specified program is executed. dtach then tries to attach itself to the newly created session. brand new baby session, and you're immediately holding it 🍼
  • -n β€” creates a new session, without attaching to it. a new session is created in which the specified program is executed. dtach does not try to attach to the newly created session, however, and exits instead. set it and forget it, no strings πŸ’…
  • -N β€” creates a new session, without attaching to it or daemonizing. a new session is created in which the specified program is executed. dtach does not try to attach to the newly created session, however, and will stay in the foreground until the program exits. no detaching, no daemon-ing, just sitting right there in the front row the whole time 🍿
  • -p β€” copies the contents of standard input to a session. dtach connects to the session specified by <socket>, copies the contents of standard input to the session, and then exits. dtach will not scan the input for a detach character. it's a one-way pipeline, in and out, no detach drama πŸ™ˆ

πŸ’œ OPTIONS πŸ’œ

dtach has a few options that allow you to modify its behavior. each attaching process can have separate settings for these options, which allows for some flexibility. personalized settings?? we love a customizable queen πŸ‘‘

  • -e <char> β€” sets the detach character to <char>. when the detach character is pressed, dtach detaches itself from the current session and exits. the process running in the session is unaffected by the detach. by default, the detach character is set to ^\ (Ctrl-\). so press it and you're out, but your program doesn't even notice you left πŸ˜­πŸ’”
  • -E β€” disables the detach character. dtach does not try to scan input from the terminal for a detach character. the only way to detach from the session is then by sending the attaching process an appropriate signal. no magic key for you β€” it's signals only, bestie πŸ“‘
  • -r <method> β€” sets the redraw method to <method>. the valid methods are none, ctrl_l, or winch.
    • none disables redrawing completely. zero redraws, not even one. πŸ™…
    • ctrl_l sends a Ctrl L character to the program if the terminal is in character-at-a-time and no-echo mode. that's the little nudge to get the screen to refresh itself ✨
    • winch forces a WINCH signal to be sent to the program. bold. dramatic. effective πŸ”₯

when creating a new session, the specified method is used as the default redraw method for the session. if not specified, the ctrl_l method is used. that's the default, no cap.

  • -z β€” disables processing of the suspend key. normally, dtach will suspend itself when the suspend key is pressed. with this option, the suspend character is sent to the session instead of being handled by dtach. so the key goes straight through to your program instead of pausing everything πŸ’«

πŸ“ EXAMPLES πŸ“

the following example creates a new session that has the detach character and suspend processing disabled. a socket is created in the /tmp directory for the session.

$ dtach -c /tmp/foozle -Ez bash

the following example attaches to the /tmp/foozle session if it exists, and if not, creates a new session using /tmp/foozle as the socket for the session. processing of the suspend character is also disabled for the attach instance.

$ dtach -A /tmp/foozle -z bash

the following example attaches to the /tmp/foozle session, using the winch redraw method to redraw the screen.

$ dtach -a /tmp/foozle -r winch

the following example creates a new session and sets the default redraw method for the session to the winch redraw method.

$ dtach -c /tmp/foozle -r winch bash

πŸ‘‘ AUTHOR πŸ‘‘

Ned T. Crigler <crigler@users.sourceforge.net>. thank you king, we are forever grateful πŸ«‘πŸ’–


🌟 SEE ALSO 🌟

screen(1) β€” the other one. the og. go say hi πŸ’ž


and that's the whole page bestie!! this was dtach version 0.9, from May 2016 β€” yeah she's a little vintage but she ATE and she's still slaying πŸ’…βœ¨ bye ily, go detach from something πŸ¦‹