From d6b8d7e0aef435410d4218f7a3e432cafac72cc5 Mon Sep 17 00:00:00 2001 From: thek4n Date: Fri, 18 Jul 2025 20:11:35 +0300 Subject: [PATCH] git alias ga --- TARGETS.sh | 2 +- home/user/.config/git/aliases | 2 +- home/user/.config/zsh/aliases | 2 +- home/user/.local/bin/ga | 28 ++++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100755 home/user/.local/bin/ga diff --git a/TARGETS.sh b/TARGETS.sh index 1089159..e26d4f9 100644 --- a/TARGETS.sh +++ b/TARGETS.sh @@ -8,7 +8,7 @@ zsh:.config/zsh .zshenv .zshenv.d .inputrc %colors alacritty:.config/alacritty nvim:.config/nvim .editorconfig .editrc .local/bin/vim_askpass_helper ssh: -git:.config/git +git:.config/git .local/bin/ga ranger:.config/ranger gpg: i3:.xinitrc .xprofile .Xresources .config/i3 .config/i3status .local/bin/i3status_wrapper .config/rofi .config/picom .local/bin/slm .local/bin/slm_rofi.sh .local/bin/power_rofi.sh .local/bin/i3_switch_workspace.sh .config/mimeapps.list .local/bin/screenshot .local/bin/i3_swap_workspaces diff --git a/home/user/.config/git/aliases b/home/user/.config/git/aliases index 238d0d1..c0d083d 100644 --- a/home/user/.config/git/aliases +++ b/home/user/.config/git/aliases @@ -2,7 +2,7 @@ [alias] - a = "!git ls-files --exclude-standard --modified -t | fzf -1 -0 -m --bind load:last --preview 'git diff --color=always {2}' | cut -d' ' -f2 | xargs git add" + a = "!ga" u = "!git diff --name-only --cached | fzf -1 -0 -m --bind load:last --preview 'git diff --staged --color=always {1}' | xargs -r git restore --staged" msg = log -1 --pretty=%B d = diff diff --git a/home/user/.config/zsh/aliases b/home/user/.config/zsh/aliases index fcd0f6a..61c3fb2 100644 --- a/home/user/.config/zsh/aliases +++ b/home/user/.config/zsh/aliases @@ -76,7 +76,7 @@ alias vi='nvim' alias svi="sudo --preserve-env nvim" # git -for al in s d di co col cob ds a u ps pl pr hs last lastd df amend br fuck +for al in s d di co col cob ds u ps pl pr hs last lastd df amend br fuck do alias "g${al}"="git ${al}" done diff --git a/home/user/.local/bin/ga b/home/user/.local/bin/ga new file mode 100755 index 0000000..93c5276 --- /dev/null +++ b/home/user/.local/bin/ga @@ -0,0 +1,28 @@ +#!/bin/sh + + +_fzf_base() { + fzf -0 -m --bind load:last "${@}" | cut -d' ' -f2 +} + +fzf_get_selected_modified() { + _fzf_base -1 --border-label=' Modified ' --preview 'git diff --color=always {2}' +} + +fzf_get_selected_untracked() { + _fzf_base --border-label=' Untracked ' --preview 'highlight -O xterm256 {2}' +} + +gitadd() { + xargs git add +} + +git_ls_files() { + git ls-files --exclude-standard -t "${@}" +} + +modified_files="$(git_ls_files --modified)" +printf "%s" "${modified_files}" | fzf_get_selected_modified | gitadd + +untracked_files="$(git_ls_files --others)" +printf "%s" "${untracked_files}" | fzf_get_selected_untracked | gitadd