- 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
73 lines
2.1 KiB
Bash
73 lines
2.1 KiB
Bash
#!/bin/sh
|
|
|
|
# Git
|
|
git_push_all_changes() {
|
|
if [ -z "$1" ] || [ "$1" = " " ]; then
|
|
echo "Please provide a commit message."
|
|
return 126
|
|
fi
|
|
git add . && git commit -am "${1}" && git push
|
|
}
|
|
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 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"
|
|
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"
|
|
|
|
[ ! -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"
|
|
return 127
|
|
fi
|
|
|
|
lsof -i :"$1"
|
|
|
|
is_listening=$(lsof -i :"$1" | wc -l)
|
|
|
|
if [ "$is_listening" = 0 ]; then
|
|
return
|
|
fi
|
|
|
|
printf "\nKill above processes? : (y/n) "
|
|
read -r to_kill
|
|
|
|
if [ "$to_kill" = "y" ]; then
|
|
lsof -ti :"$1" | xargs kill -9 && echo "Successfully killed the processes listening on port $1"
|
|
fi
|
|
}
|