module Rfd::Commands

Public Instance Methods

-() click to toggle source

Return to the previous directory (popd).

# File lib/rfd/commands.rb, line 245
def -
  popd
end
/() click to toggle source

Search files and directories from the current directory.

# File lib/rfd/commands.rb, line 250
def /
  process_command_line preset_command: 'grep'
end
C() click to toggle source

“C”opy paths of selected files and directory to the “C”lipboard.

# File lib/rfd/commands.rb, line 133
def C
  clipboard
end
D() click to toggle source

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() click to toggle source

“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
G() click to toggle source

Move the cursor to the bottom of the list.

# File lib/rfd/commands.rb, line 157
def G
  move_cursor items.size - 1
end
H() click to toggle source

Move the cursor to the top.

# File lib/rfd/commands.rb, line 152
def H
  move_cursor current_page * max_items
end
K() click to toggle source

Ma“K”e a directory.

# File lib/rfd/commands.rb, line 162
def K
  process_command_line preset_command: 'mkdir'
end
L() click to toggle source

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
M() click to toggle source

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() click to toggle source

“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() click to toggle source

“S”ymlink the current file or directory

# File lib/rfd/commands.rb, line 185
def S
  process_command_line preset_command: 'symlink'
end
T() click to toggle source

“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
a() click to toggle source

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() click to toggle source

“c”opy selected files and directories.

# File lib/rfd/commands.rb, line 10
def c
  process_command_line preset_command: 'cp'
end
click(y: nil, x: nil) click to toggle source

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
ctrl_a() click to toggle source

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
ctrl_b() click to toggle source

“b”ack to the previous page.

# File lib/rfd/commands.rb, line 204
def ctrl_b
  ctrl_p
end
ctrl_f() click to toggle source

“f”orward to the next page.

# File lib/rfd/commands.rb, line 209
def ctrl_f
  ctrl_n
end
ctrl_l() click to toggle source

Refresh the screen.

# File lib/rfd/commands.rb, line 214
def ctrl_l
  ls
end
ctrl_n() click to toggle source

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
ctrl_p() click to toggle source

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
ctrl_w() click to toggle source

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
d() click to toggle source

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
del() click to toggle source

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
double_click(y: nil, x: nil) click to toggle source

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
e() click to toggle source

Open current file or directory with the “e”ditor

# File lib/rfd/commands.rb, line 24
def e
  edit
end
enter() click to toggle source

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() click to toggle source

“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
g() click to toggle source

Move the cursor to the top of the list.

# File lib/rfd/commands.rb, line 34
def g
  move_cursor 0
end
h() click to toggle source

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
j() click to toggle source

Move the cursor down.

# File lib/rfd/commands.rb, line 44
def j
  move_cursor (current_row + times) % items.size
end
k() click to toggle source

Move the cursor up.

# File lib/rfd/commands.rb, line 49
def k
  move_cursor (current_row - times) % items.size
end
l() click to toggle source

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() click to toggle source

“m”ove selected files and directories.

# File lib/rfd/commands.rb, line 59
def m
  process_command_line preset_command: 'mv'
end
n() click to toggle source

Redo the latest f or F.

# File lib/rfd/commands.rb, line 64
def n
  @last_command.call if @last_command
end
o() click to toggle source

“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
p() click to toggle source

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() click to toggle source

“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!() click to toggle source

“q”uit the app!

# File lib/rfd/commands.rb, line 88
def q!
  raise StopIteration
end
r() click to toggle source

“r”ename selected files and directories.

# File lib/rfd/commands.rb, line 93
def r
  process_command_line preset_command: 'rename'
end
s() click to toggle source

“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
space() click to toggle source

Toggle mark, and move down.

# File lib/rfd/commands.rb, line 284
def space
  toggle_mark
  draw_marked_items
  j
end
t() click to toggle source

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() click to toggle source

“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
v() click to toggle source

“o”pen selected files and directories with the viewer.

# File lib/rfd/commands.rb, line 113
def v
  view
end
w() click to toggle source

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() click to toggle source

“y”ank selected file / directory names.

# File lib/rfd/commands.rb, line 123
def y
  yank
end
z() click to toggle source

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