Skip to content

Instantly share code, notes, and snippets.

@snuffop
Last active March 3, 2024 04:16
Show Gist options
  • Save snuffop/1706122f8fcc4f3575bebe37abab1a21 to your computer and use it in GitHub Desktop.
Save snuffop/1706122f8fcc4f3575bebe37abab1a21 to your computer and use it in GitHub Desktop.
Use with fasd(command) plugin for ranger to give a list of fasd directories fuzzy search with fzf and change directory on enter.
class fasd_dir(Command):
def execute(self):
import subprocess
import os.path
fzf = self.fm.execute_command("fasd -dl | grep -iv cache | fzf 2>/dev/tty", universal_newlines=True, stdout=subprocess.PIPE)
stdout, stderr = fzf.communicate()
if fzf.returncode == 0:
fzf_file = os.path.abspath(stdout.rstrip('\n'))
print(fzf_file)
if os.path.isdir(fzf_file):
self.fm.cd(fzf_file)
else:
self.fm.select_file(fzf_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment