Skip to content

Instantly share code, notes, and snippets.

@ktrysmt
Last active January 19, 2022 13:53
Show Gist options
  • Save ktrysmt/7a969e5cecd7328b2f184fc150368c7d to your computer and use it in GitHub Desktop.
Save ktrysmt/7a969e5cecd7328b2f184fc150368c7d to your computer and use it in GitHub Desktop.
How to share clipboard between HostOS and GuestOS of Vagrant
export DISPLAY=:0
if [ -x /usr/bin/Xvfb ] && [ -x /usr/bin/VBoxClient ] && [ ! -f /tmp/.X11-unix/X0 ]; then
nohup Xvfb -screen 0 120x80x8 > /dev/null 2>&1 &
sleep 0.5
VBoxClient --clipboard
fi
if [ -x /usr/bin/xsel ]; then
alias pbcopy='xsel --display :0 --input --clipboard'
alias pbpaste='xsel --display :0 --output --clipboard'
fi
  1. Activate virtualbox, access to setting > general > advance and change virtualbox's clipboard sharing to "bidirectional".
  2. Install deps by references to setup-ubuntu.sh in your GuestOS (ex: ubuntu).
  3. Put the content of .zshrc to your guest machine's rc-file.
sudo apt-get -y install Xvfb xsel
@imadjamil
Copy link

This is exactly what I was looking for, thanks for sharing!

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