Compare commits
3 Commits
00ca94a9f3
...
3e41fff831
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e41fff831 | |||
| cd356cabd3 | |||
| 39075d2dd3 |
@@ -7,6 +7,7 @@
|
||||
#
|
||||
|
||||
set AUTOENV_AUTH_FILE ~/.autoenv_authorized
|
||||
set AUTOENV_TRUSTED_FILE ~/.autoenv_trusted
|
||||
if [ -z "$AUTOENV_ENV_FILENAME" ]
|
||||
set AUTOENV_ENV_FILENAME ".env"
|
||||
end
|
||||
@@ -77,6 +78,27 @@ function autoenv_hashline
|
||||
echo "$envfile:$hash"
|
||||
end
|
||||
|
||||
function autoenv_content_hash
|
||||
set envfile $argv[1]
|
||||
shasum "$envfile" | cut -d' ' -f 1
|
||||
end
|
||||
|
||||
function autoenv_check_trusted
|
||||
set envfile $argv[1]
|
||||
set hash (autoenv_content_hash "$envfile")
|
||||
touch $AUTOENV_TRUSTED_FILE
|
||||
grep -Fxq "$hash" $AUTOENV_TRUSTED_FILE
|
||||
end
|
||||
|
||||
function autoenv_trust_env
|
||||
set envfile $argv[1]
|
||||
set hash (autoenv_content_hash "$envfile")
|
||||
touch $AUTOENV_TRUSTED_FILE
|
||||
if not grep -Fxq "$hash" $AUTOENV_TRUSTED_FILE
|
||||
echo "$hash" >>$AUTOENV_TRUSTED_FILE
|
||||
end
|
||||
end
|
||||
|
||||
function autoenv_check_authz
|
||||
# typeset envfile hash
|
||||
set envfile $argv[1]
|
||||
@@ -87,7 +109,7 @@ end
|
||||
|
||||
function autoenv_check_authz_and_run
|
||||
set envfile $argv[1]
|
||||
if autoenv_check_authz "$envfile"
|
||||
if autoenv_check_authz "$envfile"; or autoenv_check_trusted "$envfile"
|
||||
autoenv_source "$envfile"
|
||||
return 0
|
||||
end
|
||||
@@ -100,11 +122,16 @@ function autoenv_check_authz_and_run
|
||||
autoenv_indent "$envfile"
|
||||
autoenv_env " --- (end contents) -----------------------------------------"
|
||||
autoenv_env
|
||||
autoenv_printf "Are you sure you want to allow this? (y/N) \n"
|
||||
autoenv_printf "Are you sure you want to allow this? (y/t/N) \n"
|
||||
autoenv_env " y - approve for this path only"
|
||||
autoenv_env " t - trust these contents everywhere"
|
||||
read answer
|
||||
if [ $answer = y -o $answer = Y ]
|
||||
if [ "$answer" = y -o "$answer" = Y ]
|
||||
autoenv_authorize_env "$envfile"
|
||||
autoenv_source "$envfile"
|
||||
else if [ "$answer" = t -o "$answer" = T ]
|
||||
autoenv_trust_env "$envfile"
|
||||
autoenv_source "$envfile"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -131,3 +158,7 @@ function autoenv_source
|
||||
#set -e AUTOENV_CUR_FILE
|
||||
#set -e AUTOENV_CUR_DIR
|
||||
end
|
||||
|
||||
# Run once on shell startup so .env files are sourced in the initial
|
||||
# working directory (PWD is already set, so --on-variable PWD won't fire).
|
||||
autoenv_init
|
||||
|
||||
29
home/.config/fish/functions/dev.fish
Normal file
29
home/.config/fish/functions/dev.fish
Normal file
@@ -0,0 +1,29 @@
|
||||
function dev -d "Create and attach to a tmux dev session for the current git branch"
|
||||
set -l branch (git branch --show-current 2>/dev/null)
|
||||
if test -z "$branch"
|
||||
echo "Not in a git repository"
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l session (string replace -a '/' '-' -- $branch | string replace -a '\\' '-')
|
||||
|
||||
if not tmux has-session -t "$session" 2>/dev/null
|
||||
tmux new-session -d -s "$session" -c (pwd) -n dev
|
||||
tmux split-window -h -t "$session:dev" -c (pwd)
|
||||
tmux split-window -v -t "$session:dev.0" -c (pwd)
|
||||
tmux split-window -v -t "$session:dev.2" -c (pwd)
|
||||
tmux send-keys -t "$session:dev.1" 'vim' Enter
|
||||
tmux send-keys -t "$session:dev.2" 'claude' Enter
|
||||
tmux send-keys -t "$session:dev.3" 'pnpm i && pnpm dev' Enter
|
||||
tmux select-pane -t "$session:dev.0"
|
||||
end
|
||||
|
||||
if test -z "$TMUX"
|
||||
exec tmux attach-session -t "$session"
|
||||
else
|
||||
set -l current_session (tmux display-message -p '#S')
|
||||
if test "$current_session" != "$session"
|
||||
exec tmux switch-client -t "$session"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user