summaryrefslogtreecommitdiff
path: root/plugins/copyfile/copyfile.plugin.zsh
blob: 3281410e5c5b93a5d35101a8bc77d02a08d26ec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Copies the contents of a given file to the system or X Windows clipboard
#
# Usage: copyfile <file>
function copyfile {
  emulate -L zsh

  if [[ -z "$1" ]]; then
    echo "Usage: copyfile <file>"
    return 1
  fi

  if [[ ! -f "$1" ]]; then
    echo "Error: '$1' is not a valid file."
    return 1
  fi

  clipcopy $1
  echo ${(%):-"%B$1%b copied to clipboard."}
}