diff --git a/README.md b/README.md index a17e4a4..40ba1af 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,11 @@ A simple file manager written in `bash`. **NOTE:** `fff` can be uninstalled easily using `make uninstall`. This removes all of files from your system. ### CD on Exit +#### Bash +```sh +# Add this to your .bashrc or equivalent. +. fff +``` #### Bash and Zsh ```sh # Add this to your .bashrc, .zshrc or equivalent. diff --git a/fff b/fff index 16766e3..107770e 100755 --- a/fff +++ b/fff @@ -2,6 +2,16 @@ # # fff - fucking fast file-manager. +# Enable cd on exit by sourcing fff +if (return 0 2>/dev/null); then + function fff { + command fff "$@" + [[ ${FFF_CD_ON_EXIT:-1} == 1 ]] && + cd "$(cat "${XDG_CACHE_HOME:-${HOME}/.cache}/fff/.fff_d")" + } + return +fi + get_os() { # Figure out the current operating system to set some specific variables. # '$OSTYPE' typically stores the name of the OS kernel.