diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2020-08-20 17:50:04 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2020-08-20 17:50:04 +0200 |
commit | f24707548f28efe6686bf118c477d91b6e573772 (patch) | |
tree | 123e487e47804d726de82b001e14420b0497ac30 /scripts | |
parent | 85d4f3d77b05dcda95197eca2b3297bf84b3f720 (diff) | |
parent | f92de02473499669c1a83f8563b77a1c64ad4a02 (diff) | |
download | dotfiles-f24707548f28efe6686bf118c477d91b6e573772.tar.gz |
Merge branch 'master' of jonasgunz.de:repos/dotfiles into master
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/bulkrename.sh | 41 | ||||
-rwxr-xr-x | scripts/system-setup | 64 |
2 files changed, 41 insertions, 64 deletions
diff --git a/scripts/bulkrename.sh b/scripts/bulkrename.sh new file mode 100755 index 0000000..9df17d2 --- /dev/null +++ b/scripts/bulkrename.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Rename multiple files at once using a text editor +# File list can be given as args +# if no args, all files in pwd are used + +EDITOR=${EDITOR=:vi} + +while [ -z "$TMPFILE" -o -e "$TMPFILE" ]; do + TMPFILE="/tmp/bulkrename.$RANDOM" +done +touch "$TMPFILE" + +FILES=( ) +if [ $# -eq 0 ]; then + FILES=( * ) +else + FILES=( $@ ) +fi + +# List current dir +for f in "${FILES[@]}"; do + echo $f >> "$TMPFILE" +done + +eval "$EDITOR $TMPFILE" + +i=0 +while read line; do + if [ "$line" != "${FILES[$i]}" -a -e "${FILES[$i]}" -a ! -e "$line" ]; then + echo "${FILES[$i]} -> $line" + if [ -e "${FILES[$i]}" -a ! -e "$line" ]; then + mv "${FILES[$i]}" "$line" + else + echo Error. does target already exist? + fi + fi + + i=$(( i + 1 )) +done < "$TMPFILE" + +rm "$TMPFILE" diff --git a/scripts/system-setup b/scripts/system-setup deleted file mode 100755 index 6e2bebe..0000000 --- a/scripts/system-setup +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -#interactive systen setup - -AUTHKEY_FILE_URL="https://jonasgunz.de/authorized_keys" - -if [ $(id -u) -ne 0 ]; then - echo Supposed to run as root. - return 1 -fi - -yes_no() -{ - read -p "$1 (y/[n])" inp - case $inp in - [yY]* ) return 0;; - * ) return 1;; - esac -} - -selector() -{ - local cnt=0 - local regex="^-?[0-9]+\$" - for selection in "$@" - do - echo "$cnt) $selection" - ((cnt=$cnt + 1)) - done - - read -p "(default=0) >" inp - if [[ "$inp" =~ $regex ]] && [ $inp -ge 0 -a $inp -le $# ] - then - return $inp - elif [ -z $inp ] - then - return 0 - else - return -1 - fi -} - -function user_setup() { - while true; do - read -p "Name for new User: " username - if [ ! -z $username ]; then - break; - fi - done -} - -echo "Interactive system setup" - -while true ; do - selector "User setup" "Exit" - case $? in - 0) - user_setup;; - 1) - exit 0;; - *) - echo Wrong input;; - esac -done |