feat(function): port_who added

This commit is contained in:
Pratik Tripathy
2024-11-20 16:46:41 +05:30
parent c987f015fd
commit d403585c3a

View File

@@ -2,7 +2,7 @@
# Git # Git
git_push_all_changes() { git_push_all_changes() {
if [ "$1" = "" ]; then if [ -z "$1" ] || [ "$1" = " " ]; then
echo "Please provide a commit message." echo "Please provide a commit message."
return 126 return 126
fi fi
@@ -25,8 +25,33 @@ alias ls='ls --color=auto --hyperlink'
alias ll='ls -alhF' alias ll='ls -alhF'
alias la='ls -Ah' alias la='ls -Ah'
alias lsa="ls -lAFhZ" alias lsa="ls -lAFhZ"
alias tldr="tldr --platform=linux "
alias h="tldr"
alias path="env | grep ^PATH= | sed 's/^PATH=//' | tr ':' '\n'" alias printpath="echo $PATH | tr : '\n'"
command -v fzf >/dev/null && alias path="printenv | grep ^PATH= | sed 's/^PATH=//' | tr ':' '\n' | fzf" command -v fzf >/dev/null && alias path="printenv | grep ^PATH= | sed 's/^PATH=//' | tr ':' '\n' | fzf"
[ ! -f "$PRETTIER_TEMPLATE" ] || alias cpprc='cp ${PRETTIER_TEMPLATE} .' [ ! -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
}