fix: change echo
commands to printf
commands
`printf` behaviour is more predictable then `echo` because bash is just overdoing things
This commit is contained in:
parent
97ae8ca1d0
commit
a94e6be43c
@ -26,12 +26,12 @@ services_list="netctl-auto@wlp4s0 systemd-timescyncd"
|
||||
|
||||
git_clone() {
|
||||
git clone https://gitlab.com/swy7ch/$1 ~/suckless/$1
|
||||
echo "$1 downloaded!"
|
||||
printf "\n$1 downloaded!"
|
||||
cd ~/$1
|
||||
git remote set-url origin git@gitlab.com:swy7ch/$1
|
||||
if [ "dotfiles" != $1 ]
|
||||
git remote add upstream git://git.suckless.org/$1
|
||||
echo "$1 setup complete!"
|
||||
printf "\n$1 setup complete!"
|
||||
fi
|
||||
cd
|
||||
}
|
||||
@ -39,7 +39,7 @@ git_clone() {
|
||||
build() {
|
||||
cd ~/$1
|
||||
sudo make clean install
|
||||
echo "$1 compilation complete!"
|
||||
printf "\n$1 compilation complete!"
|
||||
}
|
||||
|
||||
install() {
|
||||
@ -47,7 +47,7 @@ install() {
|
||||
if [ $validation = "y" ]; then
|
||||
yay -S $APP
|
||||
else
|
||||
echo "Skipping $APP"
|
||||
printf "\nSkipping $APP"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ enable_systemctl() {
|
||||
|
||||
|
||||
|
||||
echo "Configuring Arch..."
|
||||
printf "\nConfiguring Arch..."
|
||||
|
||||
# Retrieving yay
|
||||
# We need git
|
||||
@ -70,96 +70,96 @@ git clone https://aur.archlinux.org/yay.git
|
||||
cd yay
|
||||
makepkg -si
|
||||
|
||||
echo "YAY is here !"
|
||||
printf "\nYAY is here !"
|
||||
|
||||
cd ~
|
||||
|
||||
echo "Let's get the other apps"
|
||||
printf "\nLet's get the other apps"
|
||||
|
||||
# Installing apps
|
||||
|
||||
echo "Installing base"
|
||||
printf "\nInstalling base"
|
||||
|
||||
for app in $base_list; do
|
||||
install $app
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo "Installing utilitaries"
|
||||
printf "\nInstalling utilitaries"
|
||||
|
||||
for app in $utilities_list; do
|
||||
install $app
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo "Installing fonts"
|
||||
printf "\nInstalling fonts"
|
||||
|
||||
for app in $fonts_list; do
|
||||
install $app
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo "Installing media apps"
|
||||
printf "\nInstalling media apps"
|
||||
|
||||
for app in $media_list; do
|
||||
install $app
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo "Installing other apps"
|
||||
printf "\nInstalling other apps"
|
||||
|
||||
for app in $other_list; do
|
||||
install $app
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo "Installing vim-plug"
|
||||
printf "\nInstalling vim-plug"
|
||||
|
||||
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo "Installation complete !"
|
||||
printf "\nInstallation complete !"
|
||||
|
||||
# Symlinking the necessary stuff
|
||||
|
||||
echo "Downloading personnal git repos..."
|
||||
printf "\nDownloading personnal git repos..."
|
||||
|
||||
for repo in $git_list; do
|
||||
git_clone $repo
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo "Compiling tools..."
|
||||
printf "\nCompiling tools..."
|
||||
|
||||
for tool in $build_list; do
|
||||
build $tool
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo ""
|
||||
echo "!!! Don't forget to link an SSH key to your account !!!"
|
||||
echo "!!! As of now, you can't pull nor push anything !!!"
|
||||
echo ""
|
||||
printf "\n"
|
||||
printf "\n!!! Don't forget to link an SSH key to your account !!!"
|
||||
printf "\n!!! As of now, you can't pull nor push anything !!!"
|
||||
printf "\n"
|
||||
|
||||
echo "Enabling systemctl services"
|
||||
printf "\nEnabling systemctl services"
|
||||
|
||||
for service in $services_list; do
|
||||
enable_systemctl $service
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
printf "\nDone."
|
||||
|
||||
echo ""
|
||||
echo "##################################################"
|
||||
echo ""
|
||||
printf "\n"
|
||||
printf "\n##################################################"
|
||||
printf "\n"
|
||||
|
||||
echo "Configuration complete !"
|
||||
printf "\nConfiguration complete !\n"
|
||||
|
@ -26,7 +26,7 @@ input() {
|
||||
if [ "$1" = "reference" ]; then
|
||||
refinput | dmenu -i -p 'reference?' -l 10
|
||||
elif [ "$1" = "doctype" ]; then
|
||||
echo "$doctypes" | sed "s| |\n|g" | dmenu -i -p 'doctype?'
|
||||
printf "$doctypes" | sed "s| |\n|g" | dmenu -i -p 'doctype?'
|
||||
elif [ "$1" = "author" ]; then
|
||||
parse "author" | dmenu -i -p 'author name? (surname, first name)' -l 10
|
||||
elif [ "$1" = "keywords" ]; then
|
||||
@ -37,7 +37,7 @@ input() {
|
||||
}
|
||||
|
||||
refinput(){
|
||||
echo "ref$(cat "$file" | grep '@' | wc -l | awk '{printf $1}')" && parse "@"
|
||||
printf "ref$(cat "$file" | grep '@' | wc -l | awk '{printf $1}')\n" && parse "@"
|
||||
}
|
||||
|
||||
doctypes="article book online techreport"
|
||||
@ -105,14 +105,14 @@ while [ "$keyword_test" = "yes" ]; do
|
||||
fi
|
||||
done
|
||||
|
||||
echo "@$doctype{"$reference"," >> "$file"
|
||||
echo -e "\tauthor = \"$author\"," >> "$file"
|
||||
echo -e "\ttitle = \"$title\"," >> "$file"
|
||||
echo -e "\tyear = \"$year\"," >> "$file"
|
||||
[ -n "$journal" ] && echo -e "\tjournal = \"$journal\"," >> "$file"
|
||||
[ -n "$volume" ] && echo -e "\tvolume = \"$volume\"," >> "$file"
|
||||
[ -n "$publisher" ] && echo -e "\tpublisher = \"$publisher\"," >> "$file"
|
||||
[ -n "$url" ] && echo -e "\turl = \"$url\"," >> "$file"
|
||||
[ -n "$institution" ] && echo -e "\tinstitution = \"$institution\"," >> "$file"
|
||||
echo -e "\tkeywords = \"$keywords\"" >> "$file"
|
||||
echo "}" >> "$file"
|
||||
printf "\n@$doctype{"$reference"," >> "$file"
|
||||
printf "\n\tauthor = \"$author\"," >> "$file"
|
||||
printf "\n\ttitle = \"$title\"," >> "$file"
|
||||
printf "\n\tyear = \"$year\"," >> "$file"
|
||||
[ -n "$journal" ] && printf "\n\tjournal = \"$journal\"," >> "$file"
|
||||
[ -n "$volume" ] && printf "\n\tvolume = \"$volume\"," >> "$file"
|
||||
[ -n "$publisher" ] && printf "\n\tpublisher = \"$publisher\"," >> "$file"
|
||||
[ -n "$url" ] && printf "\n\turl = \"$url\"," >> "$file"
|
||||
[ -n "$institution" ] && printf "\n\tinstitution = \"$institution\"," >> "$file"
|
||||
printf "\n\tkeywords = \"$keywords\"" >> "$file"
|
||||
printf "\n}" >> "$file"
|
||||
|
@ -16,10 +16,10 @@ file="$(find $HOME/documents/bibliographies/ -type f -not -path '*/\.*' | dmenu
|
||||
refs_list="$(sed -e 's/\t//g' "$file" | tr '\n' ' ' | sed -e 's/}\ /}\n/g')"
|
||||
[ -z $refs_list ] && exit 1;
|
||||
|
||||
ref="$(echo "$refs_list" | dmenu -i -p 'infos?' -l 10)"
|
||||
ref="$(printf "$refs_list" | dmenu -i -p 'reference?' -l 10)"
|
||||
[ -z $ref ] && exit 1;
|
||||
|
||||
output="$(echo "$ref" | sed 's/author/\n author/g' | sed 's/",/",\n/g')"
|
||||
output="$(printf "$ref" | sed -e 's/author/\n author/g' -e 's/",/",\n/g')"
|
||||
|
||||
echo "$output" | dmenu -i -p "infos" -l 10
|
||||
echo "$ref" | awk -F '{' '{print $2}' | awk -F ',' '{print $1}' | xclip -selection clipboard
|
||||
printf "$output" | dmenu -i -p "infos" -l 10
|
||||
printf "$ref" | awk -F '{' '{print $2}' | awk -F ',' '{print $1}' | xclip -selection clipboard
|
||||
|
@ -17,7 +17,7 @@
|
||||
file=$(readlink -f "$1")
|
||||
dir=$(dirname "$file")
|
||||
dirname=$(basename "$dir")
|
||||
base="$(echo "${file%.*}" | awk -F '/' '{printf $NF}')"
|
||||
base="$(printf "${file%.*}" | awk -F '/' '{printf $NF}')"
|
||||
shebang=$(sed -n 1p "$file")
|
||||
|
||||
sucklesstools="$(ls $XDG_CONFIG_HOME/suckless)"
|
||||
@ -47,7 +47,7 @@ texcompile() { \
|
||||
s_build(){
|
||||
case "$file" in
|
||||
*config.def.h) sudo make clean install && rm -f config.h ;;
|
||||
*config.h) echo "" && echo "You should build from config.def.h !" ;;
|
||||
*config.h) printf "\nYou should build from config.def.h !" ;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
@ -14,7 +14,7 @@
|
||||
# Handle SIGTRAP signals sent by refbar to update the status bar immediately.
|
||||
trap 'update' 5
|
||||
|
||||
delim="|" # Set the delimiter character.
|
||||
delim=" | " # Set the delimiter character.
|
||||
|
||||
status() { \
|
||||
# Get the volume of ALSA's master volume output.
|
||||
@ -22,21 +22,22 @@ status() { \
|
||||
muted="$(pamixer --get-mute)"
|
||||
|
||||
if [ "$muted" = "true" ]; then
|
||||
echo " muted"
|
||||
printf " muted"
|
||||
else
|
||||
echo " 墳 $volume%"
|
||||
printf " 墳 $volume%%"
|
||||
fi
|
||||
|
||||
echo "$delim"
|
||||
printf "$delim"
|
||||
|
||||
# Wifi quality percentage and icon if ethernet is connected.
|
||||
grep "^\s*w" /proc/net/wireless | awk '{ print "索", int($3 * 100 / 70) "%" }'
|
||||
wifi="$(grep "^\s*w" /proc/net/wireless | awk '{ print "索", int($3 * 100 / 70) "%" }')"
|
||||
printf "$wifi"
|
||||
eth="$(cat /sys/class/net/enp0s25/operstate)"
|
||||
if [ "up" = "$eth" ]; then
|
||||
echo "/ "
|
||||
printf " / "
|
||||
fi
|
||||
|
||||
echo "$delim"
|
||||
printf "$delim"
|
||||
|
||||
# Will show all batteries with approximate icon for remaining power.
|
||||
# Or show that the computer is plugged to a power source
|
||||
@ -46,17 +47,17 @@ status() { \
|
||||
do
|
||||
if [ "$AC_ON" = 0 ]; then
|
||||
case "$(cat "$x")" in
|
||||
10[0-9]|101) echo "" ;;
|
||||
100|9[0-9]) echo " $(cat "$x")%" ;;
|
||||
8[0-9]|7[0-9]) echo " $(cat "$x")%" ;;
|
||||
6[0-9]|5[0-9]) echo " $(cat "$x")%" ;;
|
||||
4[0-9]|3[0-9]) echo " $(cat "$x")%" ;;
|
||||
*) echo " $(cat "$x")%" ;;
|
||||
10[0-9]|101) printf "" ;;
|
||||
100|9[0-9]) printf " $(cat "$x")%%" ;;
|
||||
8[0-9]|7[0-9]) printf " $(cat "$x")%%" ;;
|
||||
6[0-9]|5[0-9]) printf " $(cat "$x")%%" ;;
|
||||
4[0-9]|3[0-9]) printf " $(cat "$x")%%" ;;
|
||||
*) printf " $(cat "$x")%%" ;;
|
||||
esac
|
||||
else
|
||||
echo " $(cat "$x")%"
|
||||
printf " $(cat "$x")%%"
|
||||
fi
|
||||
done && echo "$delim"
|
||||
done && printf "$delim"
|
||||
|
||||
# Date and time.
|
||||
date '+%b. %d - %I:%M%p'
|
||||
|
@ -13,14 +13,14 @@
|
||||
|
||||
headers_list="$(ls | grep '.h$')"
|
||||
sources_list="$(ls | grep '.cp*$')"
|
||||
modules_list="$(echo "$sources_list" | sed 's/\.cp*//g' | tr '\n' ' ')"
|
||||
targets_list="$(echo "$sources_list" | sed 's/\.cp*/\.o/g' | tr '\n' ' ')"
|
||||
modules_list="$(printf "\n$sources_list" | sed 's/\.cp*//g' | tr '\n' ' ')"
|
||||
targets_list="$(printf "\n$sources_list" | sed 's/\.cp*/\.o/g' | tr '\n' ' ')"
|
||||
|
||||
get_compiler(){
|
||||
for source_ in "$sources_list"; do
|
||||
case "$source_" in
|
||||
*.cpp) echo "g++" && return;;
|
||||
*.c) echo "gcc";;
|
||||
*.cpp) printf "\ng++" && return;;
|
||||
*.c) printf "\ngcc";;
|
||||
esac
|
||||
done
|
||||
}
|
||||
@ -31,17 +31,17 @@ is_c_project(){
|
||||
|
||||
make_rule(){
|
||||
if [ "$comp" = "gcc" ]; then
|
||||
echo "$1.o : $1.c $1.h" >> makefile
|
||||
printf "\n$1.o : $1.c $1.h" >> makefile
|
||||
echo -e "\t\$(CC) -c $1.c \$(FLAGS)" >> makefile
|
||||
else
|
||||
echo "$1.o : $1.cpp $1.h" >> makefile
|
||||
printf "\n$1.o : $1.cpp $1.h" >> makefile
|
||||
echo -e "\t\$(CC) -c $1.cpp \$(FLAGS)" >> makefile
|
||||
fi
|
||||
echo "" >> makefile
|
||||
printf "\n" >> makefile
|
||||
}
|
||||
|
||||
if ! is_c_project; then
|
||||
echo "No C/C++ project in directory. Exiting..."
|
||||
printf "\nNo C/C++ project in directory. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -11,26 +11,26 @@
|
||||
######################################################################
|
||||
|
||||
|
||||
if [ -z ""$1"" ]; then
|
||||
echo "Please provide a name for your file"
|
||||
if [ -z "$1" ]; then
|
||||
printf 'Please provide a name for your file\n'
|
||||
elif [ -e "$1" ]; then
|
||||
echo "This filename is already taken, please provide a different name"
|
||||
printf 'This filename is already taken, please provide a different name\n'
|
||||
else
|
||||
touch "$1" && \
|
||||
echo "\# metadata" >> "$1" && \
|
||||
echo '.AUTHOR "David JULIEN"' >> "$1" && \
|
||||
echo '.TITLE' >> "$1" && \
|
||||
echo '\# template' >> "$1" && \
|
||||
echo '.PRINTSTYLE TYPESET' >> "$1" && \
|
||||
echo '.QUOTE_STYLE QUAD' >> "$1" && \
|
||||
echo '.SMARTQUOTES FR' >> "$1" && \
|
||||
echo '.ATTRIBUTE_STRING "par"' >> "$1" && \
|
||||
echo '.LINEBREAK_CHAR ""' >> "$1" && \
|
||||
echo '\# cover' >> "$1" && \
|
||||
echo '.COVER AUTHOR TITLE BLANKPAGE' >> "$1" && \
|
||||
echo '.DOCHEADER OFF' >> "$1" && \
|
||||
echo '\#' >> "$1" && \
|
||||
echo '.START' >> "$1" && \
|
||||
printf '\# metadata' >> "$1" && \
|
||||
printf '\n.AUTHOR "David JULIEN"' >> "$1" && \
|
||||
printf '\n.TITLE' >> "$1" && \
|
||||
printf '\n\# template' >> "$1" && \
|
||||
printf '\n.PRINTSTYLE TYPESET' >> "$1" && \
|
||||
printf '\n.QUOTE_STYLE QUAD' >> "$1" && \
|
||||
printf '\n.SMARTQUOTES FR' >> "$1" && \
|
||||
printf '\n.ATTRIBUTE_STRING "par"' >> "$1" && \
|
||||
printf '\n.LINEBREAK_CHAR ""' >> "$1" && \
|
||||
printf '\n\# cover' >> "$1" && \
|
||||
printf '\n.COVER AUTHOR TITLE BLANKPAGE' >> "$1" && \
|
||||
printf '\n.DOCHEADER OFF' >> "$1" && \
|
||||
printf '\n\#' >> "$1" && \
|
||||
printf '\n.START' >> "$1" && \
|
||||
|
||||
# checks if neovim is intalled
|
||||
if command -v nvim > /dev/null 2>&1; then
|
||||
|
@ -25,7 +25,7 @@ touch rendu.mom
|
||||
|
||||
for doc in "$list"; do
|
||||
cat "$doc" >> rendu.mom
|
||||
echo ".COLLATE" >> rendu.mom
|
||||
printf "\n.COLLATE" >> rendu.mom
|
||||
done
|
||||
|
||||
# Remove the last ".COLLATE"
|
||||
|
@ -12,69 +12,69 @@
|
||||
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Please provide a name for your file"
|
||||
printf "Please provide a name for your file\n"
|
||||
elif [ -e $1 ]; then
|
||||
echo "This filename is already taken, please provide a different name"
|
||||
printf "This filename is already taken, please provide a different name\n"
|
||||
else
|
||||
touch "$1"
|
||||
echo '% metadata' >> "$1"
|
||||
printf '%%metadata' >> "$1"
|
||||
read -p "Which type is your document? (def: article) " class
|
||||
if [ -z "$class" ]; then
|
||||
class='article'
|
||||
fi
|
||||
echo "\\documentclass[a4paper, 12pt]{$class}" >> "$1"
|
||||
echo '' >> "$1"
|
||||
printf "\n\\documentclass[a4paper, 12pt]{$class}" >> "$1"
|
||||
printf '\n' >> "$1"
|
||||
read -p "Do you want colors?(y/N) " colors
|
||||
if [ "$colors" = "y" ]; then
|
||||
echo '\usepackage[dvipsname]{xcolor}' >> "$1"
|
||||
printf '\n\usepackage[dvipsname]{xcolor}' >> "$1"
|
||||
fi
|
||||
read -p "Do you want hyperlinks management?(y/N) " links
|
||||
if [ "$links" = "y" ]; then
|
||||
if [ "$colors" != "y" ]; then
|
||||
echo '\usepackage[dvipsname]{xcolor}' >> "$1"
|
||||
printf '\n\usepackage[dvipsname]{xcolor}' >> "$1"
|
||||
fi
|
||||
echo '\usepackage[colorlinks=true, urlcolor=BrickRed]{hyperref}' >> "$1"
|
||||
printf '\n\usepackage[colorlinks=true, urlcolor=BrickRed]{hyperref}' >> "$1"
|
||||
fi
|
||||
read -p "Do you want bibliography management?(y/N) " bibliography
|
||||
if [ "$bibliography" = "y" ]; then
|
||||
read -p "Do you want to use apacite?(y/N) " apacite
|
||||
if [ $apacite = "y" ]; then
|
||||
echo '\usepackage{apacite}' >> "$1"
|
||||
printf '\n\usepackage{apacite}' >> "$1"
|
||||
bibstyle="apacite"
|
||||
else
|
||||
bibstyle="unsrt"
|
||||
echo 'The default style is _unsrt_ (you may change it at the end of the document)'
|
||||
printf '\nThe default style is _unsrt_ (you may change it at the end of the document)'
|
||||
fi
|
||||
bibfile="$(basename "$(find $HOME/documents/bibliographies/ -type f -not -path '*/\.*' | dmenu -l 20 -p "which bibliography?")")" # the -not -path allows find to ignore hidden files
|
||||
if [ -z "$bibfile" ]; then
|
||||
echo ''
|
||||
echo '##################################################'
|
||||
echo "Don't forget to specify the .bib file (\\bibliography{.bib}) at the end of the file " | fold -w 46 | sed "s/$/\ \#/g" | sed "s/^/\#\ /g"
|
||||
echo '##################################################'
|
||||
echo ''
|
||||
printf '\n'
|
||||
printf '\n##################################################'
|
||||
printf "\nDon't forget to specify the .bib file (\\bibliography{.bib}) at the end of the file " | fold -w 46 | sed "s/$/\ \#/g" | sed "s/^/\#\ /g"
|
||||
printf '\n##################################################'
|
||||
printf '\n'
|
||||
fi
|
||||
fi
|
||||
read -p "Do you want to use another package? If so, please provide a package name; else, just press <Enter>: " package
|
||||
while [ -n "$package" ]; do
|
||||
echo "\usepackage{"$package"}" >> "$1"
|
||||
printf "\n\usepackage{"$package"}" >> "$1"
|
||||
package=''
|
||||
read -p "Do you want to use another package? If so, please provide a package name: " package
|
||||
done
|
||||
echo '' >> "$1"
|
||||
echo '\author{David JULIEN}' >> "$1"
|
||||
printf '\n' >> "$1"
|
||||
printf '\n\\author{David JULIEN}' >> "$1"
|
||||
read -p "What is the title of the document? " title
|
||||
echo "\\title{"$title"}" >> "$1"
|
||||
echo '' >> "$1"
|
||||
echo '%document' >> "$1"
|
||||
echo '\begin{document}' >> "$1"
|
||||
echo '' >> "$1"
|
||||
echo '\maketitle' >> "$1"
|
||||
echo '' >> "$1"
|
||||
printf '\n\\title{"$title"}' >> "$1"
|
||||
printf '\n' >> "$1"
|
||||
printf '\n%%document' >> "$1"
|
||||
printf '\n\\begin{document}' >> "$1"
|
||||
printf '\n' >> "$1"
|
||||
printf '\n\\maketitle' >> "$1"
|
||||
printf '\n' >> "$1"
|
||||
if [ "$bibliography" = "y" ]; then
|
||||
echo "\bibliographystyle{$bibstyle}" >> "$1"
|
||||
echo "\bibliography{$HOME/documents/bibliographies/$bibfile}" >> "$1"
|
||||
printf '\n\bibliographystyle{$bibstyle}' >> "$1"
|
||||
printf '\n\bibliography{$HOME/documents/bibliographies/$bibfile}' >> "$1"
|
||||
fi
|
||||
echo '\end{document}' >> "$1"
|
||||
printf '\n\end{document}' >> "$1"
|
||||
|
||||
# check if neovim is installed
|
||||
if command -v nvim > /dev/null 2>&1; then
|
||||
|
Reference in New Issue
Block a user