diff options
Diffstat (limited to '')
-rw-r--r-- | %HOME%/.bash_utils/alternatives.sh | 46 | ||||
-rw-r--r-- | %HOME%/.bash_utils/os.sh | 2 | ||||
-rw-r--r-- | %HOME%/.bashrc | 13 |
3 files changed, 55 insertions, 6 deletions
diff --git a/%HOME%/.bash_utils/alternatives.sh b/%HOME%/.bash_utils/alternatives.sh new file mode 100644 index 0000000..4a0565c --- /dev/null +++ b/%HOME%/.bash_utils/alternatives.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Copyright (c) 2018 Egor Tensin <Egor.Tensin@gmail.com> +# This file is part of the "Linux/Cygwin environment" project. +# For details, see https://github.com/egor-tensin/linux-home. +# Distributed under the MIT License. + +alias update-my-alternatives='update-alternatives --quiet --altdir ~/.local/etc/alternatives --admindir ~/.local/var/lib/alternatives' + +setup_alternatives_cc() ( + set -o errexit -o nounset -o pipefail + + gcc_cc="$( command -v gcc 2> /dev/null )" || return 0 + gcc_cxx="$( command -v g++ 2> /dev/null )" || return 0 + clang_cc="$( command -v clang 2> /dev/null )" || return 0 + clang_cxx="$( command -v clang++ 2> /dev/null )" || return 0 + + mkdir -p -- ~/.local/bin + + update-my-alternatives --remove-all cc || true + update-my-alternatives --install ~/.local/bin/cc cc "$clang_cc" 512 --slave ~/.local/bin/c++ c++ "$clang_cxx" + update-my-alternatives --install ~/.local/bin/cc cc "$gcc_cc" 256 --slave ~/.local/bin/c++ c++ "$gcc_cxx" +) + +setup_alternatives() ( + set -o errexit -o nounset -o pipefail + + command -v update-alternatives > /dev/null 2>&1 || return 0 + mkdir -p -- ~/.local/etc/alternatives ~/.local/var/lib/alternatives + + setup_alternatives_cc +) + +setup_alternatives + +alt_gcc() ( + set -o errexit -o nounset -o pipefail + gcc_cc="$( command -v gcc 2> /dev/null )" + update-my-alternatives --set cc "$gcc_cc" +) + +alt_clang() ( + set -o errexit -o nounset -o pipefail + clang_cc="$( command -v clang 2> /dev/null )" + update-my-alternatives --set cc "$clang_cc" +) diff --git a/%HOME%/.bash_utils/os.sh b/%HOME%/.bash_utils/os.sh index b063cbc..f5af0f6 100644 --- a/%HOME%/.bash_utils/os.sh +++ b/%HOME%/.bash_utils/os.sh @@ -43,6 +43,8 @@ os_is_mint() { test "$_os" == "$_MINT" ; } os_is_arch() { test "$_os" == "$_ARCH" -o "$_os" == "$_ARCH_ARM" ; } os_is_fedora() { test "$_os" == "$_FEDORA" ; } +os_is_debian_based() { os_is_ubuntu || os_is_mint ; } + # Cygwin pkg_list_cygwin() ( diff --git a/%HOME%/.bashrc b/%HOME%/.bashrc index 95df1e6..3ff6820 100644 --- a/%HOME%/.bashrc +++ b/%HOME%/.bashrc @@ -63,12 +63,13 @@ alias ssh-copy-id='ssh-copy-id -i' [ -r "$HOME/.bash_utils/file.sh" ] && source "$HOME/.bash_utils/file.sh" [ -r "$HOME/.bash_utils/text.sh" ] && source "$HOME/.bash_utils/text.sh" -[ -r "$HOME/.bash_utils/cxx.sh" ] && source "$HOME/.bash_utils/cxx.sh" -[ -r "$HOME/.bash_utils/distr.sh" ] && source "$HOME/.bash_utils/distr.sh" -[ -r "$HOME/.bash_utils/git.sh" ] && source "$HOME/.bash_utils/git.sh" -[ -r "$HOME/.bash_utils/mysql.sh" ] && source "$HOME/.bash_utils/mysql.sh" -[ -r "$HOME/.bash_utils/os.sh" ] && source "$HOME/.bash_utils/os.sh" -[ -r "$HOME/.bash_utils/path.sh" ] && source "$HOME/.bash_utils/path.sh" +[ -r "$HOME/.bash_utils/alternatives.sh" ] && source "$HOME/.bash_utils/alternatives.sh" +[ -r "$HOME/.bash_utils/cxx.sh" ] && source "$HOME/.bash_utils/cxx.sh" +[ -r "$HOME/.bash_utils/distr.sh" ] && source "$HOME/.bash_utils/distr.sh" +[ -r "$HOME/.bash_utils/git.sh" ] && source "$HOME/.bash_utils/git.sh" +[ -r "$HOME/.bash_utils/mysql.sh" ] && source "$HOME/.bash_utils/mysql.sh" +[ -r "$HOME/.bash_utils/os.sh" ] && source "$HOME/.bash_utils/os.sh" +[ -r "$HOME/.bash_utils/path.sh" ] && source "$HOME/.bash_utils/path.sh" [ -r "$HOME/.bashrc_work" ] && source "$HOME/.bashrc_work" |