Cleanup Makefile and shell configs

This commit is contained in:
2023-04-06 06:45:09 +02:00
parent 4f2a71c217
commit 3cf804b159
4 changed files with 58 additions and 50 deletions

View File

@@ -1,10 +1,19 @@
Q := @
ECHO := @echo
LN := ln -sf
MKDIR := ${Q}mkdir -p
MV := ${Q}mv
# Override on the command line, for example
# make Q=""
# would print on the console all the commands being run, instead of just their outputs
Q := @
OMYZSH_GET := curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh
# The role of echo is to print, so never print the command itsef
ECHO := @echo
LN := ${Q}ln -sf
MKDIR := ${Q}mkdir -p
MV := ${Q}mv
# Make sure that all files moved during this invokation of make get the same
# timestamp.
TS := $(shell date -Iseconds)
OMYZSH_URL := https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh
VUNDLE_URL := https://github.com/gmarik/vundle.git
.PHONY: help
@@ -36,10 +45,10 @@ bash: profile bashrc bash_aliases bash_logout
zsh: profile zprofile zshrc oh-my-zsh/themes/lsambuc.zsh-theme
oh-my-zsh/themes/lsambuc.zsh-theme: oh-my-zsh/themes/dir
.PHONY: omz omz-setup
.PHONY: omz
omz:
${MV} $@ $@-$(shell date -Iseconds)
$(Q) $(OMYZSH_GET) | sh
${MV} "$@" "$@-${TS}"
${Q} ${CURL} "${OMYZSH_URL}" | sh
.PHONY: vim vim/bundle/dir vimrc vim/filetype.vim vim/syntax
vim: ~/.vim/bundle/vundle
@@ -49,8 +58,8 @@ vim: ~/.vim/bundle/vundle
${ECHO} Do not forget to install and set a Nerdfont enhanced font.
~/.vim/bundle/vundle: vim/bundle/dir vimrc vim/filetype.vim vim/syntax
${MV} $@ $@-$(shell date -Iseconds)
git clone ${VUNDLE_URL} $@
${MV} "$@" "$@-${TS}"
git clone "${VUNDLE_URL}" "$@"
vim/filetype.vim vim/syntax: vim/dir
@@ -66,10 +75,10 @@ config/i3 config/i3status.conf: config/dir
x11: Xdefaults xinitrc xsession
%/dir:
${MKDIR} ~/.$(shell dirname $@)
${MKDIR} "~/.$(shell dirname $@)"
%:
@# Prevent generating link within links to folders
${MV} ~/.$@ ~/.$@-$(shell date -Iseconds)
${LN} $(shell pwd)/_$@ ~/.$@
${MV} "~/.$@" "~/.$@-${TS}"
${LN} "$(shell pwd)/_$@" "~/.$@"

48
_bashrc
View File

@@ -80,9 +80,9 @@ if [ -x /bin/dircolors ]; then
alias ls='ls --color=auto'
fi
# Alias definitions.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
# Alias definitions
if [ -f "${HOME}/.bash_aliases" ]; then
. "${HOME}/.bash_aliases"
fi
#colorize stderr
@@ -90,28 +90,28 @@ function swapandcolorize()
{
# "$@" 3>&2 2>&1 1>&3 | while read line
# do
# echo -e "\e[91m$line\e[0m"
# echo -e "\e[91m$line\e[0m"
# done
"$@" 3>&2 2>&1 1>&3 | perl -e 'while(<>)
{
chomp;
#Print in LYELLOW and blue background xenomai stuff warning and such
if (m/^xenomai.+:\d+:(\d+:)?\s+warning.*/)
{print "\033[1;45m".$_."\033[m\n"; next;}
"$@" 3>&2 2>&1 1>&3 | perl -e 'while(<>)
{
chomp;
#Print in LYELLOW and blue background xenomai stuff warning and such
if (m/^xenomai.+:\d+:(\d+:)?\s+warning.*/)
{print "\033[1;45m".$_."\033[m\n"; next;}
#Print in DARKBLUE forced warnings
if (m/.*\#warning.*/)
{print "\033[1;34m".$_."\033[m\n"; next;}
#Print in LYELLOW warning and such
if (m/.+:\d+:(\d+:)?\s+warning.*/)
{print "\033[1;33m".$_."\033[m\n"; next;}
#print in LRED errors
if (m/.+:\d+:(\d+:)?\s+error.*/ ||
m/.+:\d+:(\d+:)? undefined reference to `/)
{print "\033[1;31m".$_."\033[m\n"; next;}
#Print in default colors
{print "\033[m".$_."\n"; next;}
};'
return ${PIPESTATUS[0]}
#Print in DARKBLUE forced warnings
if (m/.*\#warning.*/)
{print "\033[1;34m".$_."\033[m\n"; next;}
#Print in LYELLOW warning and such
if (m/.+:\d+:(\d+:)?\s+warning.*/)
{print "\033[1;33m".$_."\033[m\n"; next;}
#print in LRED errors
if (m/.+:\d+:(\d+:)?\s+error.*/ ||
m/.+:\d+:(\d+:)? undefined reference to `/)
{print "\033[1;31m".$_."\033[m\n"; next;}
#Print in default colors
{print "\033[m".$_."\n"; next;}
};'
return ${PIPESTATUS[0]}
}
export -f swapandcolorize

View File

@@ -9,26 +9,25 @@
#umask 022
# When running bash
if [ -n "$BASH_VERSION" ]; then
if [ -n "${BASH_VERSION}" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
if [ -f "${HOME}/.bashrc" ]; then
. "${HOME}/.bashrc"
fi
fi
# Add brew
if [ -x /opt/homebrew/bin/brew ]; then
if [ -x "/opt/homebrew/bin/brew" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# Add ~/bin
if [ -e "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
if [ -e "${HOME}/bin" ]; then
PATH="${HOME}/bin:${PATH}"
fi
# Add cargo
if [ -e "$HOME/.cargo/bin" ]; then
PATH="$HOME/.cargo/bin:$PATH"
if [ -e "${HOME}/.cargo/bin" ]; then
PATH="${HOME}/.cargo/bin:${PATH}"
fi

6
_zshrc
View File

@@ -109,7 +109,7 @@ unsetopt correct_all
export VISUAL=vi
export EDITOR=vi
# Alias definitions.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
# Alias definitions
if [ -f "${HOME}/.bash_aliases" ]; then
. "${HOME}/.bash_aliases"
fi