Bash helpers
copy
# High level examples
run_some_command | copy
pasta > file_from_my_clipboard.txt
# Copy a file's contents
copy < file.txt
# Open a file path from your clipboard
vim "$(pasta)"
# Decode some base64 from the clipboard
pasta | base64 --decode
#!/usr/bin/env bash
set -e
set -u
if hash pbcopy 2>/dev/null; then
exec pbcopy
elif hash xclip 2>/dev/null; then
exec xclip -selection clipboard
elif hash putclip 2>/dev/null; then
exec putclip
else
rm -f /tmp/clipboard 2> /dev/null
if [ $# -eq 0 ]; then
cat > /tmp/clipboard
else
cat "$1" > /tmp/clipboard
fi
fi
pasta
#!/usr/bin/env bash
set -e
set -u
if hash pbpaste 2>/dev/null; then
exec pbpaste
elif hash xclip 2>/dev/null; then
exec xclip -selection clipboard -o
elif [[ -e /tmp/clipboard ]]; then
exec cat /tmp/clipboard
else
echo ''
fi
pastas
current state clipboard:
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
trap 'exit 0' SIGINT
last_value=''
while true
do
value="$(pasta)"
if [ "$last_value" != "$value" ]; then
echo "$value"
last_value="$value"
fi
sleep 0.1
done
# High level example
pastas > everything_i_copied.txt
# Download every link I copy to my clipboard
pastas | wget -i -
mkcd () {
\mkdir -p "$1"
cd "$1"
}
tempe () {
cd "$(mktemp -d)"
chmod -R 0700 .
if [[ $# -eq 1 ]]; then
\mkdir -p "$1"
cd "$1"
chmod -R 0700 .
fi
}
