| 1 |
# Change working dir in shell to last dir in lf on exit (adapted from ranger). |
| 2 |
# |
| 3 |
# You need to either copy the content of this file to your shell rc file |
| 4 |
# (e.g. ~/.bashrc) or source this file directly: |
| 5 |
# |
| 6 |
# LFCD="/path/to/lfcd.sh" |
| 7 |
# if [ -f "$LFCD" ]; then |
| 8 |
# source "$LFCD" |
| 9 |
# fi |
| 10 |
# |
| 11 |
# You may also like to assign a key (Ctrl-O) to this command: |
| 12 |
# |
| 13 |
# bind '"\C-o":"lfcd\C-m"' # bash |
| 14 |
# bindkey -s '^o' 'lfcd\n' # zsh |
| 15 |
# |
| 16 |
|
| 17 |
lfcd () { |
| 18 |
# `command` is needed in case `lfcd` is aliased to `lf` |
| 19 |
cd "$(command lf -print-last-dir "$@")" |
| 20 |
} |