Use this tool to copy a path to a file in a terminal if you want to paste it in a GUI.
The tool
- looksup the absolute path of the file
- formats a
file://
uri - passes it to xclip with the target
text/uri-list
#!/bin/bash | |
# Copies the path to a file as a URI to the clipboard. | |
# This allows pasting the file in GUI applications. | |
set -e | |
if [ ! $# -eq 1 ]; then | |
echo "Usage: $(basename $0) file" >&2 | |
exit 1 | |
fi | |
FILEPATH=$(realpath "$1") | |
echo "file:///$FILEPATH" | xclip -i -selection clipboard -t text/uri-list | |
exit $? |