function og() { open $(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g') }
#!/bin/bash
# Open the repo in the browser
function og() {
open "$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')"
}
# Open the repo at the current branch
function ogb() {
open "$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')/tree/$(git rev-parse --abbrev-ref HEAD)"
}
# Open the PR for the current branch (if exists)
function ogpr() {
branch=$(git rev-parse --abbrev-ref HEAD)
repo_url=$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')
open "$repo_url/pull/$(
gh pr list --head "$branch" --json number --jq '.[0].number' 2>/dev/null || echo 'new'
)"
}
# Open the list of pull requests
function ogprs() {
open "$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')/pulls"
}
# Open the list of issues
function ogis() {
open "$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')/issues"
}
# Open GitHub Actions (CI/CD) page
function ogci() {
open "$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')/actions"
}
# Open the latest commit in the current branch
function ogl() {
open "$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')/commit/$(git rev-parse HEAD)"
}
# Open a specific file in the remote repo (GitHub, GitLab, etc.)
function ogf() {
file_path=$1
[[ -z "$file_path" ]] && echo "Usage: ogf <file-path>" && return 1
open "$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')/blob/$(git rev-parse --abbrev-ref HEAD)/$file_path"
}
# Open the repo settings page
function ogsettings() {
open "$(git config --get remote.origin.url | sed 's/git@\(.*\):\(.*\)\.git/https:\/\/\1\/\2/g')/settings"
}
# Jump to the first matching subdirectory within the current path
cdf() {
if [ -z "$1" ]; then
echo "Usage: cdf <directory>"
return 1
fi
local dir
dir=$(fd -t d -d 3 "$1" | head -n 1)
[ -n "$dir" ] && cd "$dir" || echo "Directory '$1' not found."
}
# Fuzzy search for a subdirectory and jump
cdff() {
if [ -z "$1" ]; then
echo "Usage: cdff <directory>"
return 1
fi
local dir
dir=$(fd -t d -d 3 "$1" | fzf)
[ -n "$dir" ] && cd "$dir" || echo "No directory selected."
}
# List matching directories and select one to jump into
cdl() {
if [ -z "$1" ]; then
echo "Usage: cdl <directory>"
return 1
fi
local dirs
mapfile -t dirs < <(fd -t d -d 3 "$1")
[ ${#dirs[@]} -eq 0 ] && echo "No directories found." && return
select dir in "${dirs[@]}"; do
[ -n "$dir" ] && cd "$dir" && break
done
}