Skip to content

Commit

Permalink
focus on requested folder
Browse files Browse the repository at this point in the history
  • Loading branch information
semicontinuity committed Aug 22, 2023
1 parent 05c1758 commit 6c901f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions fsel/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ def update_recents(recent, rel_path_from_root):

def main():
path_args = [arg for arg in sys.argv[1:] if not arg.startswith('-')]
folder = os.getenv('PWD') if len(path_args) != 1 else os.path.realpath(path_args[0])
debug("main", folder=folder)
wd = os.getenv('PWD')
folder = wd if len(path_args) != 1 else os.path.realpath(path_args[0])
search_root_from_work_dir = '-W' in sys.argv[1:]
target_is_file = '-f' in sys.argv[1:]
target_is_executable = '-x' in sys.argv[1:]
show_dot_files = '-a' in sys.argv[1:]
Expand All @@ -93,7 +94,11 @@ def main():
else:
field_for_recent = 'recent-folders'
all_settings = AllSettingsFolder(os.getenv("HOME") + "/.cache/fsel")
root, folder = find_root(folder, all_settings.roots)
if search_root_from_work_dir:
root, _ = find_root(wd, all_settings.roots)
else:
root, folder = find_root(folder, all_settings.roots)
debug("main", root=root, folder=folder)
settings_for_root = all_settings.load_settings(root)
recent = field_or_else(settings_for_root, field_for_recent, [])
if show_recent:
Expand Down
4 changes: 2 additions & 2 deletions key_bindings.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ __fsel_cd__() {
while true; do
local dir
local res
dir=$(python3 -m fsel.app "${args[@]}")
dir=$(python3 -m fsel.app -W "${args[@]}")
res=$?

# On Alt+Enter, continue with the link target
[[ $res == 80 ]] && args=($(realpath "$dir")) && continue
# On Alt+Home, continue with the parent of the returned root folder
[[ $res == 95 ]] && args=($(dirname "$dir")) && continue
[[ $res == 95 ]] && cd $(dirname "$dir") && args=($dir) && continue

[[ $res == 14 ]] && printf 'rm -rf %q' "$dir"
[[ $res == 0 ]] && printf 'cd %q' "$dir"
Expand Down

0 comments on commit 6c901f4

Please sign in to comment.