PGID-CD(1)

πŸ“¦ version 26.16.1, in nixos 26.05, nixpkgs unstable

okay so bestie, you’ve opened PGID-CD(1) from the User Contributed Perl Documentation πŸ’– this one is a perl script that’s giving β€œfind the current working directory of a process group and run a command there” energy, and it has opinions about brittleness. slay.

🌸 NAME 🌸

pgid-cd.pl β€” change directory to that of given process and run command ✨

πŸŽ€ SYNOPSIS πŸŽ€

pgid-cd.pl [ -v ] ( pgid | -1 ) command [ args ... ]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so what it does is: it tries to detect the current working directory (or CWD) of the specified process group, and then runs the specified command in that directory. iconic concept, tbh πŸ‘‘

but bestie, CWD detection is brittle and can lead to unexpected results 😭 it is likely to fail if all processes in the given process group run as a user other than the current user (because the current user will simply lack permission to read CWD information). and furthermore, if different processes in the process group have different CWDs, the script will pick an arbitrary one (the one it can access). and of course there’s no hope of it working via a remote connection (e.g. SSH). no cap, that’s just the vibe check it fails πŸ’€

✨ OPTIONS ✨

  • -v β€” if changing directory fails, print all encountered errors. otherwise, silently start the command. note: if present, this must be the first argument. yes, first-first. main character position only πŸ’…
  • pgid or -1 β€” the ID of the process group to detect the CWD of. -1 disables CWD detection, and then the script simply executes the command. periodt.
  • command [ args ... ] β€” the command to execute, bestie. that’s the whole point 🫢

πŸͺŸ TABBEDEX πŸͺŸ

the script was designed to work with the tabbedex urxvt plugin, and in particular its <pink>tab-arguments</pink> configuration resource. for example, if this script is located in ~/.urxvt/tabbedex-pgid-cd, one can use the following configuration:

URxvt.tabbedex.tab-arguments: \
    -e %~/.urxvt/tabbedex-pgid-cd %p %E

or if it’s in /usr/lib/urxvt/tabbedex-pgid-cd, then:

URxvt.tabbedex.tab-arguments: \
    -e /usr/lib/urxvt/tabbedex-pgid-cd %p %E

tabbedex will replace the %p sequence with an ID of a process in the foreground of the current tab, such that the command in the new tab will inherit the current working directory from the existing tab. that’s the whole cute little handoff 🌈✨

πŸ‘‘ SEE ALSO πŸ‘‘

tabbedex(1) and tabbedex-command-runner(1) β€” go read those too, bestie, iykyk πŸ“šπŸ’œ


mwah πŸ’‹ this page is perl v5.42.3, dated 1980-01-01, and that’s the footer sign-off, no cap 🫢

πŸ“¦ where this page comes from