From ff5f5fde540d26e6c0c3a1f36d1da08cdcdd4dda Mon Sep 17 00:00:00 2001 From: Penelope Gwen <pogmommypenny@gmail.com> Date: Wed, 17 Apr 2024 14:45:02 -0600 Subject: [PATCH] New backup 2024-04-17 14:45:02 --- default/home/.sapphrc/default | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/default/home/.sapphrc/default b/default/home/.sapphrc/default index f0d78f8..e63997b 100755 --- a/default/home/.sapphrc/default +++ b/default/home/.sapphrc/default @@ -5,10 +5,25 @@ hyfetch #test # Quality of Life +#enable using sudo with functions +function Sudo { + local firstArg=$1 + if [ $(type -t $firstArg) = function ];then + shift && command sudo bash -c "$(declare -f $firstArg);$firstArg $*" + elif [ $(type -t $firstArg) = alias ];then + alias sudo='\sudo ' + eval "sudo $@" + else + command sudo "$@" + fi +} #find in history alias h="history|grep " #search files in current and sub dirs -alias f="find . |grep " +#alias f="find . |grep " +find_file() { + find . -name *"${1}"* +} #find running processes alias p="ps aux |grep " #open file @@ -16,7 +31,8 @@ alias o="open " #find large files #alias find_largest_files="du -h -x -s -- * | sort -r -h | head -20" sort_filesizes() { - sudo du -h --max-depth=1 "${1}" | sort --human-numeric-sort + [ -z ${1} ] && local dir="." || local dir="${1}" + du -h --max-depth=1 "$( realpath ${dir} )" | sort --human-numeric-sort } #User Env Vars