module Rfd::Commands
Public Instance Methods
Return to the previous directory (popd).
# File lib/rfd/commands.rb, line 245 def - popd end
Search files and directories from the current directory.
# File lib/rfd/commands.rb, line 250 def / process_command_line preset_command: 'grep' end
“C”opy paths of selected files and directory to the “C”lipboard.
# File lib/rfd/commands.rb, line 133 def C clipboard end
Hard “d”elete selected files and directories.
# File lib/rfd/commands.rb, line 138 def D if selected_items.any? if ask %Q[Are you sure want to delete #{selected_items.one? ? selected_items.first.name : "these #{selected_items.size} files"}? (y/n)] delete end end end
“f”ind the last file or directory of which name starts with the given String.
# File lib/rfd/commands.rb, line 147 def F c = get_char and (@last_command = -> { find_reverse c }).call end
Move the cursor to the bottom of the list.
# File lib/rfd/commands.rb, line 157 def G move_cursor items.size - 1 end
Move the cursor to the top.
# File lib/rfd/commands.rb, line 152 def H move_cursor current_page * max_items end
Ma“K”e a directory.
# File lib/rfd/commands.rb, line 162 def K process_command_line preset_command: 'mkdir' end
Move the cursor to the bottom.
# File lib/rfd/commands.rb, line 167 def L move_cursor current_page * max_items + displayed_items.size - 1 end
Move the cursor to the “M”iddle.
# File lib/rfd/commands.rb, line 172 def M move_cursor current_page * max_items + displayed_items.size / 2 end
“O”pen terminal here.
# File lib/rfd/commands.rb, line 177 def O dir = current_item.directory? ? current_item.path : current_dir.path system %Q[osascript -e 'tell app "Terminal" do script "cd #{dir}" end tell'] if osx? end
“S”ymlink the current file or directory
# File lib/rfd/commands.rb, line 185 def S process_command_line preset_command: 'symlink' end
“T”ouch the current file. This updates current item's timestamp (equivalent to `touch -t`).
# File lib/rfd/commands.rb, line 190 def T process_command_line preset_command: 'touch_t', default_argument: current_item.mtime.tr(': -', '') end
Change permission (“A”ttributes) of selected files and directories.
# File lib/rfd/commands.rb, line 5 def a process_command_line preset_command: 'chmod' end
“c”opy selected files and directories.
# File lib/rfd/commands.rb, line 10 def c process_command_line preset_command: 'cp' end
Move cursor position by mouse click.
# File lib/rfd/commands.rb, line 300 def click(y: nil, x: nil) move_cursor_by_click y: y, x: x end
Mark or unmark “a”ll files and directories.
# File lib/rfd/commands.rb, line 195 def ctrl_a mark = marked_items.size != (items.size - 2) # exclude . and .. items.each {|i| i.toggle_mark unless i.marked? == mark} draw_items draw_marked_items move_cursor current_row end
“b”ack to the previous page.
# File lib/rfd/commands.rb, line 204 def ctrl_b ctrl_p end
“f”orward to the next page.
# File lib/rfd/commands.rb, line 209 def ctrl_f ctrl_n end
Refresh the screen.
# File lib/rfd/commands.rb, line 214 def ctrl_l ls end
Forward to the “n”ext page.
# File lib/rfd/commands.rb, line 219 def ctrl_n move_cursor (current_page + 1) % total_pages * max_items if total_pages > 1 end
Back to the “p”revious page.
# File lib/rfd/commands.rb, line 224 def ctrl_p move_cursor (current_page - 1) % total_pages * max_items if total_pages > 1 end
Split the main “w”indow into given number of columns.
# File lib/rfd/commands.rb, line 229 def ctrl_w if @times spawn_panes @times.to_i ls end end
Soft “d”elete (actually mv to the trash folder on OSX) selected files and directories.
# File lib/rfd/commands.rb, line 15 def d if selected_items.any? if ask %Q[Are you sure want to trash #{selected_items.one? ? selected_items.first.name : "these #{selected_items.size} files"}? (y/n)] trash end end end
cd to the upper hierarchy.
# File lib/rfd/commands.rb, line 291 def del if current_dir.path != '/' dir_was = times == 1 ? current_dir.name : File.basename(current_dir.join(['..'] * (times - 1))) cd File.expand_path(current_dir.join(['..'] * times)) find dir_was end end
Move cursor position and enter
# File lib/rfd/commands.rb, line 305 def double_click(y: nil, x: nil) if move_cursor_by_click y: y, x: x enter end end
Open current file or directory with the “e”ditor
# File lib/rfd/commands.rb, line 24 def e edit end
cd into a directory, or view a file.
# File lib/rfd/commands.rb, line 270 def enter if current_item.name == '.' # do nothing elsif current_item.name == '..' cd '..' elsif in_zip? v elsif current_item.directory? || current_item.zip? cd current_item else v end end
“f”ind the first file or directory of which name starts with the given String.
# File lib/rfd/commands.rb, line 29 def f c = get_char and (@last_command = -> { find c }).call end
Move the cursor to the top of the list.
# File lib/rfd/commands.rb, line 34 def g move_cursor 0 end
Move the cursor to the left pane.
# File lib/rfd/commands.rb, line 39 def h (y = current_row - maxy) >= 0 and move_cursor y end
Move the cursor down.
# File lib/rfd/commands.rb, line 44 def j move_cursor (current_row + times) % items.size end
Move the cursor up.
# File lib/rfd/commands.rb, line 49 def k move_cursor (current_row - times) % items.size end
Move the cursor to the right pane.
# File lib/rfd/commands.rb, line 54 def l (y = current_row + maxy) < items.size and move_cursor y end
“m”ove selected files and directories.
# File lib/rfd/commands.rb, line 59 def m process_command_line preset_command: 'mv' end
Redo the latest f or F
.
# File lib/rfd/commands.rb, line 64 def n @last_command.call if @last_command end
“o”pen selected files and directories with the OS “open” command.
# File lib/rfd/commands.rb, line 69 def o if selected_items.any? system "open #{selected_items.map {|i| %Q["#{i.path}"]}.join(' ')}" elsif %w(. ..).include? current_item.name system %Q[open "#{current_item.path}"] end end
Paste yanked files / directories into the directory on which the cursor is, or into the current directory.
# File lib/rfd/commands.rb, line 78 def p paste end
“q”uit the app.
# File lib/rfd/commands.rb, line 83 def q raise StopIteration if ask 'Are you sure want to exit? (y/n)' end
“q”uit the app!
# File lib/rfd/commands.rb, line 88 def q! raise StopIteration end
“r”ename selected files and directories.
# File lib/rfd/commands.rb, line 93 def r process_command_line preset_command: 'rename' end
“s”ort displayed files and directories in the given order.
# File lib/rfd/commands.rb, line 98 def s process_command_line preset_command: 'sort' end
Toggle mark, and move down.
# File lib/rfd/commands.rb, line 284 def space toggle_mark draw_marked_items j end
Create a new file, or update its timestamp if the file already exists (“t”ouch).
# File lib/rfd/commands.rb, line 103 def t process_command_line preset_command: 'touch' end
“u”narchive .zip and .tar.gz files within selected files and directories into current_directory.
# File lib/rfd/commands.rb, line 108 def u unarchive end
“o”pen selected files and directories with the viewer.
# File lib/rfd/commands.rb, line 113 def v view end
Change o“w”ner of selected files and directories.
# File lib/rfd/commands.rb, line 118 def w process_command_line preset_command: 'chown' end
“y”ank selected file / directory names.
# File lib/rfd/commands.rb, line 123 def y yank end
Archive selected files and directories into a “z”ip file.
# File lib/rfd/commands.rb, line 128 def z process_command_line preset_command: 'zip' end