-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnvim_wrapper.sh
executable file
·47 lines (38 loc) · 1.32 KB
/
nvim_wrapper.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Define the virtual environment path
VENV_PATH=~/dotfiles/iterm2_venv
# Check if the virtual environment exists, create it if it does not
if [ ! -d "$VENV_PATH" ]; then
python3 -m venv "$VENV_PATH"
source "$VENV_PATH/bin/activate"
pip install iterm2
else
source "$VENV_PATH/bin/activate"
fi
# Function to get the current window bounds
get_window_bounds() {
osascript -e 'tell application "iTerm2" to get bounds of current window'
}
# Function to set the window bounds
set_window_bounds() {
local bounds=$1
osascript -e "tell application \"iTerm2\" to set bounds of current window to {$bounds}"
}
# Get the current window bounds
initial_bounds=$(get_window_bounds | awk -F", " '{print $1","$2","$3","$4}')
# Switch to the nvim profile
python3 ~/dotfiles/switch_profile.py "nvim" "start" &
wait %1
# Set the window bounds to the initial bounds after switching to nvim profile
set_window_bounds "$initial_bounds"
# Execute nvim
nvim "$@"
# Get the current window bounds
initial_bounds=$(get_window_bounds | awk -F", " '{print $1","$2","$3","$4}')
# Switch back to the default profile
python3 ~/dotfiles/switch_profile.py "Default" "end" &
wait %1
# Restore the initial window bounds after switching back to default profile
set_window_bounds "$initial_bounds"
# Deactivate the virtual environment
deactivate