News for hackers. Stuff that matters.
Re:Useful built-in macOS command-line utilities by pmarreck on Wednesday November 06, 2024 @08:13AM (#42061773)
since I switch between linux and macos a lot I wrote a dotfile function called "clip" that will work the same on both. nice thing is it will automatically paste if nothing is piped to it to copy so there's no need to use separate commands... although I just realized it might be nice to have a "passthrough" mode that both copies and pastes if you add this to a pipeline in order to capture some intermediate part to the clipboard

    if [[ "$(uname)" == "Darwin" ]]; then
      clip() {
        [ -t 0 ] && pbpaste || pbcopy
      }
    else # assume linux if not macos
      clip() {
        [ -t 0 ] && xclip -o -selection clipboard || xclip -selection clipboard
      }
    fi
Re:Useful built-in macOS command-line utilities by gkfasdfasdf on Wednesday November 06, 2024 @08:22AM (#42061888)
That's handy, thanks! `osc copy` may also take args for files to copy to the clipboard, but in the absence of that and no data on stdin it maybe should switch to paste.
Re:Useful built-in macOS command-line utilities by hk1337 on Wednesday November 06, 2024 @01:24PM (#42066841)
I went the route of managing a different set of dotfiles for linux and macOS. Same repository, just different branches.

Also, falling back to using oh-my-zsh functionality.