Parent directory

copypath.plugin.zsh

523 bytes
 1# Copies the path of given directory or file to the system or X Windows clipboard.
 2# Copy current directory if no parameter.
 3function copypath {
 4  # If no argument passed, use current directory
 5  local file="${1:-.}"
 6
 7  # If argument is not an absolute path, prepend $PWD
 8  [[ $file = /* ]] || file="$PWD/$file"
 9
10  # Copy the absolute path without resolving symlinks
11  # If clipcopy fails, exit the function with an error
12  print -n "${file:a}" | clipcopy || return 1
13
14  echo ${(%):-"%B${file:a}%b copied to clipboard."}
15}