Skip to content

Instantly share code, notes, and snippets.

@redxef
Last active September 30, 2018 16:27
Show Gist options
  • Save redxef/9ddf91413b82b2e97a5c0a8a0127f8c5 to your computer and use it in GitHub Desktop.
Save redxef/9ddf91413b82b2e97a5c0a8a0127f8c5 to your computer and use it in GitHub Desktop.
# Copy this function into your ~/.bashrc file to make the clipboard work in the WSL.
# This is not beautiful or encouraged, but gets the job done.
pass() {
if [[ "$1" = '-c' ]] || [[ "$1" = '--clip' ]]; then
$(which pass) "$2" | head -n1 | clip.exe
[[ -f ~/.pass-clr-pid ]] && kill "$(cat ~/.pass-clr-pid)"
((sleep 45 && echo '' | clip.exe) && rm ~/.pass-clr-pid) &
local pid=$!
echo "$pid" > ~/.pass-clr-pid
else
$(which pass) "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment