From 02f14a9cb152561a5e44062aac79f3b700403b40 Mon Sep 17 00:00:00 2001 From: navewindre Date: Sun, 13 Jul 2025 06:42:05 +0200 Subject: omz --- home/.oh-my-zsh/plugins/copypath/copypath.plugin.zsh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 home/.oh-my-zsh/plugins/copypath/copypath.plugin.zsh (limited to 'home/.oh-my-zsh/plugins/copypath/copypath.plugin.zsh') diff --git a/home/.oh-my-zsh/plugins/copypath/copypath.plugin.zsh b/home/.oh-my-zsh/plugins/copypath/copypath.plugin.zsh new file mode 100644 index 0000000..8fe0a85 --- /dev/null +++ b/home/.oh-my-zsh/plugins/copypath/copypath.plugin.zsh @@ -0,0 +1,15 @@ +# Copies the path of given directory or file to the system or X Windows clipboard. +# Copy current directory if no parameter. +function copypath { + # If no argument passed, use current directory + local file="${1:-.}" + + # If argument is not an absolute path, prepend $PWD + [[ $file = /* ]] || file="$PWD/$file" + + # Copy the absolute path without resolving symlinks + # If clipcopy fails, exit the function with an error + print -n "${file:a}" | clipcopy || return 1 + + echo ${(%):-"%B${file:a}%b copied to clipboard."} +} -- cgit v1.2.3