From 3bb428e060e87f271c79dbea939e0012a1c5684a Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sun, 8 Feb 2026 03:40:44 +0100 Subject: [PATCH] Simple git commands --- README.md | 11 +++++++++++ rc.zsh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 rc.zsh diff --git a/README.md b/README.md index 7159b52..2b1e5fa 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,27 @@ # shell-productivity + My zsh/bash productivity aliases / tools / scripts ## Installation ### Step 1 + ```bash cd ~ git clone https://github.com/selimaj-dev/shell-productivity.git ``` ### Step 2 (zsh) + Add this into your `.zshrc` + ```bash source ~/shell-productivity/rc.zsh ``` + +## Usage + +`ga` - **git add -A** +`gp` - **git pull** +`gc ` - **git commit -am ** +`postpr` - **Done after a pull request is merged, switches to master and removes the pr branch and pulls** diff --git a/rc.zsh b/rc.zsh new file mode 100644 index 0000000..e8a526c --- /dev/null +++ b/rc.zsh @@ -0,0 +1,41 @@ +# Silently remove any conflicting aliases +unalias postpr 2>/dev/null +unalias gc 2>/dev/null +unalias ga 2>/dev/null +unalias gp 2>/dev/null + +# --- Functions --- + +postpr() { + # Save current branch + local current_branch + current_branch=$(git symbolic-ref --short HEAD) + + if [[ "$current_branch" == "master" ]]; then + echo "You are already on master!" + return 1 + fi + + # Switch to master + git checkout master || return 1 + + # Pull latest changes + git pull origin master || return 1 + + # Delete previous branch locally + git branch -d "$current_branch" || echo "Failed to delete branch $current_branch. Maybe unmerged changes?" + + echo "Switched to master, pulled latest, and deleted branch $current_branch" +} + +gc() { + git commit -am $1 +} + +ga() { + git add -A +} + +gp() { + git pull +}