add shell linting/make

This commit is contained in:
Daylin Morgan 2022-07-06 11:55:14 -05:00
parent c8025c2cde
commit d38e26bf5d
11 changed files with 202 additions and 217 deletions

3
Makefile Normal file
View file

@ -0,0 +1,3 @@
.PHONY: lint
lint:
shfmt -s -w $(shell shfmt -f .)

View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if ! $(is-executable yq); then if ! $(is-executable yq); then
echo "you will need to install yq" echo "you will need to install yq"
echo "see here for more info: https://github.com/mikefarah/yq" echo "see here for more info: https://github.com/mikefarah/yq"
fi fi
YAMLDOC="$HOME/.dotfiles/info/pkgs.yml" YAMLDOC="$HOME/.dotfiles/info/pkgs.yml"

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ -x "$(command -v $1)" ]; then if [ -x "$(command -v $1)" ]; then
exit 0 exit 0
else else
exit 1 exit 1
fi fi

View file

@ -1,8 +1,9 @@
#!/bin/sh #!/bin/sh
case $(tty) in /dev/tty[0-9]*) case $(tty) in /dev/tty[0-9]*)
exit 0;; exit 0
*) ;;
exit 1;; *)
exit 1
;;
esac esac

216
extras.sh
View file

@ -6,9 +6,8 @@
MAMBAFORGE_RELEASE="https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh" MAMBAFORGE_RELEASE="https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh"
MAMBAFORGE_INSTALLER="Mambaforge-Linux-x86_64.sh" MAMBAFORGE_INSTALLER="Mambaforge-Linux-x86_64.sh"
help() { help() {
cat << EOF cat <<EOF
extras downloaders extras downloaders
by default will download all packages listed below by default will download all packages listed below
@ -29,144 +28,135 @@ EOF
} }
for opt in "$@"; do for opt in "$@"; do
case $opt in case $opt in
--help) --help)
help help
exit 0 exit 0
;; ;;
--force) force=1 ;; --force) force=1 ;;
--fzf) fzf=1 ;; --fzf) fzf=1 ;;
--nvm) nvm=1 ;; --nvm) nvm=1 ;;
--mambaforge) mamba=1 ;; --mambaforge) mamba=1 ;;
*) *)
echo "unknown option: $opt" echo "unknown option: $opt"
help help
exit 1 exit 1
;; ;;
esac esac
done done
check_existing() { check_existing() {
pkg=$1 pkg=$1
install_dir=$2 install_dir=$2
declare -n skip_out=$3 declare -n skip_out=$3
if [ -d "$install_dir" ]; then if [ -d "$install_dir" ]; then
echo "found existing $pkg installation" echo "found existing $pkg installation"
if [[ "$force" ]]; then if [[ "$force" ]]; then
echo "removing previous installation" echo "removing previous installation"
rm -rf $install_dir rm -rf $install_dir
skip_out=0 skip_out=0
else else
skip_out=1 skip_out=1
fi fi
else else
skip_out=0 skip_out=0
fi fi
} }
ask() { ask() {
while true; do while true; do
read -p "$1 ([y]/n) " -r read -p "$1 ([y]/n) " -r
REPLY=${REPLY:-"y"} REPLY=${REPLY:-"y"}
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
return 1 return 1
elif [[ $REPLY =~ ^[Nn]$ ]]; then elif [[ $REPLY =~ ^[Nn]$ ]]; then
return 0 return 0
fi fi
done done
} }
install_fzf() { install_fzf() {
echo "##############" echo "##############"
echo installing fzf echo installing fzf
echo "##############" echo "##############"
check_existing "fzf" "$HOME/.fzf" skip check_existing "fzf" "$HOME/.fzf" skip
if [[ "$skip" -eq 1 ]]; if [[ $skip -eq 1 ]]; then
then echo "remove your previous installation or rerun with --force"
echo "remove your previous installation or rerun with --force" return
return fi
fi
echo "installing fzf using git" echo "installing fzf using git"
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install \
--key-bindings \
--completion \
--no-bash \
--no-zsh \
--no-update-rc \
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install \
--key-bindings \
--completion \
--no-bash \
--no-zsh \
--no-update-rc
} }
install_nvm() { install_nvm() {
echo "##############" echo "##############"
echo installing nvm echo installing nvm
echo "##############" echo "##############"
check_existing "nvm" "$HOME/.nvm" skip check_existing "nvm" "$HOME/.nvm" skip
if [[ "$skip" -eq 1 ]]; if [[ $skip -eq 1 ]]; then
then echo "remove your previous installation or rerun with --force"
echo "remove your previous installation or rerun with --force" return
return fi
fi
local current_dir=$PWD local current_dir=$PWD
git clone https://github.com/nvm-sh/nvm.git ~/.nvm git clone https://github.com/nvm-sh/nvm.git ~/.nvm
cd ~/.nvm cd ~/.nvm
git checkout v0.39.0 git checkout v0.39.0
. ./nvm.sh . ./nvm.sh
cd $current_dir cd $current_dir
} }
install_mambaforge() { install_mambaforge() {
echo "#####################" echo "#####################"
echo installing mambaforge echo installing mambaforge
echo "#####################" echo "#####################"
check_existing "mambaforge" "$HOME/mambaforge" skip
check_existing "mambaforge" "$HOME/mambaforge" skip if [[ $skip -eq 1 ]]; then
echo "remove your previous installation or rerun with --force"
return
fi
if [[ "$skip" -eq 1 ]]; echo "fetching install script from github"
then
echo "remove your previous installation or rerun with --force"
return
fi
echo "fetching install script from github" current_dir=$PWD
current_dir=$PWD cd ~/
cd ~/ wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh
bash "$MAMBAFORGE_INSTALLER" -s
rm "$MAMBAFORGE_INSTALLER"
wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh echo "cleaning up installer"
bash "$MAMBAFORGE_INSTALLER" -s
rm "$MAMBAFORGE_INSTALLER"
echo "cleaning up installer" cd $current_dir
cd $current_dir
} }
install_all() { install_all() {
echo "installing all packages..." echo "installing all packages..."
echo echo
install_fzf install_fzf
echo echo
install_nvm install_nvm
echo echo
install_mambaforge install_mambaforge
} }
@ -174,27 +164,25 @@ install_all() {
echo $@ echo $@
echo "#################" echo "#################"
echo EXTRAS DOWNLOADER echo EXTRAS DOWNLOADER
echo "#################" echo "#################"
echo echo
if [ $# -eq 0 ]; if [ $# -eq 0 ]; then
then install_all
install_all exit
exit
fi fi
if [ "$fzf" ]; then if [ "$fzf" ]; then
install_fzf install_fzf
fi fi
if [ "$nvm" ]; then if [ "$nvm" ]; then
install_nvm install_nvm
fi fi
if [ "$mamba" ]; if [ "$mamba" ]; then
then install_mambaforge install_mambaforge
fi fi
echo "FINISHED!" echo "FINISHED!"

View file

@ -7,38 +7,37 @@ sysmodmap=/etc/X11/xinit/.Xmodmap
# merge in defaults and keymaps # merge in defaults and keymaps
if [ -f $sysresources ]; then if [ -f $sysresources ]; then
xrdb -merge $sysresources xrdb -merge $sysresources
fi fi
if [ -f $sysmodmap ]; then if [ -f $sysmodmap ]; then
xmodmap $sysmodmap xmodmap $sysmodmap
fi fi
if [ -f "$userresources" ]; then if [ -f "$userresources" ]; then
xrdb -merge "$userresources" xrdb -merge "$userresources"
fi fi
if [ -f "$usermodmap" ]; then if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap" xmodmap "$usermodmap"
fi fi
# start some nice programs # start some nice programs
if [ -d /etc/X11/xinit/xinitrc.d ] ; then if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do for f in /etc/X11/xinit/xinitrc.d/?*.sh; do
[ -x "$f" ] && . "$f" [ -x "$f" ] && . "$f"
done done
unset f unset f
fi fi
[ -f ~/.xprofile ] && . ~/.xprofile [ -f ~/.xprofile ] && . ~/.xprofile
eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh) eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
export SSH_AUTH_SOCK export SSH_AUTH_SOCK
not_leftwm() { not_leftwm() {
unclutter --timeout 1 & unclutter --timeout 1 &
} }
# $1 is xterm # $1 is xterm
@ -46,25 +45,25 @@ not_leftwm() {
# i.e. startx qtile # i.e. startx qtile
case $2 in case $2 in
leftwm) leftwm)
export DESKTOP_SESSION=leftwm export DESKTOP_SESSION=leftwm
exec leftwm exec leftwm
;; ;;
plasma) plasma)
export DESKTOP_SESSION=plasma export DESKTOP_SESSION=plasma
exec startplasma-x11 exec startplasma-x11
;; ;;
xmonad) xmonad)
export DESKTOP_SESSION=xmonad export DESKTOP_SESSION=xmonad
xmonad xmonad
;; ;;
qtile) qtile)
not_leftwm not_leftwm
export DESKTOP_SESSION=qtile export DESKTOP_SESSION=qtile
exec qtile start exec qtile start
;; ;;
*) *)
not_leftwm not_leftwm
export DESKTOP_SESSION=qtile export DESKTOP_SESSION=qtile
;; ;;
esac esac

