Improve Makefile & shell configs

* Add cross platform support in Makefile

 * Add host-specific configurations support.
This commit is contained in:
2023-04-07 18:10:19 +02:00
parent ecff222168
commit 2f04eb5a3c
6 changed files with 112 additions and 31 deletions

View File

@@ -16,7 +16,37 @@ TS := $(shell date -Iseconds)
OMYZSH_URL := https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh OMYZSH_URL := https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh
VUNDLE_URL := https://github.com/gmarik/vundle.git VUNDLE_URL := https://github.com/gmarik/vundle.git
.PHONY: help
# Some things have to be done in varying ways depending on the OS
ARCH := $(shell uname -s)
# For GNU/Linux
ifeq (${ARCH},Linux)
ARCH_DEFINED := ok
HOSTNAME := (shell hostname)
endif
# For MacOS X
ifeq (${ARCH},Darwin)
ARCH_DEFINED := ok
HOSTNAME := $(shell hostname -s)
endif
# For Windows
ifeq ($(word 2,$(subst -, ,$(subst _, ,${ARCH}))),NT)
ARCH_DEFINED := ok
HOSTNAME := (shell hostname)
endif
ifneq (${ARCH_DEFINED},ok)
$(info )
$(info :: ERROR: Please add the necessary support or use one of:)
$(info :: Linux, Mac OS X (Darwin), Windows.)
$(info )
$(error Unsupported architecture: $(ARCH))
else
.PHONY:
help: help:
${ECHO} "help:\tShow this help" ${ECHO} "help:\tShow this help"
${ECHO} "all:\tSetup all the dot files in one go" ${ECHO} "all:\tSetup all the dot files in one go"
@@ -31,54 +61,59 @@ help:
${ECHO} "i3:\tInstall i3wm configuration files" ${ECHO} "i3:\tInstall i3wm configuration files"
${ECHO} ${ECHO}
.PHONY: all .PHONY:
all: bash zsh git vim x11 i3 all: bash zsh git vim x11 i3
.PHONY: git config/git .PHONY:
git: config/git git: .config/git
config/git: config/dir .config/git: .config/dir
.PHONY: bash profile bashrc bash_aliases bash_logout .PHONY:
bash: profile bashrc bash_aliases bash_logout sh: .profile
.PHONY: zsh oh-my-zsh/themes/lsambuc.zsh-theme .PHONY:
zsh: profile zprofile zshrc oh-my-zsh/themes/lsambuc.zsh-theme bash: .profile .bashrc .bash_aliases .bash_logout
oh-my-zsh/themes/lsambuc.zsh-theme: oh-my-zsh/themes/dir
.PHONY: omz .PHONY:
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:
${MV} "$@" "$@-${TS}" ${MV} "$@" "$@-${TS}"
${Q} ${CURL} "${OMYZSH_URL}" | sh ${Q} ${CURL} "${OMYZSH_URL}" | sh
.PHONY: vim vim/bundle/dir vimrc vim/filetype.vim vim/syntax .PHONY:
vim: ~/.vim/bundle/vundle vim: ~/.vim/bundle/vundle
${ECHO} ${ECHO}
vim +BundleInstall +qall vim +BundleInstall +qall
${ECHO} ${ECHO}
${ECHO} Do not forget to install and set a Nerdfont enhanced font. ${ECHO} Do not forget to install and set a Nerdfont enhanced font.
~/.vim/bundle/vundle: vim/bundle/dir vimrc vim/filetype.vim vim/syntax ~/.vim/bundle/vundle: .vim/bundle/dir .vimrc .vim/filetype.vim .vim/syntax
${MV} "$@" "$@-${TS}" ${MV} "$@" "$@-${TS}"
git clone "${VUNDLE_URL}" "$@" git clone "${VUNDLE_URL}" "$@"
vim/filetype.vim vim/syntax: vim/dir .vim/filetype.vim .vim/syntax: .vim/dir
.PHONY: tmux config/tmux config/dir .PHONY:
tmux: config/tmux tmux: .config/tmux
config/tmux: config/dir .config/tmux: .config/dir
.PHONY: i3 config/i3 config/i3status.conf .PHONY:
i3: config/i3 config/i3status.conf i3: .config/i3 .config/i3status.conf
config/i3 config/i3status.conf: config/dir .config/i3 .config/i3status.conf: .config/dir
.PHONY: x11 Xdefaults xinitrc xsession .PHONY:
x11: Xdefaults xinitrc xsession x11: .Xdefaults .xinitrc .xsession
%/dir: %/dir:
${MKDIR} "~/.$(shell dirname $@)" ${MKDIR} "~/$(shell dirname $@)"
%: .%:
@# Prevent generating link within links to folders @# Prevent generating link within links to folders
${MV} "~/.$@" "~/.$@-${TS}" @[ -e ~/.$* ] && mv ~/.$* ~/.$*-${TS} || true
${LN} "$(shell pwd)/_$@" "~/.$@" ${LN} $(shell pwd)/_$* ~/.$*
@[ -e ${HOSTNAME}.$* ] && ( [ -e ~/.host.$* ] && mv ~/.host.$* ~/.host.$*-${TS}; ln -s $(shell pwd)/${HOSTNAME}.$* ~/.host.$* ) || true
endif

