fortrangoingonforty/fortress / 83f67c6

Browse files

fixes, readme

Authored by espadonne
SHA
83f67c6c0d68902659d98e51514b32a078c428ac
Parents
8c561b1
Tree
4b775d4

2 changed files

StatusFile+-
M README.md 53 15
M app/main.f90 38 2
README.mdmodified
@@ -2,13 +2,27 @@
22
 
33
 A command-line file explorer written in modern Fortran with fzf integration.
44
 
5
-## Quick Start
5
+## Installation
66
 
7
-### Prerequisites
7
+### From AUR (Arch Linux)
8
+
9
+```bash
10
+yay -S fortress
11
+# or
12
+paru -S fortress
13
+```
14
+
15
+Shell integration is automatically set up for bash and fish. Zsh users need to add to `~/.zshrc`:
16
+```bash
17
+source /usr/share/fortress/fortress.sh
18
+```
19
+
20
+### From Source
21
+
22
+#### Prerequisites
823
 
924
 - gfortran 10+ or ifort
1025
 - fpm (Fortran Package Manager)
11
-- fzf (for fuzzy finding features)
1226
 
1327
 ### Install fpm
1428
 
@@ -33,6 +47,20 @@ fpm run
3347
 fpm run --flag "-O2"
3448
 ```
3549
 
50
+### Shell Integration (Optional)
51
+
52
+To enable the "cd on exit" feature (press 'c' to navigate your shell to a directory):
53
+
54
+```bash
55
+# Add to your .bashrc or .zshrc:
56
+source /path/to/fortress/fortress.sh
57
+
58
+# Then use:
59
+fortress  # instead of 'fpm run'
60
+```
61
+
62
+This allows you to navigate to directories and have your shell follow when you press 'c'.
63
+
3664
 ### Development
3765
 
3866
 ```bash
@@ -49,11 +77,15 @@ fpm build --flag "-g -Wall -Wextra"
4977
 - ✅ **Real filesystem navigation** with directory reading
5078
 - ✅ **Smart selection memory** - remembers position when navigating
5179
 - ✅ **Visual hierarchy** - dimmed parent pane, active current pane
80
+- ✅ **Color-coded files**:
81
+  - Directories: Blue + bold
82
+  - Executable files: Green
83
+  - Dotfiles: Grey
84
+  - Regular files: White
5285
 - ✅ **Smooth updates** - no flashing, selective redraws
53
-- ✅ **Arrow key and vim-style navigation** (h,j,k,l)
54
-- ✅ **Directory visualization** with color coding (blue with `/` suffix)
86
+- ✅ **Arrow key navigation** for intuitive movement
5587
 - ✅ **Full-width selection bar** - clean highlighting
56
-- ✅ **Navigate directories** - enter/exit with arrow keys
88
+- ✅ **CD on exit** - press 'c' to navigate your shell to selected directory
5789
 
5890
 ## Next Steps
5991
 
@@ -68,19 +100,25 @@ See [ROADMAP.md](ROADMAP.md) for detailed development plans.
68100
 
69101
 ## Controls
70102
 
71
-- `↑/↓` or `j/k`: Navigate files
72
-- `←/→` or `h/l`: Navigate directories
73
-- `Enter`: Open file/enter directory
74
-- `q` or `Ctrl-Q`: Quit
103
+- `↑/↓`: Navigate up/down
104
+- `→`: Enter directory
105
+- `←`: Go back to parent directory
106
+- `c`: CD to selected directory and exit (requires shell integration)
107
+- `q`: Quit
75108
 
76109
 ## Architecture
77110
 
78
-FORTRESS is built with modular design:
111
+FORTRESS is built as a self-contained file explorer:
79112
 
80
-- `terminal/`: Terminal I/O and screen management
113
+- `app/main.f90`: Main application with integrated UI and file operations
114
+- `lib_modules/`: Modular components (available for future expansion)
81115
   - `filesystem/`: File operations and directory walking
116
+  - `terminal/`: Terminal I/O and screen management
82117
   - `ui/`: User interface components (panes, rendering)
83
-- `integration/`: External tool integration (fzf)
118
+
119
+## Packaging
120
+
121
+For AUR maintainers, see [AUR_PACKAGING.md](AUR_PACKAGING.md) for complete packaging instructions.
84122
 
85123
 ## License
86124
 
app/main.f90modified
@@ -26,6 +26,8 @@ program fortress_clean
2626
     integer :: parent_selected = -1
2727
     character(len=1) :: key
2828
     logical :: running = .true.
29
+    logical :: cd_on_exit = .false.
30
+    character(len=MAX_PATH) :: exit_dir
2931
     integer :: i, rows, cols
3032
 
3133
     ! Initialize
@@ -86,13 +88,31 @@ program fortress_clean
8688
             end select
8789
         case(113, 81)  ! 'q' or 'Q'
8890
             running = .false.
91
+        case(99, 67)  ! 'c' or 'C' - cd to directory on exit
92
+            if (current_is_dir(selected)) then
93
+                if (trim(current_files(selected)) == "..") then
94
+                    exit_dir = parent_dir
95
+                else if (trim(current_files(selected)) == ".") then
96
+                    exit_dir = current_dir
97
+                else
98
+                    exit_dir = join_path(current_dir, current_files(selected))
99
+                end if
100
+                cd_on_exit = .true.
101
+                running = .false.
102
+            end if
89103
         end select
90104
     end do
91105
 
92106
     ! Cleanup
93107
     call execute_command_line("stty icanon echo 2>/dev/null")
94108
     write(output_unit, '(a)', advance='no') CLEAR
109
+
110
+    ! If cd_on_exit is set, write the directory to a temp file
111
+    if (cd_on_exit) then
112
+        call write_exit_dir(exit_dir)
113
+    else
95114
         write(output_unit, '(a)') "Thanks for using FORTRESS!"
115
+    end if
96116
 
97117
 contains
98118
 
@@ -284,7 +304,7 @@ contains
284304
         end do
285305
 
286306
         ! Footer
287
-        write(output_unit, '(a)') DIM // "↑↓:nav →:enter ←:back q:quit" // RESET
307
+        write(output_unit, '(a)') DIM // "↑↓:nav →:enter ←:back c:cd q:quit" // RESET
288308
     end subroutine draw_interface
289309
 
290310
     subroutine read_arrow_key(k)
@@ -319,4 +339,20 @@ contains
319339
         end if
320340
     end function get_file_color
321341
 
342
+    subroutine write_exit_dir(dir)
343
+        character(len=*), intent(in) :: dir
344
+        character(len=MAX_PATH) :: temp_file
345
+        integer :: unit, ios
346
+
347
+        ! Create temp file in HOME directory
348
+        call get_environment_variable("HOME", temp_file)
349
+        temp_file = trim(temp_file) // "/.fortress_cd"
350
+
351
+        open(newunit=unit, file=temp_file, status='replace', action='write', iostat=ios)
352
+        if (ios == 0) then
353
+            write(unit, '(a)') trim(dir)
354
+            close(unit)
355
+        end if
356
+    end subroutine write_exit_dir
357
+
322358
 end program fortress_clean