Config-files/zsh/copyfile.zsh
Victor Lalle 30e94a06db configs
2023-06-04 15:00:13 +02:00

21 lines
439 B
Bash

# Copy the content of a file to the clipboard using xclip
function copyfile() {
if [[ -z $1 ]]; then
echo "Usage: copy-file-to-clipboard <file>"
return 1
fi
if ! command -v xclip &> /dev/null; then
echo "xclip is not installed. Please install it first."
return 1
fi
if [[ ! -f $1 ]]; then
echo "$1 is not a valid file."
return 1
fi
xclip -sel clip < "$1"
echo "$1 content copied to clipboard."
}