diff --git a/lib/rfd.rb b/lib/rfd.rb index 692fb7f..b228bf7 100644 --- a/lib/rfd.rb +++ b/lib/rfd.rb @@ -144,7 +144,7 @@ def move_cursor(row = nil) # Change the current directory. def cd(dir, pushd: true) - target = File.expand_path(dir.is_a?(Rfd::Item) ? dir.path : dir.start_with?('/') ? dir : current_dir ? File.join(current_dir, dir) : dir) + target = File.expand_path(dir.is_a?(Rfd::Item) ? dir.path : dir.start_with?('/') || dir.start_with?('~') ? dir : current_dir ? File.join(current_dir, dir) : dir) if File.readable? target Dir.chdir target (@dir_history ||= []) << current_dir if current_dir && pushd