forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit
More file actions
executable file
·39 lines (36 loc) · 1.46 KB
/
init
File metadata and controls
executable file
·39 lines (36 loc) · 1.46 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
#!/usr/bin/env bash
# Copyright (c) 2025 b-data GmbH
# Copyright (c) 2023 Microsoft Corporation
# Distributed under the terms of the MIT License.
#
# https://docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases?platform=windows
#
# Modified by b-data for seamless integration with development containers on Linux/macOS.
set -e
# Do not execute on GitHub Codespaces
if [ -z "$CODESPACES" ]; then
# Check the state of the currently running instance of the agent
# 0: running with key(s); 1: running w/o key(s); 2: not running
AGENT_RUN_STATE="$(ssh-add -l > /dev/null 2>&1; echo $?)"
# Only add key(s) if running w/o key(s)
if [ "$AGENT_RUN_STATE" = "1" ]; then
ssh-add 2> /dev/null || true
fi
# Means: Not adding key(s) to a forwarded agent with key(s)
fi
# https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials
#
# On Linux: For an X session, the agent is usually started automatically.
# For a login session, add the following to your `~/.bash_profile`
# or `~/.zprofile`:
#
# if [ -z "$SSH_AUTH_SOCK" ]; then
# # Check for a currently running instance of the agent
# RUNNING_AGENT="$(pgrep -f 'ssh-agent -s' -u "$USER" | wc -l | tr -d '[:space:]')"
# if [ "$RUNNING_AGENT" = "0" ]; then
# mkdir -p -m 0700 "$HOME/.ssh"
# # Launch a new instance of the agent
# ssh-agent -s &> "$HOME/.ssh/ssh-agent"
# fi
# eval "$(cat "$HOME/.ssh/ssh-agent")" > /dev/null
# fi