Created
June 26, 2026 10:38
-
-
Save santiagocasas/2e049b4d7b8f8c14234e2a03b6789932 to your computer and use it in GitHub Desktop.
Xclip copy string in clipboard, strip spaces, copy back
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| if ! command -v xclip >/dev/null 2>&1; then | |
| printf 'stripcopy: xclip is not installed or not in PATH\n' >&2 | |
| exit 1 | |
| fi | |
| cleaned=$(xclip -selection clipboard -o | python3 -c 'import sys; print("".join(sys.stdin.read().split()), end="")') | |
| printf '%s\n' "$cleaned" | |
| printf '%s' "$cleaned" | xclip -selection clipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment