Skip to content

Commit

Permalink
Update docs, document about caching init code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei Dai committed Jul 2, 2012
1 parent f19cdbc commit 1abfbad
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 13 deletions.
11 changes: 11 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Example for a minimal zsh setup (no tab completion):

eval "$(fasd --init posix-alias zsh-hook)"

Note that this method will slightly increase your shell start-up time, since
calling binaries has overhead. You can cache fasd init code if you want minimal
overhead. Example code for bash (to be put into .bashrc):

fasd_cache="$HOME/.fasd-init-bash"
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache"
fi
source "$fasd_cache"
unset fasd_cache

Optionally, if you can also source `fasd` if you want `fasd` to be a shell
function instead of an executable.

Expand Down
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fasd

Fasd ("pronounced similar to 'fast'") is a command-line productivity booster.
Fasd (pronounced similar to "fast") is a command-line productivity booster.
Fasd offers quick access to files and directories for POSIX shells. It is
inspired by tools like [autojump](https://github.com/joelthelion/autojump),
[z](http://github.com/rupa/z) and [v](https://github.com/rupa/v). Fasd keeps
Expand All @@ -16,12 +16,12 @@ Fasd ranks files and directories by "frecency," that is, by both "frequency" and

# Introduction

If you're like me, you use your shell to navigate and launch applications. Fasd
helps you do that more efficiently. With fasd, you can open files regardless of
which directory you are in. Just with a few key strings, fasd can find
a "frecent" file or directory and open it with command you specify. Below are
some hypothetical situations, where you can type in the command on the left and
fasd will "expand" your command into the right side. Pretty magic, huh?
If you use your shell to navigate and launch applications, fasd can help you do
it more efficiently. With fasd, you can open files regardless of which
directory you are in. Just with a few key strings, fasd can find a "frecent"
file or directory and open it with command you specify. Below are some
hypothetical situations, where you can type in the command on the left and fasd
will "expand" your command into the right side. Pretty magic, huh?

```
v def conf => vim /some/awkward/path/to/type/default.conf
Expand Down Expand Up @@ -115,6 +115,19 @@ Example for a minimal zsh setup (no tab completion):
eval "$(fasd --init posix-alias zsh-hook)"
```

Note that this method will slightly increase your shell start-up time, since
calling binaries has overhead. You can cache fasd init code if you want minimal
overhead. Example code for bash (to be put into .bashrc):

```sh
fasd_cache="$HOME/.fasd-init-bash"
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache"
fi
source "$fasd_cache"
unset fasd_cache
```

Optionally, if you can also source `fasd` if you want `fasd` to be a shell
function instead of an executable.

Expand Down Expand Up @@ -167,10 +180,10 @@ You could select an entry in the list of matching files.

# How It Works

When you source `fasd`, fasd adds a hook which will be executed whenever you
execute a command. The hook will scan your commands' arguments and determine if
any of them refer to existing files or directories. If yes, fasd will add them
to the database.
When you run fasd init code or source `fasd`, fasd adds a hook which will be
executed whenever you execute a command. The hook will scan your commands'
arguments and determine if any of them refer to existing files or directories.
If yes, fasd will add them to the database.

# Compatibility

Expand Down
18 changes: 17 additions & 1 deletion fasd.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH FASD 1 "Jun 29, 2012" "fasd user manual"
.TH FASD 1 "Jul 01, 2012" "fasd user manual"
.SH NAME
.PP
fasd - quick access to files and directories
Expand Down Expand Up @@ -100,6 +100,22 @@ eval\ "$(fasd\ --init\ posix-alias\ zsh-hook)"
\f[]
.fi
.PP
Note that this method will slightly increase your shell start-up time,
since calling binaries has overhead.
You can cache fasd init code if you want minimal overhead.
Example code for bash (to be put into .bashrc):
.IP
.nf
\f[C]
fasd_cache="$HOME/.fasd-init-bash"
if\ [\ "$(command\ -v\ fasd)"\ -nt\ "$fasd_cache"\ -o\ !\ -s\ "$fasd_cache"\ ];\ then
\ \ fasd\ --init\ posix-alias\ bash-hook\ bash-ccomp\ bash-ccomp-install\ >|\ "$fasd_cache"
fi
source\ "$fasd_cache"
unset\ fasd_cache
\f[]
.fi
.PP
Optionally, if you can also source \f[C]fasd\f[] if you want
\f[C]fasd\f[] to be a shell function instead of an executable.
.PP
Expand Down
13 changes: 12 additions & 1 deletion fasd.1.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% FASD(1) fasd user manual
% Wei Dai <[email protected]>
% Jun 29, 2012
% Jul 01, 2012

# NAME

Expand Down Expand Up @@ -85,6 +85,17 @@ Example for a minimal zsh setup (no tab completion):

eval "$(fasd --init posix-alias zsh-hook)"

Note that this method will slightly increase your shell start-up time, since
calling binaries has overhead. You can cache fasd init code if you want
minimal overhead. Example code for bash (to be put into .bashrc):

fasd_cache="$HOME/.fasd-init-bash"
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache"
fi
source "$fasd_cache"
unset fasd_cache

Optionally, if you can also source `fasd` if you want `fasd` to be a shell
function instead of an executable.

Expand Down

0 comments on commit 1abfbad

Please sign in to comment.