Git with Oh My Zsh Aliases: Boost Your Productivity

If you’re using Oh My Zsh, you have access to a powerful set of git aliases that can significantly speed up your development workflow. The git plugin comes pre-installed and provides dozens of shortcuts for common git operations. Essential Git Aliases Here are the most useful git aliases that will transform your daily workflow: Basic Operations 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # Status and information gst # git status gss # git status --short gsb # git status --short --branch gl # git pull gp # git push ga # git add gaa # git add --all gc # git commit --verbose gcmsg # git commit --message gca # git commit --verbose --all gcam # git commit --all --message # Branch operations gb # git branch gba # git branch --all gbd # git branch --delete gcb # git checkout -b gco # git checkout gcm # git checkout $(git_main_branch) gcd # git checkout $(git_develop_branch) Advanced Workflow 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 # Logging and history glog # git log --oneline --decorate --graph gloga # git log --oneline --decorate --graph --all glol # git log --graph --pretty=format with colors glola # git log --graph --pretty=format with colors --all glo # git log --oneline --decorate glg # git log --stat glgp # git log --stat --patch # Stashing gsta # git stash push (or save on older git) gstp # git stash pop gsts # git stash show --patch gstd # git stash drop gstl # git stash list gstaa # git stash apply gstc # git stash clear # Merging and rebasing gm # git merge gma # git merge --abort gmc # git merge --continue grb # git rebase grba # git rebase --abort grbc # git rebase --continue grbi # git rebase --interactive Remote Operations 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # Remote management gr # git remote grv # git remote --verbose gra # git remote add grrm # git remote remove grmv # git remote rename grset # git remote set-url # Fetching and pulling gf # git fetch gfa # git fetch --all --tags --prune gfo # git fetch origin gpr # git pull --rebase gpra # git pull --rebase --autostash gpu # git push upstream gpv # git push --verbose Diff and Show 1 2 3 4 5 6 7 # Diff operations gd # git diff gdca # git diff --cached gds # git diff --staged gdw # git diff --word-diff gdt # git diff-tree --no-commit-id --name-only -r gsh # git show My Most Used Aliases Based on daily development work, here are the aliases I use most frequently: ...

July 14, 2025 · 5 min · Elvin Guti

Script to run tests in Jest and get the coverage for a specific file

I needed to automate the process of running tests in Jest and getting the coverage for a specific file. I created this script to help me with that. 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 #!/bin/bash # Color definitions BLUE='\033[0;34m' GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' CYAN='\033[0;36m' NC='\033[0m' # No Color BOLD='\033[1m' # Function to display usage show_usage() { echo -e "${YELLOW}Usage:${NC} $0 [--find-by-name] <relative-file-path> [additional test options]" echo -e "${YELLOW}Examples:${NC}" echo -e " $0 src/components/Button.tsx --watch" echo -e " $0 src/components/Button.tsx --find-by-name --watch" exit 1 } # Initialize variables FIND_BY_NAME=false RELATIVE_FILE_PATH="" # Parse arguments while [[ $# -gt 0 ]]; do case $1 in --find-by-name) FIND_BY_NAME=true shift ;; *) if [ -z "$RELATIVE_FILE_PATH" ]; then RELATIVE_FILE_PATH="$1" else break # Stop parsing and keep remaining args for test options fi shift ;; esac done # Check if a file name is provided if [ -z "$RELATIVE_FILE_PATH" ]; then show_usage fi # Check if the file exists if [ ! -f "$RELATIVE_FILE_PATH" ]; then echo -e "${RED}Error: ${NC}File '${YELLOW}${RELATIVE_FILE_PATH}${NC}' not found. 😕" exit 1 fi FILE_PATH=$(echo "$RELATIVE_FILE_PATH" | cut -d'/' -f3-) # Get just the file name without extension for --find-by-name mode FILE_NAME=$(basename "$RELATIVE_FILE_PATH") FILE_NAME_NO_EXT="${FILE_NAME%.*}" # Construct the corresponding test file path TEST_FILE_NAME="${FILE_PATH%.*}.test" if [ "$FIND_BY_NAME" = true ]; then # Search by file name TEST_PATH=$(find "tests" -type f \( -name "${FILE_NAME_NO_EXT}.test.tsx" -o -name "${FILE_NAME_NO_EXT}.test.ts" \)) else # Original search by path TEST_PATH=$(find "tests" -type f \( -path "*/${TEST_FILE_NAME}.tsx" -o -path "*/${TEST_FILE_NAME}.ts" \)) fi # Check if the test file exists if [ -z "$TEST_PATH" ]; then echo -e "${RED}Error: ${NC}Test file for '${YELLOW}${RELATIVE_FILE_PATH}${NC}' not found in 'tests' directory. 😕" echo -e "Test file name: ${YELLOW}${FILE_NAME_NO_EXT}.test.tsx${NC}" echo -e "${YELLOW}Hint:${NC} If you're looking for a file by name, try using the --find-by-name flag." exit 1 fi # Print test information with styling echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "${GREEN}▶ Running Coverage Test${NC}" echo -e "${CYAN}📁 Source file:${NC} ${RELATIVE_FILE_PATH}" echo -e "${CYAN}🧪 Test file:${NC} ${TEST_PATH}" echo -e "${CYAN}⚙️ Options:${NC} $@" echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n" yarn test "$TEST_PATH" --coverage --collectCoverageFrom="$RELATIVE_FILE_PATH" "$@" Usage Test cases are in the tests folder. The script will search for the test file by path by default, if you want to search by name, you can use the --find-by-name flag. ...

March 3, 2025 · 3 min · Elvin Guti

Create pull requests descriptions using Aider and OpenRouter

In order to reduce the amount of time I spend on writing pull request instructions, I’ve been using Aider with OpenRouter to generate them. Requirements OpenRouter key Aider .env file with OPENROUTER_API_KEY variable How does it work? Aider is a tool that uses AI to help you write code. It’s a chatbot that can help you write code, fix bugs, and even write tests. OpenRouter is a tool that allows you to route requests to different APIs. In this case, we’ll use it to route the request to Aider. ...

March 3, 2025 · 4 min · Elvin Guti

Map array in server side Google tag manager

Sometimes you need to send to a third party service a different array structure than the one specified on Google Analytics 4 (GA4). So, in case you don’t want to create a new event only for this service and you want to reuse as much as posible a GA4 event like add_to_cart, then you need to map the GA4 built in array on GTM. This sounds pretty easy if you have used GTM (no server side) before, basically you create a new custom javascript variable and return the mapped array. However, on GTM using a server side container, the custom javascript variable is no longer available. ...

May 8, 2024 · 2 min · Elvin Guti

Show full branch name on powerlevel10k theme

powerlevel10k is a popular zsh theme and my favorite one. However, branch names are truncated if these are pretty long. Although, you can remove this limitation by updating its config file: 1 vim ~/.p10k.zsh Search for the branch name and comment the line that’s doing the truncation: 1 2 # Tip: To always show local branch name in full without truncation, delete the next line. # (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line You might need to restart zsh ...

April 16, 2024 · 1 min · Elvin Guti