#!/usr/bin/env bash # # ~/.bashrc.br.lorien - host specific initialization # # (C) Bruno Raoult ("br"), 2001-2023 # Licensed under the GNU General Public License v3.0 or later. # Some rights reserved. See COPYING. # # You should have received a copy of the GNU General Public License along with this # program. If not, see . # # SPDX-License-Identifier: GPL-3.0-or-later # # Usage: to be invoked from .bashrc.$USER # i.e., add at the end of .bashrc.$USER: # [ -f "$HOME/.bashrc.$USER.$(hostname)" ] && . "$HOME/.bashrc.$USER.$(hostname)" # look for a pdf viewer hash atril 2> /dev/null && alias acroread=atril # mysql aliases. Will match any "[client-XXX]" lines in ~/.my.cnf # and generate "myXXX" aliases. if [[ -r ~/.my.cnf ]]; then mapfile -t MYSQL_ARRAY < ~/.my.cnf for line in "${MYSQL_ARRAY[@]}"; do if [[ $line =~ ^\[client-(.+)\]$ ]]; then SUFFIX="${BASH_REMATCH[1]}" # shellcheck disable=SC2139,SC2140 alias my"$SUFFIX"="mysql --defaults-group-suffix=-$SUFFIX" fi done fi # shortcuts to commonly used directories/projects # _vardir() - define common dirs vars & aliases # $1: name variable to set # $2: name of alias to define # $3: script to source (relative to $2). '-' if no script. # $4: path # # _vardir will set a variable referencing $4, and an alias which will # change working directory to $1. # if $3 is not '-', it will be sourced. $3 path must be either absolute, # either relative to $4. # # Examples: # _vardir MYDIR mydir - ~/foo/mydirprj _vardir() { local _v="$1" _a="$2" _s="$3" _p="$4" local _x="cd $_p" export "$_v"="$_p" [[ $_s != "-" ]] && _x+="; . $_s" # shellcheck disable=SC2139 alias "$_a"="$_x" } _vardir AOC aoc ./env.sh ~/dev/advent-of-code # Advent of code _vardir WCHESS wchess - ~/dev/www/crd/chess # raoult.com chess _vardir CHESS chess ./env.sh ~/dev/brchess # brchess _vardir TOOLS tools - ~/dev/tools # tools _vardir BRLIB brlib - ~/dev/brlib # brlib _vardir EUD eud ./bin/ENV.sh ~/dev/eudyptula # eudyptula # Indent style for emacs # Local Variables: # mode: shell-script # sh-basic-offset: 4 # sh-indentation: 4 # indent-tabs-mode: nil # End: