]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/copypath/copypath.plugin.zsh
initial
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / copypath / copypath.plugin.zsh
1 # Copies the path of given directory or file to the system or X Windows clipboard.
2 # Copy current directory if no parameter.
3 function 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 }