Skip to content

Instantly share code, notes, and snippets.

@y16ra
y16ra / git_config_default_branch.sh
Created March 28, 2022 01:20
Configure default git branch name
git config --global init.defaultBranch main
@y16ra
y16ra / .gitconfig
Created April 5, 2023 02:30
Delete all branches that do not exist in the remote branch
[alias]
clean-branch = !git fetch -p | git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D
@y16ra
y16ra / run-ecs-task.sh
Created July 30, 2024 00:35
This script provides to run a new task using the configuration of an existing ECS service and wait for its completion.
CLUSTER_NAME=$YOUR_CLUSTER_NAME
TASK_DEF_NAME=$YOUR_TASK_NAME
SERVICE_NAME=$YOUR_SERVICE_NAME
task_arn=$(aws ecs list-task-definitions --family-prefix "$TASK_DEF_NAME" --query "reverse(taskDefinitionArns)[0]" --output text)
# Describe the ECS service to get network configuration details
network_config=$(aws ecs describe-services --cluster $CLUSTER_NAME --services $SERVICE_NAME --query 'services[0].networkConfiguration.awsvpcConfiguration' --output json)
# Extract subnets and security groups
@y16ra
y16ra / .zshrc
Last active July 31, 2024 00:31
Interactive History Search
HIST_STAMPS="yyyy-mm-dd"
# fzf history
function fzf-select-history() {
local selected=$(history -n -r 1 | fzf --query "$LBUFFER" --reverse)
if [ -n "$selected" ]; then
BUFFER=$(echo "$selected" | awk '{$1=""; $2=""; print $0}' | sed 's/^[ \t]*//')
CURSOR=$#BUFFER
zle reset-prompt
fi
@y16ra
y16ra / .zshrc
Created July 31, 2024 01:08
navigates to the directory of a repository listed by the `ghq` command using `fzf`.
function fzf-src(){
local src=$(ghq list --full-path | fzf --query "$LBUFFER" --layout=reverse)
if [ -n "$src" ]; then
BUFFER="cd $src"
zle accept-line
fi
zle -R -c
}
zle -N fzf-src
bindkey '^]' fzf-src
@y16ra
y16ra / .zshrc
Created July 31, 2024 01:32
enable cdr command
if [[ -n $(echo ${^fpath}/chpwd_recent_dirs(N)) && -n $(echo ${^fpath}/cdr(N)) ]]; then
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
zstyle ':completion:*' recent-dirs-insert both
zstyle ':chpwd:*' recent-dirs-default true
zstyle ':chpwd:*' recent-dirs-max 1000
zstyle ':chpwd:*' recent-dirs-file "$HOME/.cache/chpwd-recent-dirs"
fi
@y16ra
y16ra / get_merged_pr_numbers.sh
Last active May 8, 2025 01:54
This one-liner fetches the commit headlines for a pull request, filters lines that contain "Merge pull request", and then extracts only the PR numbers (e.g., #10) from those lines.
gh pr view 1 --json commits --jq '.commits[].messageHeadline' | grep "Merge pull request" | grep -o '#[0-9]\+'