dotfiles/.bashrc

130 lines
4.2 KiB
Bash

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 ./main 2>/dev/null; :'
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 * && 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 l='ls -larthF --color=auto'
jmp () {
cd "$(find . -name "${1}" -print -quit)"
if [ "${?}" = "0" ]; then
cd "$(find .. -name "${1}" -print -quit)"
fi
}
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$ '
##-----------------------------------------------------
## synth-shell-greeter.sh
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
:
# 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
:
# 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
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
source /nfs/homes/tischmid/.config/synth-shell/better-history.sh
fi
check () {
URL="${1}"
DIR="/tmp/tmp_repo_$(date +%s)"
if [ -z "${URL}" ]; then
URL="$(git remote get-url origin)"
fi
git clone --quiet "${URL}" "${DIR}"
if [ -d "${DIR}" ]; then
norminette "${DIR}" && printf '\033[30;102m%s\033[m\n' "Norminette success" || printf '\033[30;101m%s\033[m\n' "Norminette fail!!!"
rm -rf "${DIR}"
else
printf '\033[30;101m%s\033[m\n' "Could not clone the repo"
fi
}
timo_moulinette () {
subject="${1}"
ex="${2}"
if [ -z "${subject}" ]; then
echo "Must provide at least one argument. Exiting"
return 1
fi
if [ -z "${ex}" ]; then
ex="$(basename "${PWD}")"
fi
git_base="https://git.timo.one/42berlin/piscine-timo-moulinette/raw/branch/master"
test_file_name="$(find . -mindepth 1 -maxdepth 1 -name '*.c' -type f -exec basename {} \; | sed 's/\.c$/_test.c/g')"
if [ -z "${test_file_name}" ]; then
echo "Could not find any C files in the current directory. Exiting"
return 2
fi
git_full="${git_base}/${subject}/${ex}/${test_file_name}"
echo "${git_full}"
}
prev () {
ex="$(basename "${PWD}")"
ex_num="$(echo "${ex}" | cut -c3-)"
if [ -z "${1}" ]; then
next_ex_num="$(( ${ex_num} - 1 ))"
else
next_ex_num="${1}"
fi
builtin printf -v padded '%02d' "${next_ex_num}"
next_dir="ex${padded}"
builtin cd "../${next_dir}"
}
next () {
ex="$(basename "${PWD}")"
ex_num="$(echo "${ex}" | cut -c3-)"
if [ -z "${1}" ]; then
next_ex_num="$(( ${ex_num} + 1 ))"
else
next_ex_num="${1}"
fi
builtin printf -v padded '%02d' "${next_ex_num}"
next_dir="ex${padded}"
builtin cd "../${next_dir}"
}