Hello,
first thanks for this wonderful and useful utility.
Would it be possible to add a way to go up the parent directory ? It would be especially useful when selecting a file via the Ctrl-T shortcut.
Thanks
fzf is just a unix filter (like grep) that does not know the meaning of the items that it processes, so it's not possible to change the source dynamically. If you're on bash you can try using fuzzy completion although it won't be as easy as just hitting CTRL-T.
vim ../**<TAB>
Just leaving this here, you can do that with the following
$(cd .. && fzf)
In case you need the full path name, you can do
$(cd .. && find "$PWD" | fzf)
Also, just leaving a note... I got it working this way (minimal example):
A function:
function F() { cd "$(fzf_cd "$PWD" )" }
A script (here named fzf_cd):
#!/bin/bash
FD=$( fd --type directory --color=always "." "$1" )
CD=$( echo "$FD" | fzf -m --bind "shift-left:abort+execute(fzf_cd '$1/..' )" )
echo "$CD"
The two parts (FD, CD) need to be separated so that there is at least '\n' piped to fzf (it won't work if fd produces no results in a leaf-directory).
You can make it work in ranger, by having this in your commands.py:
class fzf_cd(Command):
def execute(self):
exec = self.fm.execute_command("fzf_cd .", universal_newlines=True, stdout=PIPE)
stdout, stderr = exec.communicate()
if exec.returncode == 0:
dest = stdout.rstrip('\n')
if os.path.isdir(dest):
self.fm.cd(dest)
elif os.path.isfile(dest):
self.fm.select_file(dest)
I would love to see a deeper integration of ranger and fzf, they're just meant to be together!
Most helpful comment
Just leaving this here, you can do that with the following
In case you need the full path name, you can do