usr

Modulate your userpace into POSIX-compliant shell scripts!
git clone git://clone.theohenson.com/usr.git
Log | Files | Refs | README

commit 11d9ada65aaad1a04143f3a87b42fcde965db444
parent cc23caafa3d17484d3fcad4006f756d108257aa7
Author: Theo Henson <[email protected]>
Date:   Mon, 11 Jan 2021 21:41:51 -0500

More portability

Diffstat:
Mhome/.bashrc | 10+++++++---
Mhome/.config/fish/config.fish | 25+++++--------------------
Mhome/.local/bin/lsearch | 2+-
Mhome/.local/bin/randwall | 10++++++++--
Mhome/.local/bin/volume_bar | 2+-
Mhome/.xinitrc | 4++--
6 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/home/.bashrc b/home/.bashrc @@ -1,9 +1,13 @@ # start fish if fish is not the parent process -PARENT="$(ps --no-header --pid=$PPID --format=cmd)" -[ "$PARENT" != "fish" ] && [ "$PARENT" != "-fish" ] && exec fish +parent="$(ps --no-header --pid=$PPID --format=cmd)" +[ "$parent" != "fish" ] && [ "$parent" != "-fish" ] && exec fish # prompt -PS1="\[\033[96m\][bash] \[\033[94m\w\] \[\$(git_status_prompt)\]" +if which git_status_prompt > /dev/null 2>&1 ; then + PS1="\[\033[96m\][bash] \[\033[94m\w\] \[\$(git_status_prompt)\]" +else + PS1="\[\033[96m\][bash] \[\033[94m\w\] \033[0m$ " +fi # aliases alias g="git" diff --git a/home/.config/fish/config.fish b/home/.config/fish/config.fish @@ -79,30 +79,15 @@ function fish_prompt echo -n (set_color 83A598)(pwd)' ' - echo -n (git_status_prompt) + if which git_status_prompt > /dev/null 2>&1 + echo -n (git_status_prompt) + else + echo -e -n "\x1b[0m\$ " + end end # vi mode indicator function fish_mode_prompt - # switch $fish_bind_mode - # case default - # set_color --bold red - # echo 'N' - # case insert - # set_color --bold green - # echo 'I' - # case replace_one - # set_color --bold green - # echo 'R' - # case visual - # set_color --bold brmagenta - # echo 'V' - # case '*' - # set_color --bold red - # echo '?' - # end - # set_color normal - # echo ' ' end # sudo !! diff --git a/home/.local/bin/lsearch b/home/.local/bin/lsearch @@ -3,6 +3,6 @@ url='lynx -vikeys -accept_all_cookies https://lite.duckduckgo.com/lite/?q=' -search=$(echo [email protected] | sed 's/ /+/g') +search=$(echo "[email protected]" | sed 's/ /+/g') eval "$url$search" diff --git a/home/.local/bin/randwall b/home/.local/bin/randwall @@ -1,10 +1,16 @@ #!/bin/sh # Sets my wallpaper to a random image in my wallpaper directory +[ -d "$XDG_PICTURES_DIR/wall" ] || exit 1 + +if [ $(ls -1A "$XDG_PICTURES_DIR/wall" | wc -l) -le 2 ] ; then + exit 1 +fi + old=$(cat "$XDG_CACHE_HOME"/oldwall) get_file () { - new=$(find "$XDG_PICTURES_DIR"/wall -type f -name '*' | shuf -n 1) + new=$(find "$XDG_PICTURES_DIR/wall" -type f -name '*' | shuf -n 1) } get_file @@ -13,4 +19,4 @@ while [ "$old" = "$new" ]; do done feh --no-fehbg --bg-fill "$new" -echo "$new" > "$XDG_CACHE_HOME"/oldwall +echo "$new" > "$XDG_CACHE_HOME/oldwall" diff --git a/home/.local/bin/volume_bar b/home/.local/bin/volume_bar @@ -2,7 +2,7 @@ # Prints volume information for dwmblocks vol=$(amixer -D pulse sget Master | grep 'Mono:' | awk -F'[][]' '{ print $2 }') -if ["$vol" -eq ""]; then +if [ "$vol" -eq "" ] ; then vol=$(amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }') fi echo "$vol" diff --git a/home/.xinitrc b/home/.xinitrc @@ -2,13 +2,13 @@ # configure monitors (system dependent) runif() { - if which $1 > /dev/null 2>&1 ; then + if which "$1" > /dev/null 2>&1 ; then [email protected] & fi } # configure x -if [ $(hostname) == "art" ] ; then +if [ "$(hostname)" = "art" ] ; then xrandr --output DP-3 --primary --mode 1920x1080 --pos 0x840 --rotate normal \ --output HDMI-1 --mode 1920x1080 --pos 1920x0 --rotate left --gamma 0.86 fi