DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Copy Full Path Name of a File in Ranger


After version 1.4.0, ranger add a command yp to copy full path name of the selected file with xsel (if there's no xsel on your system, install it with apt).

Install xsel (apt-get install xsel), and modify command of yp to copy the slected filename to system clipboard instead of only the PRIMARY clipboard: Create file $HOME/.config/ranger/rc.conf, add the following line: map yp shell -d echo -n %d/%f | xsel -i -p -b.

Or modify the system-level config file (not recommended): in file /etc/ranger/config/rc.conf, modify map yp shell -d echo -n %d/%f | xsel -i to: map yp shell -d echo -n %d/%f | xsel -i -p -b.

Add -p -b to command yd and yn as well. Here -p means copy to PRIMARY clipboard, while -b means copy to system clipboard.

Now use yp (or yn) to copy full path (or filename), and Ctrl-Shift-v (in console) or Ctrl-v (in GUI app) to paste.

Note: See manpage of xsel for the concept of 3 different clipboard PRIMARY, SECONDARY and CLIPBOARD of X windows.



Published

Aug 16, 2013

Last Updated

Jul 9, 2018

Category

Tech

Tags

  • copy 6
  • linux 158
  • xsel 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor