From ce6e26ddeebde27027a027a45bc30c25567c56ef Mon Sep 17 00:00:00 2001 From: Seth Underwood Date: Fri, 6 Jan 2023 21:36:36 -0500 Subject: [PATCH 1/4] lib/bourne-shell: Add check for notify-send command prior to setting alert alias --- lib/bourne-shell.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bourne-shell.sh b/lib/bourne-shell.sh index c45e2f8..cd3fcac 100644 --- a/lib/bourne-shell.sh +++ b/lib/bourne-shell.sh @@ -74,7 +74,9 @@ fi # Add an "alert" alias for long running commands. Use like so: # sleep 10; alert -_omb_util_alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' +if _omb_util_binary_exists notify-send; then + _omb_util_alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' +fi # Alias definitions. # You may want to put all your additions into a separate file like From 81099f1c285cae485bca66917c80ac63f8bb1f0f Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 7 Jan 2023 13:08:35 +0900 Subject: [PATCH 2/4] aliases/misc: Do not assume the absolute path of executables --- aliases/misc.aliases.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/aliases/misc.aliases.sh b/aliases/misc.aliases.sh index 0536abf..cb6676c 100644 --- a/aliases/misc.aliases.sh +++ b/aliases/misc.aliases.sh @@ -63,21 +63,21 @@ alias qfind="find . -name " # qfind: Quickly search for file # 4. NETWORKING # --------------------------- -alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets -alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets -alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets -alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets -alias ipInfo0='ifconfig getpacket en0' # ipInfo0: Get info on connections for en0 -alias ipInfo1='ifconfig getpacket en1' # ipInfo1: Get info on connections for en1 -alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections -alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs +alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets +alias lsock='sudo lsof -i -P' # lsock: Display open sockets +alias lsockU='sudo lsof -nP | grep UDP' # lsockU: Display only open UDP sockets +alias lsockT='sudo lsof -nP | grep TCP' # lsockT: Display only open TCP sockets +alias ipInfo0='ifconfig getpacket en0' # ipInfo0: Get info on connections for en0 +alias ipInfo1='ifconfig getpacket en1' # ipInfo1: Get info on connections for en1 +alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections +alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs # --------------------------------------- # 5. SYSTEMS OPERATIONS & INFORMATION # --------------------------------------- -alias mountReadWrite='/sbin/mount -uw /' # mountReadWrite: For use when booted into single-user +alias mountReadWrite='mount -uw /' # mountReadWrite: For use when booted into single-user # --------------------------------------- From 64ac3df5c43e46214c48fbf094a9981c2d79cf70 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 7 Jan 2023 13:18:21 +0900 Subject: [PATCH 3/4] aliases/misc: Check existence of executables for aliases --- aliases/misc.aliases.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/aliases/misc.aliases.sh b/aliases/misc.aliases.sh index cb6676c..812f780 100644 --- a/aliases/misc.aliases.sh +++ b/aliases/misc.aliases.sh @@ -67,10 +67,12 @@ alias netCons='lsof -i' # netCons: Show all open TC alias lsock='sudo lsof -i -P' # lsock: Display open sockets alias lsockU='sudo lsof -nP | grep UDP' # lsockU: Display only open UDP sockets alias lsockT='sudo lsof -nP | grep TCP' # lsockT: Display only open TCP sockets -alias ipInfo0='ifconfig getpacket en0' # ipInfo0: Get info on connections for en0 -alias ipInfo1='ifconfig getpacket en1' # ipInfo1: Get info on connections for en1 alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs +if _omb_util_binary_exists ifconfig; then + alias ipInfo0='ifconfig getpacket en0' # ipInfo0: Get info on connections for en0 + alias ipInfo1='ifconfig getpacket en1' # ipInfo1: Get info on connections for en1 +fi # --------------------------------------- @@ -101,11 +103,14 @@ alias weeknum='date +%V' # 8. WEB DEVELOPMENT # --------------------------------------- -alias apacheEdit='sudo edit /etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf -alias apacheRestart='sudo apachectl graceful' # apacheRestart: Restart Apache alias editHosts='sudo edit /etc/hosts' # editHosts: Edit /etc/hosts file -alias herr='tail /var/log/httpd/error_log' # herr: Tails HTTP error logs -alias apacheLogs="less +F /var/log/apache2/error_log" # Apachelogs: Shows apache error logs + +if _omb_util_binary_exists apachectl; then + alias apacheEdit='sudo edit /etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf + alias apacheRestart='sudo apachectl graceful' # apacheRestart: Restart Apache + alias herr='tail /var/log/httpd/error_log' # herr: Tails HTTP error logs + alias apacheLogs="less +F /var/log/apache2/error_log" # Apachelogs: Shows apache error logs +fi # --------------------------------------- # 9. OTHER ALIASES From fff8f7f002b70be35af76b21f685be96884f226e Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 24 Jan 2023 09:16:15 +0900 Subject: [PATCH 4/4] aliases/misc: Add source information --- aliases/misc.aliases.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aliases/misc.aliases.sh b/aliases/misc.aliases.sh index 812f780..077c2fe 100644 --- a/aliases/misc.aliases.sh +++ b/aliases/misc.aliases.sh @@ -1,6 +1,12 @@ #! bash oh-my-bash.module -# --------------------------------------------------------------------------- +#------------------------------------------------------------------------------ +# Note on copyright (2022-08-23): The aliases defined in this file seems to +# originally come from a blog post [1]. See also the comments in lib/base.sh. # +# [1] Nathaniel Landau, "My Mac OSX Bash Profile", +# https://natelandau.com/my-mac-osx-bash_profile/, 2013-07-02. +# +#------------------------------------------------------------------------------ # Description: This file holds many useful BASH aliases and save our lives! # # Sections: @@ -15,7 +21,7 @@ # # X. Reminders & Notes # -# --------------------------------------------------------------------------- +#------------------------------------------------------------------------------ # ------------------------------- # 1. FILE AND FOLDER MANAGEMENT