Skip to content

Instantly share code, notes, and snippets.

Last active January 5, 2023 11:38
What would you like to do?
Simple Script to configure pbcopy like functionality on ubuntu
# Copyright (C) 2009-2017 Three Nine Consulting
# Always good practice to update packages. However ask user if they would like to do so
# For explanation on how this works and why check out
read -p "Do you want to update your package repositories before proceeding ? " -n 1 -r
echo #adding new line
if [[ $REPLY =~ ^[Yy]$ ]]
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
# Check to see if Xclip is installed if not install it
if [ $(dpkg-query -W -f='${Status}' xclip 2>/dev/null | grep -c "ok installed") -eq 0 ];
echo 'xclip not installed .... installing now!'
sudo apt install xclip -y;
# Add the aliases to the .bashrc
echo 'updating bash profile'
echo "#pbcopy & pbpaste aliases" >> ~/.bash_aliases
echo "alias pbcopy='xclip -selection clipboard'" >> ~/.bash_aliases
echo "alias pbpaste='xclip -selection clipboard -o'" >> ~/.bash_aliases
Copy link

PSLLSP commented Jul 29, 2021

Alias command cannot be called from other scripts or programs, these are usable only from command line.
pbcopy and pbpaste in MacOS are real commands, you can locate them with "which" command and check that these are binary commands...

Some ideas how to create similar commands in Linux are listed here at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment