Search code examples
linuxcross-platformexplorerfinderwindow-managers

How do I reveal a file as "selected" in *nix from the command line?


Is there a semi-universal mechanism by which to reveal files as selected in various *nix window managers via the command line? For example, in Windows I can say the following:

 explorer.exe /select,C:\TestDir\TestFile.txt

…and Explorer will reveal the file and select it for you. In OS X I can say the following:

 osascript -e 'Tell application "Finder" to reveal "MacHD:Users:myaccount:Desktop:filename.txt"'

…and it will do the same. My question is, is there any way to do the exact same thing (somewhat universally) in any of the various popular *nix flavors across window managers? Obviously "Open Containing Folder" is simple enough, but I want to go the extra step of actually opening it with the specific file selected. Any assistance is appreciated.

Best.


Solution

  • I don't about other file managers (other answers can add that) but for nautilus it's been recently fixed

    This allows to call nautilus uri:///path/to/file from the command line to open uri:///path/to with file pre-selected.