printf "The config variables are stored in this script itself \n Enter yes if you want to open it now \n Enter no if you want to edit it yourself later\n"
while true; do
read -rp "$2 " yn
case $yn in
[Yy]*) open=1; break;;
[Nn]*) open=0; break;;
*) echo "Please answer yes or no"
esac
done
if [[ $open == 1 ]]
then {
if which twtxt-c &> /dev/null
then
scriptpath=$(which twtxt-c)
else {
read -p "Path to this script [`pwd`/twtxt-c]" scriptpath
scriptpath=${scriptpath:-"`pwd`/twtxt-c"}
}
fi
if [ -z "$EDITOR" ]
then
{
if which vim &> /dev/null
then
vim $scriptpath
elif which nvim &> /dev/null
then
nvim $scriptpath
elif which emacs &> /dev/null
then
emacs -nw $scriptpath
elif which nano &> /dev/null
then
nano $scriptpath
else
echo " EDITOR variable is empty and vim, neovim, emacs and nano not found. please open this script using your preferred text editor and set the config variables"
fi
echo "Now you can tweet using twtxt-c tweet <tweet>"
}
else
$EDITOR $scriptpath
fi
}
else
echo "Please edit the script and set nick, path to twtxt file and url for twtxt file"
fi
echo "would you like to copy this script to $HOME/.local/bin [yes/no]"
while true; do
read -rp "$3 " yn
case $yn in
[Yy]*) copy=1; break;;
[Nn]*) copy=0; break;;
*) echo "Please answer yes or no"
esac
done
if [[ $copy == 1 ]]
then {
# give warning if path not ok
if [[ $PATH != *"$HOME/.local/bin"* && $PATH != *"~/.local/bin"* ]]
then
echo " Warning: $HOME/.local/bin is not in PATH "
fi
# checking for scriptpath
if which twtxt-c &> /dev/null
then
echo "already present"
elif [[ -z "$scriptpath" ]]
then {
read -p "Path to this script [`pwd`/twtxt-c]" scriptpath
scriptpath=${scriptpath:-"`pwd`/twtxt-c"}
cp $scriptpath $HOME/.local/bin/
}
else
cp $scriptpath $HOME/.local/bin/
fi
}
fi
printf "Would you like to set the following aliases \n ttc=twtxt-c timeline\n twtc=twtxt-c tweet\n"
while true; do
read -rp "$3 " yn
case $yn in
[Yy]*) als=1; break;;
[Nn]*) als=0; break;;
*) echo "Please answer yes or no"
esac
done
if [[ $als == 1 ]]
then {
read -p "Path to alias file [$HOME/.bash_aliases]" alspath