From 3cf804b159a21b1d7b3000db60b678320c6e5fd0 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Thu, 6 Apr 2023 06:45:09 +0200 Subject: [PATCH] Cleanup Makefile and shell configs --- Makefile | 37 +++++++++++++++++++++++-------------- _bashrc | 48 ++++++++++++++++++++++++------------------------ _profile | 17 ++++++++--------- _zshrc | 6 +++--- 4 files changed, 58 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index e7be797..c7989c1 100644 --- a/Makefile +++ b/Makefile @@ -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)/_$@" "~/.$@" diff --git a/_bashrc b/_bashrc index e44fb78..47740f8 100644 --- a/_bashrc +++ b/_bashrc @@ -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 diff --git a/_profile b/_profile index 6669aa6..9d97ee0 100644 --- a/_profile +++ b/_profile @@ -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 diff --git a/_zshrc b/_zshrc index 25900c1..d8f760e 100644 --- a/_zshrc +++ b/_zshrc @@ -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