-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash.sh
More file actions
34 lines (29 loc) · 1.04 KB
/
Copy pathbash.sh
File metadata and controls
34 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# proj shell integration for bash
# Source this file in your ~/.bashrc or ~/.bash_profile
# Function to integrate proj with bash
setup_proj_bash_integration() {
# Create proj function that handles directory changes
proj() {
# Store the original directory
local original_dir="$(pwd)"
# Run proj with all arguments
command proj "$@"
# Check if a .proj_last_dir file exists (created by proj on directory change)
local proj_dir_file="$HOME/.config/proj/.proj_last_dir"
if [ -f "$proj_dir_file" ]; then
local target_dir="$(cat "$proj_dir_file")"
if [ -d "$target_dir" ] && [ "$target_dir" != "$original_dir" ]; then
echo "Changing to: $target_dir"
cd "$target_dir"
fi
# Clean up the file
rm -f "$proj_dir_file"
fi
}
echo "proj bash integration enabled"
}
# Auto-setup if sourced
if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
setup_proj_bash_integration
fi