Add a common env for platform/platform os export

This commit is contained in:
Michael Campagnaro 2020-07-30 11:56:04 -04:00
parent fbd5048dca
commit 12018878a4
13 changed files with 38 additions and 16 deletions

15
aliases
View File

@ -3,8 +3,6 @@
# to remove those with: `sed -i 's/\r//' <file>` or with `dos2unix`.
#
platform=`uname`
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
@ -28,6 +26,8 @@ else
NORMAL=""
fi
platform=`uname`
####################################################################################################
# Helper Functions
####################################################################################################
@ -49,9 +49,16 @@ reload() {
fi
}
update-shell() {
if [[ '${platform,,}' == *'ming'* ]]; then
pacman -Syu
printf "\n${BOLD}${YELLOW}Close this shell, open a new one, and then run 'pacman -Su'${NORMAL}\n"
fi
}
# See top 10 bash commands
hist() {
if [[ "${platform,,}" == *'ming'* ]]; then
if [[ '${platform,,}' == *'ming'* ]]; then
hist_file=~/.bash_history
else
hist_file=~/.history
@ -552,7 +559,7 @@ alias tw-4k-shortname-compressed='dl_twitch_vid "2160p" 1 25'
# Git
####################################################################################################
if [[ $platform != 'Darwin' && $platform != 'Linux' ]]; then
if [[ '${platform,,}' == *'ming'* ]]; then
# Fix a weird mingw 'not a valid identifierline' error.
# Got the fix from https://github.com/Alexpux/MSYS2-packages/issues/735#issuecomment-328938800
alias git="PATH=/usr/bin git"

View File

@ -3,13 +3,13 @@
# Unbreak broken, non-colored terminal
export TERM=xterm-256color
# For Windows setup
test -f ~/.aliases && . ~/.aliases
test -f ~/.aliases.private && . ~/.aliases.private
# Common env must come first.
test -f ~/.common_env && . ~/.common_env
test -f ~/.private-dotfiles.common/env && . ~/.private-dotfiles.common/env
test -f ~/.private-dotfiles/env && . ~/.private-dotfiles/env
test -f ~/.aliases && . ~/.aliases
test -f ~/.aliases.private && . ~/.aliases.private
if [[ -d "$HOME/bin" ]]; then
export PATH=$HOME/bin/:$PATH
fi

15
common_env Normal file
View File

@ -0,0 +1,15 @@
# Common env for all shells.
uname_s="$(uname -s)"
case "${uname_s}" in
Linux*) platform="LINUX" platform_os="LINUX";;
Darwin*) platform="MACOS" platform_os="MACOS";;
CYGWIN*) platform="CYGWIN" platform_os="WINDOWS";;
MINGW*) platform="MINGW" platform_os="WINDOWS";;
MSYS*) platform="MINGW" platform_os="WINDOWS";;
*) platform="UNKNOWN:${uname_s} platform_os="UNKNOWN_OS""
esac
export PLATFORM=$platform
export PLATFORM_OS=$platform_os

View File

@ -1,8 +1,6 @@
#!/usr/bin/env bash
platform=`uname`
if [[ $platform == 'Darwin' ]]; then
if [[ $(uname) == 'Darwin' ]]; then
if ! command -v brew &>/dev/null
then
# We need to update bash, so we'll start with setting up homebrew.
@ -55,7 +53,7 @@ setup_zsh() {
fi
fi
setup_dir .dotfiles/zsh .zsh
setup_dir .dotfiles/zsh/core .zsh
FILES=()
FILES+=('zshrc')
@ -64,7 +62,7 @@ setup_zsh() {
for file in "${FILES[@]}"
do
setup_file .dotfiles/$file .$file
setup_file .dotfiles/zsh/$file .$file
done
}
@ -84,6 +82,7 @@ setup_dir .dotfiles/vim .vim
# Setup root files
#########################
FILES=()
FILES+=('common_env')
FILES+=('aliases')
FILES+=('gitconfig')
FILES+=('vimrc')

View File

0
zsh/func/zgitinit → zsh/core/func/zgitinit Executable file → Normal file
View File

View File

View File

View File

@ -90,12 +90,13 @@ bindkey -e
source $ZSH/lib/*.zsh
# Source my custom files after oh-my-zsh so I can override things.
test -f $HOME/.aliases && . $HOME/.aliases
test -f $HOME/.aliases.private && . $HOME/.aliases.private
# Common env must come first.
test -f $HOME/.common_env && . $HOME/.common_env
test -f $HOME/.private-dotfiles.common/env && . $HOME/.private-dotfiles.common/env
test -f $HOME/.private-dotfiles/env && . $HOME/.private-dotfiles/env
test -f $HOME/.aliases && . $HOME/.aliases
test -f $HOME/.aliases.private && . $HOME/.aliases.private
if [[ -d "$HOME/bin" ]]; then
export PATH=$HOME/bin/:$PATH
fi