View file

@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if ! [[ -f /usr/bin/i3lock ]]; then notify-send "no i3lock...install i3lock-color" if ! [[ -f /usr/bin/i3lock ]]; then
notify-send "no i3lock...install i3lock-color"
exit exit
fi fi
# colors # colors
@ -41,9 +42,9 @@ make_figlet() {
} }
font_size=25 font_size=25
font_to_px=$(( $font_size * 16 / 12 )) font_to_px=$((font_size * 16 / 12))
greeter_h=$(($(make_figlet | wc -l) * $font_to_px)) greeter_h=$(($(make_figlet | wc -l) * font_to_px))
greeter_w=$(($(make_figlet | wc -L ) * $font_to_px)) greeter_w=$(($(make_figlet | wc -L) * font_to_px))
greeter_pos="x+w/2-${greeter_w}/4:y+h/2-${greeter_h}/4" greeter_pos="x+w/2-${greeter_w}/4:y+h/2-${greeter_h}/4"
@ -55,34 +56,33 @@ sleep 0.1
# lock the screen # lock the screen
i3lock \ i3lock \
-n \ -n \
--screen 1 \ --screen 1 \
\ \
--color $bg_color \ --color $bg_color \
--inside-color ffffff00 \ --inside-color ffffff00 \
--ring-color $green \ --ring-color $green \
--ringwrong-color $red \ --ringwrong-color $red \
--ringver-color $cyan \ --ringver-color $cyan \
--insidewrong-color $bg_color \ --insidewrong-color $bg_color \
--insidever-color $bg_color \ --insidever-color $bg_color \
--line-uses-ring \ --line-uses-ring \
--separator-color $selection \ --separator-color $selection \
--keyhl-color $cyan \ --keyhl-color $cyan \
--bshl-color $red \ --bshl-color $red \
--wrong-color $red \ --wrong-color $red \
\ \
--ind-pos x+w-5-r:y+h-10-r \ --ind-pos x+w-5-r:y+h-10-r \
--ring-width 25 \ --ring-width 25 \
--radius 100 \ --radius 100 \
--verif-text "" \ --verif-text "" \
\ \
--greeter-text "$(make_figlet)" \ --greeter-text "$(make_figlet)" \
--greeter-font "${font}" \ --greeter-font "${font}" \
--greeter-size $font_size \ --greeter-size $font_size \
--greeter-color $cyan \ --greeter-color $cyan \
--greeter-pos "${greeter_pos}" \ --greeter-pos "${greeter_pos}" \
--greeter-align 1 \ --greeter-align 1
# resume message display # resume message display
pkill -u "$USER" -USR2 dunst pkill -u "$USER" -USR2 dunst

