dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

pass-import-txt (619B)


      1 #!/usr/bin/env bash
      2 if [ $# -ne 2 ]; then
      3   echo 'Usage: pass-import-txt [file] [path]'
      4   exit 1
      5 fi
      6 
      7 dest="${2%/}"
      8 echo "$(tput setaf 6)This is what's gonna happen:"
      9 while read -r line; do 
     10   arr=(${line/:/ }); 
     11   echo "echo ${arr[1]} | pass insert --multiline $dest/${arr[0]}"; 
     12 done < "$1"
     13 
     14 echo -ne "\n$(tput setaf 3)Is this OK? [Y/n]"
     15 read -rn 1 -s CONF
     16 case $CONF in
     17   Y|y)
     18     echo -e "\n$(tput setaf 6)OK, importing...$(tput sgr0)"
     19     ;;
     20   *) exit 1;;
     21 esac
     22 while read -r line; do 
     23   arr=(${line//:/ }); 
     24   echo "${arr[1]}" | pass insert --multiline "$dest"/"${arr[0]}"; 
     25 done < "$1"
     26 echo "$(tput setaf 2)Done."