From de4430a2e7e75dca7176beb22b96d86bfc4a3662 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sun, 15 Apr 2018 22:07:50 +0300 Subject: [PATCH] Fix prerun_prune (is secure enough and works on OpenBSD). - Also, silence a few shellcheck alerts, aren't relevant. - And finally small change to ddg search, mainly aesthetics. --- .bashrc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.bashrc b/.bashrc index ad99ddd..cd51c49 100644 --- a/.bashrc +++ b/.bashrc @@ -88,6 +88,7 @@ alias unssh="ssh -o \"UserKnownHostsFile /dev/null\" -o \"StrictHostKeyChecking alias todo="vim \$HOME/Documents/TODO.yml" alias sudo="sudo " alias presentation='docker dev adarnimrod/presentation' +alias prune_prerun='find "$HOME" -maxdepth 1 -name ".prerun\.[0-9]*" | grep -v "$(pgrep -u "$(id -u)" "$(basename "$SHELL" )" )" | xargs -r rm' alias netdata='docker run --detach --name netdata --cap-add SYS_PTRACE --volume /proc:/host/proc:ro --volume /sys:/host/sys:ro --volume /var/run/docker.sock:/var/run/docker.sock --publish 19999:19999 firehol/netdata' alias jt='json_tool' alias http-server='python3 -m http.server 8080' @@ -110,9 +111,11 @@ for line in stdin.readlines(): fi } +# shellcheck disable=SC2120 urldecode () { if [ -t 0 ] then + # shellcheck disable=SC2119 echo "$@" | urldecode else python3 -c ' @@ -133,24 +136,17 @@ monitor () { fi } +# shellcheck disable=SC2120 json_tool () { if [ -t 0 ] then + # shellcheck disable=SC2119 echo "$@" | json_tool else python3 -m json.tool | pygmentize -l javascript fi } -prune_prerun () { - local shell_procs - shell_procs="$(pgrep -u "$(id -u)" "$(basename "$SHELL")")" - for file in $HOME/.prerun.* - do - echo "file" | grep -qv "$shell_procs" || rm "$file" - done -} - bold () { printf '\e[1m' echo "$@" @@ -228,7 +224,7 @@ bfg () { } ddg () { - lynx "https://duckduckgo.com/lite/?q=$(echo "$@" | urlencode)" + lynx "https://duckduckgo.com/lite/?q=$(urlencode "$@")" } bump () { -- GitLab