From b5764c0376feebf2d0fdffbb74010e2acf4ac662 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Mon, 17 Oct 2022 18:49:58 +0200 Subject: [PATCH] Improve scripts --- .bin/.e | 6 +++--- .bin/autostart-manage | 14 ++++++++++++-- .bin/backlight | 2 +- .bin/gpg2-decrypt | 4 ++-- .bin/gpg2-encrypt | 4 ++-- .bin/source-remote-file | 4 ++-- .bin/vim-find | 5 +++-- .bin/vim-grep | 5 +++-- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.bin/.e b/.bin/.e index a719a34..fffd747 100755 --- a/.bin/.e +++ b/.bin/.e @@ -19,19 +19,19 @@ declare -A mapper=( ["zsh"]="$HOME/.config/zsh/.zshrc" ) -if [[ -z "$1" ]] +if [ -z "$1" ] then echo "No argument given. Use --list (-l) to show all options." exit fi -if [[ "$1" == "-l" ]] || [[ "$1" == "--list" ]] +if [ "$1" = "-l" ] || [ "$1" = "--list" ] then echo "${!mapper[@]}" exit fi target="${mapper["$1"]}" -if [[ -n "$target" ]] +if [ -n "$target" ] then $EDITOR "$target" else diff --git a/.bin/autostart-manage b/.bin/autostart-manage index 0f6cb59..87ed1b8 100755 --- a/.bin/autostart-manage +++ b/.bin/autostart-manage @@ -43,12 +43,22 @@ _autostart_manage_list () { } _autostart_manage_info () { - mapfile -t autostart_units < <( _list ) + autostart_units=() + while IFS='' read -r line + do + autostart_units+=("$line") + done < <(_list) + _echo_table "${autostart_units[@]}" | column -t -s$'\t' } _autostart_manage_enable_all () { - mapfile -t autostart_units < <( _list ) + autostart_units=() + while IFS='' read -r line + do + autostart_units+=("$line") + done < <(_list) + for unit in "${autostart_units[@]}" do _systemctl "$unit" add-wants autostart.target diff --git a/.bin/backlight b/.bin/backlight index 953b52d..dc68512 100755 --- a/.bin/backlight +++ b/.bin/backlight @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env sh set -e path="/sys/class/backlight/intel_backlight" diff --git a/.bin/gpg2-decrypt b/.bin/gpg2-decrypt index 3413168..08cf4e8 100755 --- a/.bin/gpg2-decrypt +++ b/.bin/gpg2-decrypt @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -gpg2 --output ${1%".gpg"} --decrypt $1 +gpg2 --output "${1%'.gpg'}" --decrypt "$1" diff --git a/.bin/gpg2-encrypt b/.bin/gpg2-encrypt index dbdf905..942d2c8 100755 --- a/.bin/gpg2-encrypt +++ b/.bin/gpg2-encrypt @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -gpg2 --output $1.gpg --encrypt $1 +gpg2 --output "$1.gpg" --encrypt "$1" diff --git a/.bin/source-remote-file b/.bin/source-remote-file index fa82730..92648a8 100755 --- a/.bin/source-remote-file +++ b/.bin/source-remote-file @@ -1,3 +1,5 @@ +#!/usr/bin/env sh + base_path="$HOME/.cache/remote-sources" mkdir -p "$base_path" file_path="$base_path/$1" @@ -7,5 +9,3 @@ then curl -Ls -o "$file_path" "$2" fi source $file_path - -# vim: ft=bash diff --git a/.bin/vim-find b/.bin/vim-find index 5c48dc3..d96a569 100755 --- a/.bin/vim-find +++ b/.bin/vim-find @@ -1,3 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -vim $(find $@) +# shellcheck disable=SC2046 +vim $(find "$@") diff --git a/.bin/vim-grep b/.bin/vim-grep index 05d4b35..ed618e8 100755 --- a/.bin/vim-grep +++ b/.bin/vim-grep @@ -1,3 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -vim $(grep $@) +# shellcheck disable=SC2046 +vim $(grep "$@")