Compare commits
1 Commits
5fb50bb924
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f5c054f3e |
45
home/.config/fish/functions/pc.fish
Normal file
45
home/.config/fish/functions/pc.fish
Normal file
@@ -0,0 +1,45 @@
|
||||
function __create_session
|
||||
set session "process-compose"
|
||||
set dir "/home/tgrosinger/obsidian"
|
||||
|
||||
if not tmux has-session -t "$session" 2>/dev/null
|
||||
# Unset any devbox environment variables so they can be re-sourced
|
||||
# in the new directory.
|
||||
set -l shell env
|
||||
for var in (set --names --export | string match 'DEVBOX_*')
|
||||
set -a shell -u $var
|
||||
end
|
||||
|
||||
set -a shell (command -s fish) --login
|
||||
|
||||
tmux new-session -d -s "$session" -c "$dir" -n dev $shell
|
||||
|
||||
# Ensure that new panes in this session also start with the clean environment.
|
||||
tmux set-option -t "$session" default-command (string join ' ' -- $shell)
|
||||
|
||||
set -l left (tmux display-message -t "$session:dev" -p '#{pane_id}')
|
||||
tmux split-window -h -t "$left" -c "$dir" $shell
|
||||
set -l right (tmux display-message -t "$session:dev" -p '#{pane_id}')
|
||||
tmux send-keys -t "$left" 'devbox services attach' Enter
|
||||
|
||||
tmux select-pane -t "$right"
|
||||
end
|
||||
end
|
||||
|
||||
function __attach_session
|
||||
set session "process-compose"
|
||||
|
||||
if test -z "$TMUX"
|
||||
tmux attach-session -t "$session"
|
||||
else
|
||||
set -l current_session (tmux display-message -p '#S')
|
||||
if test "$current_session" != "$session"
|
||||
tmux switch-client -t "$session"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pc -d "Create and attach to a tmux session for process compose in Obsidian"
|
||||
__create_session
|
||||
__attach_session
|
||||
end
|
||||
Reference in New Issue
Block a user