Skip to content

Instantly share code, notes, and snippets.

@bluetechy
Forked from garywoodfine/pbcopyfy
Created November 7, 2022 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluetechy/efb93b8b0c312054b08016a2c260aae3 to your computer and use it in GitHub Desktop.
Save bluetechy/efb93b8b0c312054b08016a2c260aae3 to your computer and use it in GitHub Desktop.
Simple Script to configure pbcopy like functionality on ubuntu
#!/bin/sh
# 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 https://garywoodfine.com/use-pbcopy-on-ubuntu/
read -p "Do you want to update your package repositories before proceeding ? " -n 1 -r
echo #adding new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
fi
# 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 ];
then
echo 'xclip not installed .... installing now!'
sudo apt install xclip -y;
fi
# Add the aliases to the .bashrc
echo 'updating bash profile'
echo "#pbcopy & pbpaste aliases" >> ~/.bashrc
echo "alias pbcopy='xclip -selection clipboard'" >> ~/.bashrc
echo "alias pbpaste='xclip -selection clipboard -o'" >> ~/.bashrc
source ~/.bashrc
echo 'Complete! happy PbCopy'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment