News for hackers. Stuff that matters.
Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by chasil on Wednesday April 20, 2022 @11:33AM (#31098422)
A lot of these scripts have areas of nuance and subtlety that are likely not addressed.

The backup script that essentially runs cp "$x" "$x.$(date +%y%m%d)" would greatly benefit from the --reflink option to GNU cp, but only when running on a COW filesystem (ZFS or BtrFS). This particularly strikes me.

Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by Self-Perfection on Wednesday April 20, 2022 @04:26PM (#31102532)
Since coreutils 9.0 you don't need to explicitly enable CoW in cp, this behaviour is default now.

https://www.mail-archive.com/[email protected]/msg02953.html

Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by chungy on Wednesday April 20, 2022 @12:36PM (#31099519)
ZFS doesn't (yet) support reflink copies.
Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by chasil on Wednesday April 20, 2022 @12:39PM (#31099564)
Zut alors! I thought it did.
Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by cryptonector on Wednesday April 20, 2022 @04:25PM (#31102517)
For those of us who nest tmux sessions:

  # Map a PID to a tmux session and window
  # in which to find that process (typically
  # $EDITOR):
  #
  function p2mux {
    local fmt='#{session_name} #{window_index} #{pane_tty} #{window_name}'
    find /tmp/tmux-$UID -type s -print0 |
    xargs -0i tmux -S '{}' list-panes -a -F "$fmt" 2>/dev/null |
    grep -w "$(ps -p "$1" -o tty= || echo pts/NO_SUCH_TTY)"
  }
Yes, I nest tmux sessions. I've one session per-project, each running in a window of the same name in a top-level session. I've a different prefix for the top-level (^T) and the nested sessions (^A, because old habits from the days of screen(1) die hard). Every $EDITOR instance goes in a window named after the basename of the file being edited. `p2mux` is very useful in this setup.

Using `pane_pid` to make this more compact is tricky because I want to find processes that might be stopped and not running in the foreground.

Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by raziel2p on Wednesday April 20, 2022 @11:33AM (#31098425)
no offense but how is this getting so many upvotes?
Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by sigmonsays on Thursday April 21, 2022 @11:53AM (#31111090)
it's newb bait.

I dont think any seasoned sys admin or dev would use these, let alone polish it up so much.

Most of these can just be solved by keeping commands in a bash history file and recalling them...

Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by ImTheMaddest on Wednesday April 20, 2022 @12:11PM (#31099083)
Great way to take the fun out of using the Linux CLI.
Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by navanchauhan on Wednesday April 20, 2022 @03:06PM (#31101468)
Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by martinky24 on Wednesday April 20, 2022 @11:17AM (#31098146)
Last commit 2017!
Re:Scripnix: Useful Python3 and bash shell scripts for macOS... by unixhero on Wednesday April 20, 2022 @03:43PM (#31101922)
Maybe it is done