View file

@ -4,8 +4,6 @@
files=(alacritty.yml dracula.yml dracula-pro.yml) files=(alacritty.yml dracula.yml dracula-pro.yml)
for file in "${files[@]}" for file in "${files[@]}"; do
do
cp -v $DOTFILES_DIR/config/alacritty/$file /mnt/c/Users/daylin/AppData/Roaming/alacritty/$file cp -v $DOTFILES_DIR/config/alacritty/$file /mnt/c/Users/daylin/AppData/Roaming/alacritty/$file
done done

View file

@ -14,16 +14,16 @@
# bindkey -s '^o' 'lfcd\n' # zsh # bindkey -s '^o' 'lfcd\n' # zsh
# #
lfcd () { lfcd() {
tmp="$(mktemp)" tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@" lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then if [ -f "$tmp" ]; then
dir="$(cat "$tmp")" dir="$(cat "$tmp")"
rm -f "$tmp" rm -f "$tmp"
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
if [ "$dir" != "$(pwd)" ]; then if [ "$dir" != "$(pwd)" ]; then
cd "$dir" cd "$dir"
fi fi
fi fi
fi fi
} }

View file

@ -2,7 +2,7 @@ function cl() {
DIR="$*" DIR="$*"
# if no DIR given, go home # if no DIR given, go home
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
DIR=$HOME DIR=$HOME
fi fi
builtin cd "${DIR}" && builtin cd "${DIR}" &&
# use your preferred ls command # use your preferred ls command
@ -75,5 +75,5 @@ py2nb2html() {
alias bathelp='bat --plain --language=help' alias bathelp='bat --plain --language=help'
help() { help() {
"$@" --help 2>&1 | bathelp "$@" --help 2>&1 | bathelp
} }

View file

@ -3,47 +3,43 @@
YAMLDOC="extensions.yml" YAMLDOC="extensions.yml"
# check for yq # check for yq
if ! command -v yq &> /dev/null if ! command -v yq &>/dev/null; then
then echo "yq could not be found"
echo "yq could not be found" echo "to install w/ eget"
echo "to install w/ eget" echo "eget mikefarah/yq"
echo "eget mikefarah/yq" exit
exit
fi fi
readarray sections < <(yq e 'keys | .[]' $YAMLDOC) readarray sections < <(yq e 'keys | .[]' $YAMLDOC)
get_extensions() { get_extensions() {
for section in "${sections[@]}" for section in "${sections[@]}"; do
do echo $section
echo $section readarray exts < <(key=$section yq e '.[env(key)] | .[]' $YAMLDOC)
readarray exts < <(key=$section yq e '.[env(key)] | .[]' $YAMLDOC) echo ${exts[@]}
echo ${exts[@]} for ext in "${exts[@]}"; do
for ext in "${exts[@]}" write_bat $ext
do write_sh $ext
write_bat $ext done
write_sh $ext done
done
done
} }
write_bat() { write_bat() {
echo "call code --install-extension $1 --force" >> install-extensions.bat echo "call code --install-extension $1 --force" >>install-extensions.bat
} }
write_sh() { write_sh() {
echo "code --install-extension $1 --force" >> install-extensions.sh echo "code --install-extension $1 --force" >>install-extensions.sh
} }
# clean up old files # clean up old files
rm -f install-extensions.{sh,bat} rm -f install-extensions.{sh,bat}
echo "echo off" > install-extensions.bat echo "echo off" >install-extensions.bat
echo >> install-extensions.bat echo >>install-extensions.bat
echo "echo Installing VSCode extensions" >> install-extensions.bat echo "echo Installing VSCode extensions" >>install-extensions.bat
echo "#!/usr/bin/env bash" > install-extensions.sh echo "#!/usr/bin/env bash" >install-extensions.sh
echo >> install-extensions.sh echo >>install-extensions.sh
echo "echo Installing VSCode extensions" >> install-extensions.sh echo "echo Installing VSCode extensions" >>install-extensions.sh
# read extensions and write install scripts # read extensions and write install scripts
get_extensions get_extensions