Bash · 1271 bytes Raw Blame History
1 # FORTRESS shell integration
2 # Add this to your .bashrc or .zshrc:
3 # source ~/Documents/GithubOrgs/FortranGoingOnForty/fortress/fortress.sh
4 #
5 # Then use: fortress
6
7 fortress() {
8 # Determine which fortress binary to use
9 local fortress_exe
10
11 if [ -x "/usr/bin/fortress-bin" ]; then
12 # Use system-installed binary (via package manager)
13 fortress_exe="/usr/bin/fortress-bin"
14 elif [ -n "$FORTRESS_DIR" ]; then
15 # Use FORTRESS_DIR if set
16 fortress_exe="$FORTRESS_DIR/build/gfortran_"*"/app/fortress"
17 else
18 # Fallback to local development path
19 fortress_exe="$HOME/Documents/GithubOrgs/FortranGoingOnForty/fortress/build/gfortran_"*"/app/fortress"
20 fi
21
22 # Run fortress
23 $fortress_exe
24
25 # Check if fortress wants us to cd somewhere
26 if [ -f "$HOME/.fortress_cd" ]; then
27 local target_dir
28 target_dir=$(cat "$HOME/.fortress_cd")
29 rm -f "$HOME/.fortress_cd"
30 cd "$target_dir" || return 1
31 echo "fortress: changed directory to $(pwd)"
32 fi
33 }
34
35 # For zsh compatibility
36 if [ -n "$ZSH_VERSION" ]; then
37 # Nothing special needed for zsh
38 :
39 fi
40
41 # Export for subshells if needed (bash only)
42 if [ -n "$BASH_VERSION" ]; then
43 export -f fortress 2>/dev/null || true
44 fi