Created
July 29, 2019 04:52
-
-
Save apwan/f3d4921af65437ca67974fb27f7be787 to your computer and use it in GitHub Desktop.
useful shell functions for .bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vicmd() { | |
[ "$#" -lt 1 ] && echo "Usage: $0 [CMD_name]" >&2 && return 1; | |
# check alias | |
#echo "type $(type -t $1)" | |
[[ "$(type -t $1)" =~ ("alias"|"builtin"|"function") ]] && echo "$1 is $(type -t $1), not a valid cmd! " >&2 && return 1 | |
local CMD_="$(which $1 2>/dev/null)" | |
[ -x "$CMD_" ] && vi "$CMD_" || vi "$MY_SHARE_HOME/bin/$1" | |
} | |
export -f vicmd | |
cmdir() { | |
dirname "$(readlink -f $(which $1 2>/dev/null) 2>/dev/null)" | |
} | |
export -f cmdir | |
sumdir() { | |
du -sh $@; | |
ls $@ | wc -l; | |
} | |
export -f sumdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment