Moulinette params
This commit is contained in:
parent
3b4068fac9
commit
00cf30350f
75
.bashrc
75
.bashrc
|
@ -3,17 +3,17 @@ alias v='vim'
|
|||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
alias tmux='tmux -2'
|
||||
alias ft='cc -Wall -Wextra -Werror -o main -xc -- <(grep -v "////" *.c) && ./main; rm -f -- ./main; :'
|
||||
alias ft='cc -Wall -Wextra -Werror -o main -xc -- <(grep -v "////" *.c) && ./main ; rm -f -- ./main ; :'
|
||||
alias ft2='cc -Wall -Wextra -Werror -o main -xc -- <(grep -v "////" *.c) && ./main'
|
||||
alias git='EDITOR=vim git'
|
||||
alias cmatrix='cmatrix -cu3 -Cred'
|
||||
alias gca='git add -u && git commit -m *'
|
||||
alias watch='watch -cn.1'
|
||||
alias push='git push origin master; git push gitea master'
|
||||
alias norm='alacritty -e sh -c '\''git rev-parse --show-toplevel || { echo "Exiting in 5"; sleep 1; echo "Exiting in 4"; sleep 1; echo "Exiting in 3"; sleep 1; echo "Exiting in 2"; sleep 1; echo "Exiting in 1"; sleep 1; } && cd "$(git rev-parse --show-toplevel)" && watch -cn.5 date \&\& norminette -R CheckForbiddenSourceHeader'\'' & disown'
|
||||
alias push='git push origin master ; git push gitea master'
|
||||
alias norm='alacritty -e sh -c '\''git rev-parse --show-toplevel || { echo "Exiting in 5" ; sleep 1 ; echo "Exiting in 4" ; sleep 1 ; echo "Exiting in 3" ; sleep 1 ; echo "Exiting in 2" ; sleep 1 ; echo "Exiting in 1" ; sleep 1 ; } && cd "$(git rev-parse --show-toplevel)" && watch -cn.5 date \&\& norminette -R CheckForbiddenSourceHeader'\'' & disown'
|
||||
jmp () {
|
||||
cd "$(find . -name "${1}" -not -wholename "*mouli*" -print -quit)"
|
||||
if [ "${?}" = "0" ]; then
|
||||
if [ "${?}" = "0" ] ; then
|
||||
cd "$(find .. -name "${1}" -not -wholename "*mouli*" -print -quit)"
|
||||
fi
|
||||
}
|
||||
|
@ -22,45 +22,45 @@ xset r rate 200 60
|
|||
|
||||
PATH="${PATH}:/nfs/homes/tischmid/.local/bin"
|
||||
|
||||
if [ -f ~/git-prompt.sh ]; then
|
||||
. ~/git-prompt.sh
|
||||
else
|
||||
source <(curl --silent --location 'https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh')
|
||||
fi
|
||||
|
||||
export GIT_PS1_SHOWDIRTYSTATE=1
|
||||
PS1='\[\033[31m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[m\] \[\033[33m\][\w]\[\033[m\]\[\033[36m\]$(__git_ps1 " (%s)")\[\033[m\]\n$ '
|
||||
# if [ ! -f ~/git-prompt.sh ] ; then
|
||||
# curl --silent --location 'https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh' -o "~/git-prompt.sh"
|
||||
# fi
|
||||
#
|
||||
# . ~/git-prompt.sh
|
||||
# export GIT_PS1_SHOWDIRTYSTATE=1
|
||||
# PS1='\[\033[31m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[m\] \[\033[33m\][\w]\[\033[m\]\[\033[36m\]$(__git_ps1 " (%s)")\[\033[m\]\n$ '
|
||||
PS1='\[\033[31m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[m\] \[\033[33m\][\w]\[\033[m\]\[\033[36m\]\[\033[m\]\n$ '
|
||||
|
||||
##-----------------------------------------------------
|
||||
## synth-shell-greeter.sh
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/synth-shell-greeter.sh ] && [ -n "$( echo $- | grep i )" ]; then
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/synth-shell-greeter.sh ] && [ -n "$( echo $- | grep i )" ] ; then
|
||||
:
|
||||
# source /nfs/homes/tischmid/.config/synth-shell/synth-shell-greeter.sh
|
||||
fi
|
||||
|
||||
##-----------------------------------------------------
|
||||
## synth-shell-prompt.sh
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/synth-shell-prompt.sh ] && [ -n "$( echo $- | grep i )" ]; then
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/synth-shell-prompt.sh ] && [ -n "$( echo $- | grep i )" ] ; then
|
||||
:
|
||||
# source /nfs/homes/tischmid/.config/synth-shell/synth-shell-prompt.sh
|
||||
fi
|
||||
|
||||
##-----------------------------------------------------
|
||||
## better-ls
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/better-ls.sh ] && [ -n "$( echo $- | grep i )" ]; then
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/better-ls.sh ] && [ -n "$( echo $- | grep i )" ] ; then
|
||||
:
|
||||
# source /nfs/homes/tischmid/.config/synth-shell/better-ls.sh
|
||||
fi
|
||||
|
||||
##-----------------------------------------------------
|
||||
## alias
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/alias.sh ] && [ -n "$( echo $- | grep i )" ]; then
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/alias.sh ] && [ -n "$( echo $- | grep i )" ] ; then
|
||||
source /nfs/homes/tischmid/.config/synth-shell/alias.sh
|
||||
fi
|
||||
|
||||
##-----------------------------------------------------
|
||||
## better-history
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/better-history.sh ] && [ -n "$( echo $- | grep i )" ]; then
|
||||
if [ -f /nfs/homes/tischmid/.config/synth-shell/better-history.sh ] && [ -n "$( echo $- | grep i )" ] ; then
|
||||
source /nfs/homes/tischmid/.config/synth-shell/better-history.sh
|
||||
fi
|
||||
|
||||
|
@ -70,7 +70,7 @@ check () {
|
|||
DIR="/tmp/tmp_repo_$(date +%s)"
|
||||
|
||||
# If no URL, get it from current repo
|
||||
if [ -z "${URL}" ]; then
|
||||
if [ -z "${URL}" ] ; then
|
||||
URL="$(git remote get-url origin)"
|
||||
fi
|
||||
|
||||
|
@ -78,43 +78,44 @@ check () {
|
|||
git clone --quiet "${URL}" "${DIR}"
|
||||
|
||||
# Only proceed if clone success
|
||||
if [ -d "${DIR}" ]; then
|
||||
if [ -d "${DIR}" ] ; then
|
||||
# Check the norm and print beautiful message
|
||||
norminette "${DIR}" && printf '\033[30;102m%s\033[m\n' "Norminette success" || printf '\033[30;101m%s\033[m\n' "Norminette fail!!!"
|
||||
norminette "${DIR}" && printf '\033[30 ;102m%s\033[m\n' "Norminette success" || printf '\033[30 ;101m%s\033[m\n' "Norminette fail!!!"
|
||||
|
||||
# Remove temp folder
|
||||
rm -rf "${DIR}"
|
||||
else
|
||||
printf '\033[30;101m%s\033[m\n' "Could not clone the repo"
|
||||
printf '\033[30 ;101m%s\033[m\n' "Could not clone the repo"
|
||||
fi
|
||||
}
|
||||
|
||||
safe_guard_name () {
|
||||
printf '%s' "${1}" | tr \\'!@#$%^&*()_+~{}|:">[]?<, ./;=\t\-'\'\` '__________________________________'
|
||||
printf '%s' "${1}" | tr \\'!@#$%^&*()_+~{}|:">[]?<, ./ ;=\t\-'\'\` '__________________________________'
|
||||
}
|
||||
|
||||
timo_moulinette () {
|
||||
# Set params
|
||||
subject="${1}"
|
||||
ex="${2}"
|
||||
extras="${3}"
|
||||
|
||||
# Arghandle
|
||||
if [ -z "${subject}" ]; then
|
||||
if [ -z "${subject}" ] ; then
|
||||
printf '%s\n' "Must provide at least one argument. Exiting"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If exercise was not provided, get it from current folder name
|
||||
if [ -z "${ex}" ]; then
|
||||
if [ -z "${ex}" ] ; then
|
||||
ex="$(basename -- "${PWD}")"
|
||||
fi
|
||||
|
||||
# Search for a compiler
|
||||
if command -v cc >/dev/null 2>&1; then
|
||||
if command -v cc >/dev/null 2>&1 ; then
|
||||
CC="$(command -v cc)"
|
||||
elif command -v gcc >/dev/null 2>&1; then
|
||||
elif command -v gcc >/dev/null 2>&1 ; then
|
||||
CC="$(command -v gcc)"
|
||||
elif command -v clang >/dev/null 2>&1; then
|
||||
elif command -v clang >/dev/null 2>&1 ; then
|
||||
CC="$(command -v clang)"
|
||||
else
|
||||
printf '%s\n' "Could not find a compiler. Exiting"
|
||||
|
@ -127,7 +128,7 @@ timo_moulinette () {
|
|||
file_name="$(find . -mindepth 1 -maxdepth 1 -name '*.c' -not -name '*mouli*' -type f -exec basename {} \; -quit)"
|
||||
|
||||
# If no C files found, exit
|
||||
if [ -z "${file_name}" ]; then
|
||||
if [ -z "${file_name}" ] ; then
|
||||
printf '%s\n' "Could not find any C files in the current directory. Exiting"
|
||||
return 2
|
||||
fi
|
||||
|
@ -148,7 +149,7 @@ timo_moulinette () {
|
|||
${CC} -dD -E -o "${file_name}.nocomments" -- "${file_name}"
|
||||
|
||||
# Extract function definitions from preprocessed file and append semicolon
|
||||
prototypes="$(cat -- "${file_name}.nocomments" | grep -v '#' | grep ')$' | grep -v ' (' | grep -v ' ' | grep '[a-zA-Z0-9](' | grep -v 'int[[:space:]]\+main(' | sed 's/$/;/')"
|
||||
prototypes="$(cat -- "${file_name}.nocomments" | grep -v '#' | grep ')$' | grep -v ' (' | grep -v ' ' | grep '[a-zA-Z0-9](' | grep -v 'int[[:space:]]\+main(' | sed 's/$/ ;/')"
|
||||
|
||||
# Extract macros from file (ignore the ones with line continuations)
|
||||
macros="$(cat -- "${file_name}" | grep '^#' | grep -v '\\$')"
|
||||
|
@ -159,7 +160,7 @@ timo_moulinette () {
|
|||
# Write prototypes to beginning of testfile
|
||||
IFS="
|
||||
"
|
||||
for proto in ${prototypes}; do
|
||||
for proto in ${prototypes} ; do
|
||||
printf '%s\n' "${proto}" | cat -- - "${download_file_name}" > ".tmpaddfirstlinefile.c"
|
||||
mv -- ".tmpaddfirstlinefile.c" "${download_file_name}"
|
||||
done
|
||||
|
@ -167,7 +168,7 @@ timo_moulinette () {
|
|||
# Write macros to beginning of testfile
|
||||
IFS="
|
||||
"
|
||||
for macro in ${macros}; do
|
||||
for macro in ${macros} ; do
|
||||
guard_name="$(safe_guard_name "${macro}")"
|
||||
|
||||
# Endif include guard
|
||||
|
@ -193,21 +194,25 @@ timo_moulinette () {
|
|||
${CC} -Wall -Wextra -Werror -o "${out_binary}" -xc -- *.c
|
||||
err_code="${?}"
|
||||
|
||||
if [ ! "${err_code}" = 0 ]; then
|
||||
if [ ! "${err_code}" = 0 ] ; then
|
||||
printf '%s\n' "Could not compile. Exiting"
|
||||
return
|
||||
fi
|
||||
|
||||
# Delete testfile
|
||||
if [ "$(printf '%s' "${extras}" | sed 's/keep-test//g')" = "${extras}" ] ; then
|
||||
rm -f -- "${download_file_name}"
|
||||
fi
|
||||
|
||||
# Run binary
|
||||
./${out_binary}
|
||||
# rm -f -- "./${out_binary}"
|
||||
if [ "${?}" = "0" ] && [ "$(printf '%s' "${extras}" | sed 's/keep-binary//g')" = "${extras}" ] ; then
|
||||
rm -f -- "./${out_binary}"
|
||||
fi
|
||||
}
|
||||
|
||||
prev () {
|
||||
if [ -z "${1}" ]; then
|
||||
if [ -z "${1}" ] ; then
|
||||
ex="$(basename "${PWD}")"
|
||||
ex_num="$(printf '%s' "${ex}" | cut -c3-)"
|
||||
next_ex_num="$(( ${ex_num} - 1 ))"
|
||||
|
@ -221,7 +226,7 @@ prev () {
|
|||
|
||||
next () {
|
||||
# If no arg, calculate next num
|
||||
if [ -z "${1}" ]; then
|
||||
if [ -z "${1}" ] ; then
|
||||
# Exercise name
|
||||
ex="$(basename "${PWD}")"
|
||||
|
||||
|
|
Loading…
Reference in New Issue