forked from driesvints/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodespaces-post-attach
More file actions
executable file
·45 lines (40 loc) · 1.85 KB
/
codespaces-post-attach
File metadata and controls
executable file
·45 lines (40 loc) · 1.85 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
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
cd "$(dirname "$0")"
source ./helpers/runtime.sh
source ../bin/helpers/trap_and_trace.sh
# This script should be codespace agnosic. It is intended to be run as part of a
# codespaces' `postAttachCommand` lifecycle event to perform additional setup
# steps specific to these dotfiles and my development preferences.
#
# NOTE: THIS IS NOT BASED ON ANY BUILT-IN MECHANISM of devcontainers or
# codespaces, it's something YOU MUST MANUALLY ENABLE via one of the lifecycle
# event hooks - the most obvious targets being `postCreateCommand` and
# `postAttachCommand` events - by adding something like the following to a
# script that's assigned to the event in your `.devcontainer.json` file:
#
# ```sh
# # Run any additional user-specific hooks. This runs every time the container is attached.
# if [[ -f /workspaces/.codespaces/.persistedshare/dotfiles/scripts/codespaces-post-attach ]]; then
# /workspaces/.codespaces/.persistedshare/dotfiles/codespaces-post-attach
# fi
# ```
#
# The file names `codespaces-post-attach` and `codespaces-post-create` are the
# convention used at GitHub, but you can use any name you like. The script will
# be executed in the context of whatever user account the devcontainer is
# configured to use, and remember to make sure the scripts are executable.
#
# Caveat lector: While codespaces are typically isolated environments, you
# should still take care to only enable this for devcontainers in repos that you
# trust and that have a reasonable level security and observability.
log_info "Running post attach script from dotfiles"
if [[ "$(is_codespace)" != "true" ]]; then
log_attention "Not a codespace; skipping $0"
exit 0
fi
log_debug "Checking if gh CLI is installed"
if [[ -n $(command -v gh 2>/dev/null) ]]; then
log_info "Checking gh auth status"
echo $(gh auth status)
fi
log_success "Done running post attach script!"