4 ms·
pbcopy and pbpaste are handy, for a version that works over ssh connections there is osc: https://github.com/theimpostor/osc https://github.com/theimpostor/osc
by gkfasdfasdf 2y ago
pbcopy and pbpaste are handy, for a version that works over ssh connections there is osc: https://github.com/theimpostor/osc https://github.com/theimpostor/osc
- pmarreck 2y agosince 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
- gkfasdfasdf 2y agoThat'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.
- hk1337 2y agoI 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.
- hk1337 2y agoI copied this functionality to linux it's been so useful.
- pak9rabid 2y agoAt my job I have to work with a lot of JSON that's usually minimized. This command has single-handedly saved my sanity: $ pbpaste | jq | pbcopy Then I can paste it into whatever text editor I want and it's all nice & pretty-printed for me. Bonus is that I don't have to change the command at all, just copy the minimized JSON to the clipboard (say from DBeaver, for example), then hit the 'up' arrow and enter.
- mfonda 2y agoI never knew that jq without any arguments pretty-printed JSON. Very useful, and great tip to combine with pbcopy/pbpaste.
- DvdGiessen 2y agoCopying using OSC52 is great! I have a cross-platform shell function for that in my bashrc [1], as well as an implementation that works in vim [2]. [1]: https://github.com/DvdGiessen/dotfiles/blob/2c02332b4a6576909a8d1d233f3cc991845e873a/.bashrc#L483-L502 https://github.com/DvdGiessen/dotfiles/blob/2c02332b4a657690... [2]: https://github.com/DvdGiessen/dotfiles/blob/2c02332b4a6576909a8d1d233f3cc991845e873a/.vimrc#L101-L161 https://github.com/DvdGiessen/dotfiles/blob/2c02332b4a657690...