-
Notifications
You must be signed in to change notification settings - Fork 2
/
rm-newlines-and-paste
executable file
·36 lines (32 loc) · 1.08 KB
/
rm-newlines-and-paste
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
#
# TODO
#
# On LINUX:
# Reads the selection clipboard, removes all new lines, and then saves it into main clipboard.
#
# To setup a shortcut in Ubuntu, use the following steps:
# - Create keyboard shortcut with name: turkish-deasciify-selection-to-clipboard
# - Command: path-to/bashutils/turkish-deasciify-selection-to-clipboard
# - Shortcut: Something that you can easily paste afterwards. My suggestion: Ctrl-F8.
#
# On MAC:
# Reads the main clipboard, removes all newlines, and then saves it into main clipboard.
#
# Gokberk Cinbis, Feb 2024
unameOut="$(\uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
#echo ${machine}
if [[ $machine == "Mac" ]]; then
pbpaste | sed -z 's/\n/ /g' | pbcopy # NOT YET TESTED XXX
echo "Clipboard contents have been updated to remove all newlines."
else
xsel -op | sed -z 's/\n/ /g' | xsel -ib
echo "Clipboard contents have been updated to remove all newlines."
fi