Whenever I need to print out the absolute path of a file, what I am used to doing is first
pwd
, going back and copying that from the output and adding it to the filename on the command line.I made a script as a workaround, for
ln -s
, I named it lns
:
Code: Select all
#! /bin/bash
# applies absolute path to source file (TARGET) using only its short name when creating symbolic link
ln -s "$(realpath -e "$1")" "$2"
Similar to pressing tab to autocomplete a filename that bash recognizes is being typed out, but instead of it being done while it is being typed out, it is done retroactively, as in after I typed out the filename? Or maybe even while I am typing it out, that would work too.
Or is there any way to modify the behavior of tab key to behave in that way, when I specifically want it to?
If there is no built-in way to do this, is there perhaps a way I can define a keyboard shortcut as a script, and have that script echo out the
realpath -e filename.txt
live to the command line for the filename.txt
immediately left to it? And I think that this would be considered echoing it out to "standard input", correct? Since that would essentially be echoing it out live to the command line, which is standard input? (I just want to make sure that my conceptual understanding is accurate of the standard input/output in this context)