markdown · 1222 bytes Raw Blame History

Using FORTRESS with CD-on-Exit

Setup (One Time)

Add this line to your ~/.bashrc or ~/.zshrc:

source ~/Documents/GithubOrgs/FortranGoingOnForty/fortress/fortress.sh

Then reload your shell:

source ~/.bashrc  # or source ~/.zshrc

Usage

Instead of running fpm run, use the fortress command:

fortress

This runs the fortress file explorer. When you're browsing:

  1. Use ↑↓ to navigate files/directories
  2. Use to enter a directory
  3. Use to go back
  4. Press c on any directory to exit fortress and CD your shell to that directory
  5. Press q to quit without changing directory

How It Works

When you press c:

  1. FORTRESS writes the selected directory path to ~/.fortress_cd
  2. FORTRESS exits
  3. The shell function reads ~/.fortress_cd and runs cd to that directory
  4. The temp file is cleaned up

This is the same pattern used by tools like fzf.

Important Notes

  • fpm run does NOT enable cd-on-exit (it runs directly)
  • fortress command DOES enable cd-on-exit (uses the shell function)
  • You must source fortress.sh in your shell config for this to work
  • This only works in interactive shells, not in scripts
View source
1 # Using FORTRESS with CD-on-Exit
2
3 ## Setup (One Time)
4
5 Add this line to your `~/.bashrc` or `~/.zshrc`:
6
7 ```bash
8 source ~/Documents/GithubOrgs/FortranGoingOnForty/fortress/fortress.sh
9 ```
10
11 Then reload your shell:
12 ```bash
13 source ~/.bashrc # or source ~/.zshrc
14 ```
15
16 ## Usage
17
18 Instead of running `fpm run`, use the `fortress` command:
19
20 ```bash
21 fortress
22 ```
23
24 This runs the fortress file explorer. When you're browsing:
25
26 1. Use `↑↓` to navigate files/directories
27 2. Use `→` to enter a directory
28 3. Use `←` to go back
29 4. **Press `c` on any directory to exit fortress and CD your shell to that directory**
30 5. Press `q` to quit without changing directory
31
32 ## How It Works
33
34 When you press `c`:
35 1. FORTRESS writes the selected directory path to `~/.fortress_cd`
36 2. FORTRESS exits
37 3. The shell function reads `~/.fortress_cd` and runs `cd` to that directory
38 4. The temp file is cleaned up
39
40 This is the same pattern used by tools like `fzf`.
41
42 ## Important Notes
43
44 -`fpm run` does NOT enable cd-on-exit (it runs directly)
45 -`fortress` command DOES enable cd-on-exit (uses the shell function)
46 - You must source `fortress.sh` in your shell config for this to work
47 - This only works in interactive shells, not in scripts