Skip to content

Commit 2cbc06d

Browse files
committed
Add shell setup installer
1 parent 6e1f44c commit 2cbc06d

3 files changed

Lines changed: 445 additions & 25 deletions

File tree

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,49 @@ sudo pacman -S fd ripgrep bat
3939

4040
```bash
4141
brew install ioma8/tap/fishez
42+
fishez --install-shell
43+
fz ~/projects
4244
```
4345

44-
Then enable the `fz` shell wrapper below.
46+
Homebrew will also remind you to run `fishez --install-shell` after install.
4547

4648
### One-line binary installer
4749

4850
```bash
4951
curl -sfL https://raw.githubusercontent.com/ioma8/fishez/main/install.sh | sh
5052
```
5153

52-
The installer downloads the latest GitHub release and adds the `fz` wrapper to `.zshrc` / `.bashrc` when it can.
54+
The installer downloads the latest GitHub release and runs `fishez --install-shell` when it can.
5355

5456
### Build with Cargo
5557

5658
Requires Rust and CMake.
5759

5860
```bash
5961
cargo install fishez
62+
fishez --install-shell
63+
fz
6064
```
6165

6266
### Enable `fz`
6367

6468
`fz` is a tiny shell function around `fishez`. It opens the file manager and, when you quit, changes your shell into the directory you were browsing. Use `fishez` directly if you want to browse without changing the parent shell directory.
6569

66-
Append the setup line to your shell rc file:
70+
Run this once after installing with Homebrew or Cargo:
71+
72+
```bash
73+
fishez --install-shell
74+
```
75+
76+
It detects zsh, bash, or fish and installs the `fz` wrapper if it is not already present. Then open a new terminal, or source the file it prints.
77+
78+
To remove the wrapper later:
79+
80+
```bash
81+
fishez --uninstall-shell
82+
```
83+
84+
If you prefer to do it manually, append the setup line to your shell rc file:
6785

6886
```bash
6987
# zsh

install.sh

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ case "$OS" in
1717
*)
1818
echo "Unsupported OS: $OS"
1919
echo "Try: cargo install fishez"
20-
echo 'Then add eval "$(fishez --init)" to your shell rc for fz.'
20+
echo "Then run: fishez --install-shell"
2121
exit 1
2222
;;
2323
esac
@@ -28,7 +28,7 @@ case "$ARCH" in
2828
*)
2929
echo "Unsupported architecture: $ARCH"
3030
echo "Try: cargo install fishez"
31-
echo 'Then add eval "$(fishez --init)" to your shell rc for fz.'
31+
echo "Then run: fishez --install-shell"
3232
exit 1
3333
;;
3434
esac
@@ -56,22 +56,8 @@ else
5656
sudo mv /tmp/fishez /usr/local/bin/$BIN
5757
fi
5858

59-
# Install the fz() shell wrapper (cd to last viewed dir on exit)
60-
case "${SHELL:-}" in
61-
*/zsh) RC="$HOME/.zshrc" ;;
62-
*/bash) RC="$HOME/.bashrc" ;;
63-
*) RC="" ;;
64-
esac
65-
66-
FZ_LINE='eval "$(fishez --init)" # fz: fishez wrapper that cds to the last viewed dir'
67-
if [ -n "$RC" ]; then
68-
if ! grep -q "fishez --init" "$RC" 2>/dev/null; then
69-
printf '\n%s\n' "$FZ_LINE" >> "$RC"
70-
echo "✓ Added fz shell function to $RC (open a new shell to use it)."
71-
fi
72-
else
73-
echo "To get the fz function (cd on exit), add this to your shell rc:"
74-
echo " $FZ_LINE"
75-
fi
59+
/usr/local/bin/$BIN --install-shell || {
60+
echo "To enable fz later, run: fishez --install-shell"
61+
}
7662

7763
echo "✓ fishez installed. Run 'fishez' to start, or 'fz' to cd on exit."

0 commit comments

Comments
 (0)