# copy prompt buffer to clipboard
# C-p C-p (chord)

clipcopy() {
  if [[ -n "$BUFFER" ]]; then
    case "$(uname)" in
      Darwin) echo -n "$BUFFER" | pbcopy ;;
      *)      echo -n "$BUFFER" | xclip -sel c 2>/dev/null ;;
    esac
    zle -M "copied"
  fi
}
zle -N clipcopy
bindkey '^p^p' clipcopy
