3
3
[ ![ crates.io] ( https://img.shields.io/crates/v/zoxide )] ( https://crates.io/crates/zoxide )
4
4
![ .github/workflows/release.yml] ( https://github.com/ajeetdsouza/zoxide/workflows/.github/workflows/release.yml/badge.svg )
5
5
6
- A cd command that learns your habits
6
+ A faster way to navigate your filesystem
7
7
8
8
## Table of contents
9
9
@@ -12,10 +12,10 @@ A cd command that learns your habits
12
12
- [ Getting started] ( #getting-started )
13
13
- [ Installing ` zoxide ` ] ( #step-1-installing-zoxide )
14
14
- [ Adding ` zoxide ` to your shell] ( #step-2-adding-zoxide-to-your-shell )
15
- - [ zsh] ( #zsh )
16
15
- [ bash] ( #bash )
17
16
- [ fish] ( #fish )
18
- - [ POSIX] ( #posix )
17
+ - [ POSIX] ( #posix-shells )
18
+ - [ zsh] ( #zsh )
19
19
- [ Configuration] ( #configuration )
20
20
- [ ` init ` flags] ( #init-flags )
21
21
- [ Environment variables] ( #environment-variables )
@@ -71,14 +71,6 @@ your existing database into `zoxide`:
71
71
zoxide import /path/to/db
72
72
```
73
73
74
- #### zsh
75
-
76
- Add the following line to your ` ~/.zshrc ` :
77
-
78
- ``` sh
79
- eval " $( zoxide init zsh) "
80
- ```
81
-
82
74
#### bash
83
75
84
76
Add the following line to your ` ~/.bashrc ` :
@@ -95,57 +87,57 @@ Add the following line to your `~/.config/fish/config.fish`:
95
87
zoxide init fish | source
96
88
```
97
89
98
- #### POSIX
90
+ #### POSIX shells
99
91
100
92
Add the following line to your shell's configuration file:
101
93
102
94
``` sh
103
- eval " $( zoxide init posix) "
95
+ eval " $( zoxide init posix --hook prompt ) "
104
96
```
105
97
106
- NOTE: If you modify your ` PS1 ` at any point, you may need to re-run the above command. This is due
107
- to the fact that the hook is stored in ` PS1 ` , in order to be evaluated every time the prompt is
108
- displayed.
98
+ The ` prompt ` hook is recommended for POSIX shells because the default ` pwd `
99
+ hook creates a temporary file for every session, which are only deleted upon
100
+ reboot. If you do want to use ` pwd ` hooks instead, you may want to set up traps
101
+ to perform a cleanup once the shell exits:
109
102
110
- NOTE: PWD hooks are currently not supported for POSIX shells.
103
+ ``` sh
104
+ trap ' _zoxide_cleanup' EXIT HUP KILL TERM
105
+ trap ' _zoxide_cleanup; trap - INT; kill -s INT "$$"' INT
106
+ trap ' _zoxide_cleanup; trap - QUIT; kill -s QUIT "$$"' QUIT
107
+ ```
108
+
109
+ NOTE: If you modify your ` PS1 ` at any point, you may need to re-run the above
110
+ command. This is due to the fact that the hook is stored in ` PS1 ` , in order to
111
+ be evaluated every time the prompt is displayed.
112
+
113
+ #### zsh
114
+
115
+ Add the following line to your ` ~/.zshrc ` :
116
+
117
+ ``` sh
118
+ eval " $( zoxide init zsh) "
119
+ ```
111
120
112
121
## Configuration
113
122
114
123
### ` init ` flags
115
124
116
- - ` --hook <HOOK> ` : change the event that adds a new entry to the database (default: ` prompt ` )
117
- - ` none ` : never add entries (this will make ` zoxide ` useless unless you manually configure a hook)
125
+ - ` --cmd ` : change the ` z ` command (and corresponding aliases) to something else
126
+ - ` --hook <HOOK> ` : change the event that adds a new entry to the database
127
+ (default: ` pwd ` )
128
+ - ` none ` : never add entries
129
+ (this will make ` zoxide ` useless unless you manually configure a hook)
118
130
- ` prompt ` : add an entry at every prompt
119
- - ` pwd ` : add an entry whenever you change directories
120
- - ` --no-define-aliases ` : don't define extra aliases like ` zi ` , ` zq ` , ` za ` , and ` zr `
121
- - ` --z-cmd ` : rename the ` z ` command to something else
131
+ - ` pwd ` : add an entry whenever the current directory is changed
132
+ - ` --no-aliases ` : don't define extra aliases like ` zi ` , ` zq ` , ` za ` , and ` zr `
122
133
123
134
### Environment variables
124
135
125
- - ` $_ZO_DATA_DIR ` : directory where ` zoxide ` will store its data files (default:
126
- platform-specific; see the [ ` dirs ` documentation] for more information)
127
- - ` $_ZO_ECHO ` : ` z ` will print the matched directory before navigating to it
128
- - ` $_ZO_EXCLUDE_DIRS ` : list of directories separated by platform-specific
129
- characters ("` : ` " on Linux and macOS, and "` ; ` " on Windows) to be excluded from
130
- the database
136
+ - ` $_ZO_DATA_DIR ` : directory where ` zoxide ` will store its data files
137
+ (default: platform-specific; see the [ ` dirs ` documentation] for more information)
138
+ - ` $_ZO_ECHO ` : when set to ` 1 ` , ` z ` will print the matched directory before navigating to it
139
+ - ` $_ZO_EXCLUDE_DIRS ` : list of directories separated by platform-specific characters
140
+ ("` : ` " on Linux/macOS, "` ; ` " on Windows) to be excluded from the database
131
141
- ` $_ZO_MAXAGE ` : sets the maximum total rank after which entries start getting deleted
132
142
133
143
[ `dirs` documentation ] : https://docs.rs/dirs/latest/dirs/fn.data_local_dir.html
134
-
135
- ## Notes
136
-
137
- If you recently updated ` zoxide ` from an older version to ` v0.3 ` and are
138
- seeing the following error:
139
-
140
- ```
141
- Error: could not deserialize old database
142
-
143
- Caused by:
144
- io error: failed to fill whole buffer
145
- ```
146
-
147
- It is because v0.2 and v0.3 databases are incompatible. There is a script to
148
- automatically migrate your database to the new format, but it seems to be
149
- failing on some systems.
150
-
151
- For a quick fix, you can try removing the old database file: ` rm ~/.zo `
0 commit comments