From b9f5ffd0d3ad2f5744fc6ca3b497e3278aa78f35 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Wed, 23 Oct 2024 20:01:31 +0900 Subject: Add a few scripts --- bin/scripts/cclip | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 bin/scripts/cclip (limited to 'bin/scripts/cclip') diff --git a/bin/scripts/cclip b/bin/scripts/cclip new file mode 100755 index 0000000..29320ad --- /dev/null +++ b/bin/scripts/cclip @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +# Copy text from the standard input to the clipboard. +# If connected from an ssh session, use clipper to send back to local computer. +# Otherwise just use xclip. + +# The code block checks whether it is an ssh session or not. +# If so, SESSION_TYPE is set to remote/ssh. +if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + SESSION_TYPE=remote/ssh +else + case $(ps -o comm= -p "$PPID") in + sshd|*/sshd) SESSION_TYPE=remote/ssh;; + esac +fi + +if [ "$SESSION_TYPE" = "remote/ssh" ]; then + nc -q 0 -U ~/.clipper.sock +else + xclip -sel clip +fi -- cgit v1.2.3-70-g09d2