Advertisement
bvdeenen

strmprivacy config chooser

Jan 2nd, 2023 (edited)
1,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.88 KB | None | 0 0
  1.  
  2. unset -f sc
  3.  
  4. function sc_preview() {
  5.     d="$1"
  6.     f=$(basename $d)
  7.     icon=$(basename $(ls $d/icon-[PD]*))
  8.     icon=${icon##icon-[PD]}
  9.     grep "\.dev" $d/config.yaml > /dev/null
  10.     if [ $? -eq 0 ] ; then
  11.         echo "DEV $icon "
  12.     else
  13.         echo "PROD $icon "
  14.     fi
  15.     if [ -f $d/strm-creds*.json ] ; then
  16.         cat $d/strm-creds*.json | jq -r .email
  17.     else
  18.         echo "not logged in"
  19.     fi
  20.     echo $f
  21.     cat $d/config.yaml | sed -e 's/^#.*/&/g'
  22.  
  23. }
  24. export -f sc_preview
  25.  
  26. function sc() {
  27.     cd ~/.config
  28.     eval "p=$(find . -name icon-[PD]* | xargs dirname | xargs basename -a | fzf --preview \
  29.        'sc_preview {}' \
  30.        --preview-window=right:75%:wrap)"
  31.     if [ ! -z "$p" ] ; then
  32.         export STRM_CONFIG_PATH=$(realpath $p)
  33.     fi
  34.     cd - > /dev/null
  35.     echo "STRM_CONFIG_PATH=$STRM_CONFIG_PATH"
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement