Module: Rfd::Commands::Navigation

Included in:
Rfd::Commands
Defined in:
lib/rfd/commands.rb

Overview

Navigation commands for cursor movement and directory traversal.

Instance Method Summary collapse

Instance Method Details

#-Object

Go back to previous directory.



156
157
158
# File 'lib/rfd/commands.rb', line 156

def -
  popd
end

#backspaceObject

Backspace: Go to parent directory.



147
148
149
150
151
152
153
# File 'lib/rfd/commands.rb', line 147

def backspace
  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

#enterObject

Enter: Open directory or view file.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/rfd/commands.rb', line 127

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
  elsif current_item.image?
    view_image
  elsif current_item.audio?
    play_audio
  elsif current_item.video? || current_item.pdf?
    system 'open', current_item.path if osx?
  else
    v
  end
end