Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Enable cd on exit by sourcing the main script
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-Orbison committed Aug 5, 2022
1 parent 6f2dc6f commit 22573de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions fff
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 22573de

Please sign in to comment.