Skip to content

Instantly share code, notes, and snippets.

@bingzhangdai
bingzhangdai / git_branch.md
Last active May 23, 2025 03:42
Fastest way to get git branch

Sometimes, we want to show current git branch in Bash prompt. git symbolic-ref --short -q HEAD is too slow, especially in WSL. Here is a pure Bash version to print git branch.

function _get_git_branch() {
    local _head_file _head
    local _dir="$PWD"

    while [[ -n "$_dir" ]]; do
        _head_file="$_dir/.git/HEAD"
        if [[ -f "$_dir/.git" ]]; then
@sshimko
sshimko / otp.txt
Last active January 9, 2024 23:25
Yubikey + FreeIPA Manual Setup
In Yubikey tool:
1. Click OATH+HOTP tab
2. Click Advanced
3. Deselect token identifier.
4. Press Generate to create a new random seed.