From 0f94e435e2e08cdc20f0a07b76b820d6c5f666cb Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Tue, 24 Dec 2024 20:01:48 +0530 Subject: [PATCH] chore: Changes - Move tmux aliases to dotfiles - cpgi -> cp_gi : in sync with all other cp_* aliases - mann aliases for tldr - Git precommit template copy with cp_gitprecommit --- 10x_alias.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/10x_alias.sh b/10x_alias.sh index c2dcd2a..a69acb8 100644 --- a/10x_alias.sh +++ b/10x_alias.sh @@ -11,22 +11,16 @@ git_push_all_changes() { alias git_just_push=git_push_all_changes alias cd_root='cd $(git rev-parse --show-toplevel 2>/dev/null || echo ".")' alias cd_git_root=cd_root -[ ! -f "$GITIGNORE_TEMPLATE" ] || alias cpgi='cp ${GITIGNORE_TEMPLATE} .' - -# Tmux -command -v tmux >/dev/null && alias ta="tmux a" -command -v tmux >/dev/null && alias tat="tmux a -t" -command -v tmux >/dev/null && alias tls="tmux ls" -command -v tmux >/dev/null && alias tnew="tmux new" -command -v tmux >/dev/null && alias tnewt="tmux new -t" +[ ! -f "$GITIGNORE_TEMPLATE" ] || alias cp_gi='cp ${GITIGNORE_TEMPLATE} .' # command -v eza >/dev/null && alias ls="eza --hyperlink --header --git -M --icons=auto --color=never" alias ls='ls --color=auto --hyperlink' alias ll='ls -alhF' alias la='ls -Ah' alias lsa="ls -lAFhZ" -alias tldr="tldr --platform=linux " -alias h="tldr" +command -v tldr >/dev/null && alias tldr="tldr --platform=linux" +command -v tldr >/dev/null && alias mann="tldr" +command -v tldr >/dev/null && alias help="tldr" alias printpath="echo $PATH | tr : '\n'" command -v fzf >/dev/null && alias path="printenv | grep ^PATH= | sed 's/^PATH=//' | tr ':' '\n' | fzf" @@ -34,6 +28,27 @@ command -v fzf >/dev/null && alias path="printenv | grep ^PATH= | sed 's/^PATH=/ [ ! -f "$PRETTIER_TEMPLATE" ] || alias cp_prc='cp ${PRETTIER_TEMPLATE} .' [ ! -f "$PRETTIER_IGNORE_TEMPLATE" ] || alias cp_prigr='cp ${PRETTIER_IGNORE_TEMPLATE} .' +cp_gitprecommit() { + if [ ! -f "$GIT_PRECOMMIT_TEMPLATE" ]; then + echo "Git Pre-commit template does not exist" + return 1 + fi + + hooks_dir="$(pwd)/.git/hooks" + + if [ ! -d "$hooks_dir" ]; then + echo "Git repository not found under $(pwd)" + return 2 + fi + + if [ -f "$hooks_dir/$(basename "$GIT_PRECOMMIT_TEMPLATE")" ]; then + echo "pre-commit hook already exist. Skipping..." + return 0 + fi + + cp "$GIT_PRECOMMIT_TEMPLATE" "$hooks_dir" && printf "Pre-commit hook template copied to %s\n" "$hooks_dir" +} + port_who() { if [ -z "$1" ] || [ "$1" = " " ]; then echo "Please provide port number"