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..e6b371d 100755 --- a/fff +++ b/fff @@ -2,6 +2,19 @@ # # fff - fucking fast file-manager. +# Enable cd on exit by sourcing fff +(return 0 2>/dev/null) && fff_sourced=1 || fff_sourced=0 +if ((fff_sourced)); then + function fff { + command fff "$@" + [[ ${FFF_CD_ON_EXIT:-1} == 1 ]] && + cd "$(cat "${XDG_CACHE_HOME:-${HOME}/.cache}/fff/.fff_d")" + } + unset fff_sourced + return +fi +unset fff_sourced + get_os() { # Figure out the current operating system to set some specific variables. # '$OSTYPE' typically stores the name of the OS kernel.