Skip to content

Instantly share code, notes, and snippets.

@ytnobody
Last active January 10, 2026 15:50
Show Gist options
  • Select an option

  • Save ytnobody/5d0b553de30852eb05aa4da10633bfb4 to your computer and use it in GitHub Desktop.

Select an option

Save ytnobody/5d0b553de30852eb05aa4da10633bfb4 to your computer and use it in GitHub Desktop.

Revisions

  1. ytnobody revised this gist Jan 10, 2026. 1 changed file with 1 addition and 28 deletions.
    29 changes: 1 addition & 28 deletions belike-ytnobody.sh
    Original file line number Diff line number Diff line change
    @@ -13,37 +13,10 @@ if ! command -v gh &> /dev/null; then
    sudo apt-get install gh -y
    fi

    # Helper function to copy to clipboard using OSC 52 (works in VS Code/Coder terminal)
    osc52_copy() {
    local text="$1"
    local encoded=$(echo -n "$text" | base64 | tr -d '\n')
    printf "\033]52;c;%s\007" "$encoded"
    }

    # 2. Login to GitHub with GitHub CLI
    if ! gh auth status &> /dev/null; then
    echo "Please login to GitHub:"
    # Use script command to capture output while keeping TTY
    SCRIPT_OUTPUT=$(mktemp)
    script -q -c "gh auth login --web --git-protocol https" "$SCRIPT_OUTPUT" &
    SCRIPT_PID=$!

    # Wait for the code to appear and copy it
    while kill -0 $SCRIPT_PID 2>/dev/null; do
    if [[ -f "$SCRIPT_OUTPUT" ]]; then
    CODE=$(grep -oE '[A-Z0-9]{4}-[A-Z0-9]{4}' "$SCRIPT_OUTPUT" 2>/dev/null | head -1)
    if [[ -n "$CODE" ]]; then
    osc52_copy "$CODE"
    echo "✓ Code '$CODE' copied to clipboard!"
    break
    fi
    fi
    sleep 0.5
    done

    # Wait for gh auth to complete
    wait $SCRIPT_PID 2>/dev/null || true
    rm -f "$SCRIPT_OUTPUT"
    gh auth login --web --git-protocol https
    fi

    # Add settings GitHub CLI Credential helper to git
  2. ytnobody revised this gist Jan 10, 2026. 1 changed file with 19 additions and 7 deletions.
    26 changes: 19 additions & 7 deletions belike-ytnobody.sh
    Original file line number Diff line number Diff line change
    @@ -23,15 +23,27 @@ osc52_copy() {
    # 2. Login to GitHub with GitHub CLI
    if ! gh auth status &> /dev/null; then
    echo "Please login to GitHub:"
    # Get device code first, then copy and open browser
    gh auth login --web --git-protocol https 2>&1 | while IFS= read -r line; do
    echo "$line"
    # Extract and copy the one-time code
    if [[ "$line" =~ ([A-Z0-9]{4}-[A-Z0-9]{4}) ]]; then
    osc52_copy "${BASH_REMATCH[1]}"
    echo "✓ Code copied to clipboard!"
    # Use script command to capture output while keeping TTY
    SCRIPT_OUTPUT=$(mktemp)
    script -q -c "gh auth login --web --git-protocol https" "$SCRIPT_OUTPUT" &
    SCRIPT_PID=$!

    # Wait for the code to appear and copy it
    while kill -0 $SCRIPT_PID 2>/dev/null; do
    if [[ -f "$SCRIPT_OUTPUT" ]]; then
    CODE=$(grep -oE '[A-Z0-9]{4}-[A-Z0-9]{4}' "$SCRIPT_OUTPUT" 2>/dev/null | head -1)
    if [[ -n "$CODE" ]]; then
    osc52_copy "$CODE"
    echo "✓ Code '$CODE' copied to clipboard!"
    break
    fi
    fi
    sleep 0.5
    done

    # Wait for gh auth to complete
    wait $SCRIPT_PID 2>/dev/null || true
    rm -f "$SCRIPT_OUTPUT"
    fi

    # Add settings GitHub CLI Credential helper to git
  3. ytnobody revised this gist Jan 10, 2026. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion belike-ytnobody.sh
    Original file line number Diff line number Diff line change
    @@ -13,10 +13,25 @@ if ! command -v gh &> /dev/null; then
    sudo apt-get install gh -y
    fi

    # Helper function to copy to clipboard using OSC 52 (works in VS Code/Coder terminal)
    osc52_copy() {
    local text="$1"
    local encoded=$(echo -n "$text" | base64 | tr -d '\n')
    printf "\033]52;c;%s\007" "$encoded"
    }

    # 2. Login to GitHub with GitHub CLI
    if ! gh auth status &> /dev/null; then
    echo "Please login to GitHub:"
    gh auth login
    # Get device code first, then copy and open browser
    gh auth login --web --git-protocol https 2>&1 | while IFS= read -r line; do
    echo "$line"
    # Extract and copy the one-time code
    if [[ "$line" =~ ([A-Z0-9]{4}-[A-Z0-9]{4}) ]]; then
    osc52_copy "${BASH_REMATCH[1]}"
    echo "✓ Code copied to clipboard!"
    fi
    done
    fi

    # Add settings GitHub CLI Credential helper to git
  4. ytnobody revised this gist Jan 10, 2026. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion belike-ytnobody.sh
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ sudo apt-get install -y ansible git

    # 4. Execute ansible-pull
    echo "Running Ansible-pull..."
    sudo -E ansible-pull -U "https://x-access-token:${GIT_TOKEN}@github.com/ytnobody/ansible-belike-ytnobody.git" local.yml
    ansible-pull -U "https://x-access-token:${GIT_TOKEN}@github.com/ytnobody/ansible-belike-ytnobody.git" local.yml

    echo "--------------------------------------------------"
    echo "All set! Please run 'claude auth login' to finish."
  5. ytnobody revised this gist Jan 10, 2026. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion belike-ytnobody.sh
    Original file line number Diff line number Diff line change
    @@ -21,14 +21,15 @@ fi

    # Add settings GitHub CLI Credential helper to git
    gh auth setup-git
    GIT_TOKEN=$(gh auth token)

    # 3. Install Ansible
    echo "Installing Ansible..."
    sudo apt-get install -y ansible git

    # 4. Execute ansible-pull
    echo "Running Ansible-pull..."
    sudo ansible-pull -U https://github.com/ytnobody/ansible-belike-ytnobody.git local.yml
    sudo -E ansible-pull -U "https://x-access-token:${GIT_TOKEN}@github.com/ytnobody/ansible-belike-ytnobody.git" local.yml

    echo "--------------------------------------------------"
    echo "All set! Please run 'claude auth login' to finish."
  6. ytnobody revised this gist Jan 10, 2026. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions belike-ytnobody.sh
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,9 @@ if ! gh auth status &> /dev/null; then
    gh auth login
    fi

    # Add settings GitHub CLI Credential helper to git
    gh auth setup-git

    # 3. Install Ansible
    echo "Installing Ansible..."
    sudo apt-get install -y ansible git
  7. ytnobody created this gist Jan 10, 2026.
    32 changes: 32 additions & 0 deletions belike-ytnobody.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/bin/bash
    set -e

    echo "Starting bootstrap process..."

    # 1. Install GitHub CLI
    if ! command -v gh &> /dev/null; then
    echo "Installing GitHub CLI..."
    curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
    sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
    sudo apt-get update
    sudo apt-get install gh -y
    fi

    # 2. Login to GitHub with GitHub CLI
    if ! gh auth status &> /dev/null; then
    echo "Please login to GitHub:"
    gh auth login
    fi

    # 3. Install Ansible
    echo "Installing Ansible..."
    sudo apt-get install -y ansible git

    # 4. Execute ansible-pull
    echo "Running Ansible-pull..."
    sudo ansible-pull -U https://github.com/ytnobody/ansible-belike-ytnobody.git local.yml

    echo "--------------------------------------------------"
    echo "All set! Please run 'claude auth login' to finish."
    echo "--------------------------------------------------"