Skip to content

Latest commit

 

History

History
38 lines (34 loc) · 951 Bytes

003.SuperChargedTerminal-lfcd.md

File metadata and controls

38 lines (34 loc) · 951 Bytes

Advanced File Manager for the Terminal

Idea: Bind a Shortcut to use LF (or, Ranger Terminal File managers), and use a custom function to CD to the selection
  1. Install lf
  2. Create a function to cd into the location returned by lf
function lfcd () {
    tmp="$(mktemp)"
    lf -last-dir-path="$tmp" "$@"
    if [ -f "$tmp" ]; then
        dir="$(cat "$tmp")"
        rm -f "$tmp"
        [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
    fi
}
  1. Add keybinding to run lfcd when pressing Ctrl+O
bindkey -s '^o' 'lfcd\n'
  1. (Optional) Modify lf config for custom keybinding to lf functions ~/.config/lf/lfrc
# Use the default space to mark (select) files
map <enter> quit
map <esc> shell
map . set hidden!
map c copy
map x cut
map v paste

# Reset default `d` marking, and delete to 
map d
map dd $IFS=':'; rm -rf $fx