-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzsh.sh
More file actions
34 lines (29 loc) · 1013 Bytes
/
Copy pathzsh.sh
File metadata and controls
34 lines (29 loc) · 1013 Bytes
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/zsh
# proj shell integration for zsh
# Source this file in your ~/.zshrc
# Function to integrate proj with zsh
setup_proj_zsh_integration() {
# Create proj function that handles directory changes
proj() {
# Store the original directory
local original_dir="$(pwd)"
# Run proj with all arguments
command proj "$@"
# Read .proj_last_dir (created by proj on directory change), if it exists
local proj_dir_file="$HOME/.config/proj/.proj_last_dir"
local target_dir
if target_dir=$(<"$proj_dir_file"); then
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 zsh integration enabled"
}
# Auto-setup if sourced
if [[ "${ZSH_EVAL_CONTEXT}" == *":file" ]]; then
setup_proj_zsh_integration
fi