Files
dev_prod/10x_alias.sh
2024-11-20 16:46:41 +05:30

58 lines
1.7 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 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"
# 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"
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} .'
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
}