View File

@@ -2,11 +2,27 @@
This repository contains my personal profile configuration. This repository contains my personal profile configuration.
## VIM ## Notes
### VIM
The configuration relies on Vundle and expects a Nerd Font. The configuration relies on Vundle and expects a Nerd Font.
### ZSH
The configuration relies on [Ho My Zsh](https://ohmyz.sh).
The target to install it is **not** automatically triggered at this time, even with `make all`.
### Host-specific config
You can add host specific configuration by adding named it the following way:
```sh ```sh
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle ${hostname}.profile # Used by both zsh & bash
vim +BundleInstall +qall ${hostname}.zshrc
${hostname}.bashrc
${hostname}.aliases # Used by both zsh & bash
``` ```
If such files exist when you install the configuration files, symlink will be added and they will be automatically picked up by the configuration.

11
_bashrc
View File

@@ -80,11 +80,21 @@ if [ -x /bin/dircolors ]; then
alias ls='ls --color=auto' alias ls='ls --color=auto'
fi fi
# Host-specific definitions
if [ -f "${HOME}/.host.bashrc" ]; then
. "${HOME}/.host.bashrc"
fi
# Alias definitions # Alias definitions
if [ -f "${HOME}/.bash_aliases" ]; then if [ -f "${HOME}/.bash_aliases" ]; then
. "${HOME}/.bash_aliases" . "${HOME}/.bash_aliases"
fi fi
# Host-specific alias definitions
if [ -f "${HOME}/.host.aliases" ]; then
. "${HOME}/.host.aliases"
fi
#colorize stderr #colorize stderr
function swapandcolorize() function swapandcolorize()
{ {
@@ -115,3 +125,4 @@ function swapandcolorize()
return ${PIPESTATUS[0]} return ${PIPESTATUS[0]}
} }
export -f swapandcolorize export -f swapandcolorize

View File

@@ -8,6 +8,11 @@
# for ssh logins, install and configure the libpam-umask package. # for ssh logins, install and configure the libpam-umask package.
#umask 022 #umask 022
# Host-specific alias definitions
if [ -f "${HOME}/.host.profile" ]; then
. "${HOME}/.host.profile"
fi
# When running bash # When running bash
if [ -n "${BASH_VERSION}" ]; then if [ -n "${BASH_VERSION}" ]; then
# include .bashrc if it exists # include .bashrc if it exists
@@ -27,7 +32,7 @@ if [ -e "${HOME}/bin" ]; then
fi fi
# Add cargo # Add cargo
if [ -e "${HOME}/.cargo/bin" ]; then if [ -f "${HOME}/.cargo/env" ]; then
PATH="${HOME}/.cargo/bin:${PATH}" . "$HOME/.cargo/env"
fi fi

10
_zshrc
View File

@@ -109,7 +109,17 @@ unsetopt correct_all
export VISUAL=vi export VISUAL=vi
export EDITOR=vi export EDITOR=vi
# Host-specific definitions
if [ -f "${HOME}/.host.zshrc" ]; then
. "${HOME}/.host.zshrc"
fi
# Alias definitions # Alias definitions
if [ -f "${HOME}/.bash_aliases" ]; then if [ -f "${HOME}/.bash_aliases" ]; then
. "${HOME}/.bash_aliases" . "${HOME}/.bash_aliases"
fi fi
# Host-specific alias definitions
if [ -f "${HOME}/.host.aliases" ]; then
. "${HOME}/.host.aliases"
fi

4
omoikane.profile Normal file
View File

@@ -0,0 +1,4 @@
# Add brew
if [ -x "/opt/homebrew/bin/brew" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi