aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.bashrc178
-rw-r--r--.bashrc_cxx81
-rw-r--r--.bashrc_distr15
-rw-r--r--.bashrc_git2
-rw-r--r--.bashrc_netwrix4
-rw-r--r--.bashrc_pgn38
-rw-r--r--.bashrc_text25
-rw-r--r--.bashrc_third_party2
8 files changed, 174 insertions, 171 deletions
diff --git a/.bashrc b/.bashrc
index ed8825a..60ccb4f 100644
--- a/.bashrc
+++ b/.bashrc
@@ -197,6 +197,8 @@ alias fgrep='fgrep --color=auto' # show differences in colour
#
# alias cd=cd_func
+PS1='\[\e[33m\]\W\[\e[0m\]: '
+
set -o pipefail
set -o nounset
shopt -s nullglob
@@ -204,180 +206,14 @@ shopt -s nullglob
alias less='less -R'
alias ls='ls -lAh --color=tty'
-PS1='\[\e[33m\]\W\[\e[0m\]: '
-
-# Cygwin stuff
-# ------------
-
alias list_packages='cygcheck -cd'
-# Common sed one-liners
-# ---------------------
-
-alias dos2eol='sed --binary --in-place '"'"'s/\(\r\?\)$//'"'"
-alias eol2dos='sed --binary --in-place '"'"'s/\r\?$/\r/'"'"
-
-alias trim='sed --binary --in-place '"'"'s/[[:blank:]]*\(\r\?\)$/\1/'"'"
-
-alias trimeol='sed --binary --in-place -e :a -e '"'"'/^\n*$/{$d;N;ba}'"'"
-alias trimdoseol='sed --binary --in-place -e :a -e '"'"'/^\(\r\n\)*\r$/{$d;N;ba}'"'"
-
-alias eol='sed --binary --in-place '"'"'$a\'"'"
-alias doseol='sed --binary --in-place '"'"'$s/\r\?$/\r/;a\'"'"
-
-alias trimbom='sed --binary --in-place '"'"'1 s/^\xef\xbb\xbf//'"'"
-
-lint() {
- trim "$@" && trimeol "$@" && eol "$@"
-}
-
-doslint() {
- trim "$@" && trimdoseol "$@" && doseol "$@"
-}
-
-# Factored-out stuff
-# ------------------
+PYTHONSTARTUP="$HOME/.pythonrc"
+[ -f '.bashrc_cxx' ] && source .bashrc_cxx
+[ -f '.bashrc_distr' ] && source .bashrc_distr
[ -f '.bashrc_git' ] && source .bashrc_git
[ -f '.bashrc_netwrix' ] && source .bashrc_netwrix
+[ -f '.bashrc_pgn' ] && source .bashrc_pgn
+[ -f '.bashrc_text' ] && source .bashrc_text
[ -f ".bashrc_third_party" ] && source .bashrc_third_party
-
-# "distr" paranoia
-# ----------------
-
-checksums_path='sha1sums.txt'
-
-update_checksums() {
- sha1sum "$@" > "$checksums_path"
-}
-
-update_checksums_distr() {
- update_checksums *.exe *.iso
-}
-
-verify_checksums() {
- sha1sum --check "$checksums_path"
-}
-
-# `runhaskell` alternatives for C/C++
-# -----------------------------------
-
-C_FLAGS=('-Wall' '-Wextra')
-
-runc() (
- set -o errexit
-
- local -a c_flags=("${C_FLAGS[@]}")
- local -a src_files=()
- local -a prog_flags=()
-
- while [ "$#" -gt 0 ]; do
- case "$1" in
- --c-flags)
- if [ "$#" -le 1 ]; then
- echo "$FUNCNAME: usage error: missing value for option: $1" >&2
- return 1
- fi
- shift ; c_flags+=("$1") ; shift ;;
-
- --)
- shift ; break ;;
-
- *)
- src_files+=("$( realpath "$1" )") ; shift ;;
- esac
- done
-
- prog_flags=("$@")
-
- local build_dir="$( mktemp --directory )"
- trap "$( printf 'popd > /dev/null && rm -rf %q' "$build_dir" )" 0
- pushd "$build_dir" > /dev/null
- local output_name="$( mktemp --tmpdir=. "${FUNCNAME}XXX.exe" )"
-
- gcc -o "$output_name" \
- "${c_flags[@]+"${c_flags[@]}"}" \
- "${src_files[@]+"${src_files[@]}"}"
-
- "$output_name" "${prog_flags[@]+"${prog_flags[@]}"}"
-)
-
-CXX_FLAGS=('-Wall' '-Wextra' '-std=c++14')
-
-runcxx() (
- set -o errexit
-
- local cxx_flags=("${CXX_FLAGS[@]}")
- local -a src_files=()
- local -a prog_flags=()
-
- while [ "$#" -gt 0 ]; do
- case "$1" in
- --cxx-flags)
- if [ "$#" -le 1 ]; then
- echo "$FUNCNAME: usage error: missing value for option: $1" >&2
- return 1
- fi
- shift ; cxx_flags+=("$1") ; shift ;;
-
- --)
- shift ; break ;;
-
- *)
- src_files+=("$( realpath "$1" )") ; shift ;;
- esac
- done
-
- prog_flags=("$@")
-
- local build_dir="$( mktemp --directory )"
- trap "$( printf 'popd > /dev/null && rm -rf %q' "$build_dir" )" 0
- pushd "$build_dir" > /dev/null
- local output_name="$( mktemp --tmpdir=. "${FUNCNAME}XXX.exe" )"
-
- g++ -o "$output_name" \
- "${cxx_flags[@]+"${cxx_flags[@]}"}" \
- "${src_files[@]+"${src_files[@]}"}"
-
- "$output_name" "${prog_flags[@]+"${prog_flags[@]}"}"
-)
-
-# Miscellaneous
-# -------------
-
-PYTHONSTARTUP="$HOME/.pythonrc"
-
-alias strip_pgn_clk='sed --binary --in-place '"'"'s/ {\[%clk [[:digit:]]\+:[[:digit:]]\+\(:[[:digit:]]\+\)*\]}//g'"'"
-alias slice_pgn_moves='sed --binary --in-place '"'"'s/ \([[:digit:]]\+\.\)/\n\1/g'"'"
-
-normalize_pgn() {
- dos2eol "$@" \
- && lint "$@" \
- && strip_pgn_clk "$@" \
- && slice_pgn_moves "$@" \
- && eol2dos "$@"
-}
-
-append_pgn() {
- if [ "$#" -ne 2 ]; then
- echo "$FUNCNAME: usage: $FUNCNAME DEST_PGN SRC_PGN" >&2
- return 1
- fi
-
- printf '\r\n' >> "$1" \
- && cat "$2" >> "$1"
-}
-
-join_pgns() (
- [ "$#" -eq 0 ] && return
-
- set -o errexit
-
- cat "$1"
-
- local i
- for i in "${@:2}"; do
- printf '\r\n'
- cat "$i"
- done
-)
diff --git a/.bashrc_cxx b/.bashrc_cxx
new file mode 100644
index 0000000..dc1eaf5
--- /dev/null
+++ b/.bashrc_cxx
@@ -0,0 +1,81 @@
+[ ! -z "${BASHRC_CXX+x}" ] && return || readonly BASHRC_CXX=1
+
+C_FLAGS=('-Wall' '-Wextra')
+
+runc() (
+ set -o errexit
+
+ local -a c_flags=("${C_FLAGS[@]}")
+ local -a src_files=()
+ local -a prog_flags=()
+
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --c-flags)
+ if [ "$#" -le 1 ]; then
+ echo "$FUNCNAME: usage error: missing value for option: $1" >&2
+ return 1
+ fi
+ shift ; c_flags+=("$1") ; shift ;;
+
+ --)
+ shift ; break ;;
+
+ *)
+ src_files+=("$( realpath "$1" )") ; shift ;;
+ esac
+ done
+
+ prog_flags=("$@")
+
+ local build_dir="$( mktemp --directory )"
+ trap "$( printf 'popd > /dev/null && rm -rf %q' "$build_dir" )" 0
+ pushd "$build_dir" > /dev/null
+ local output_name="$( mktemp --tmpdir=. "${FUNCNAME}XXX.exe" )"
+
+ gcc -o "$output_name" \
+ "${c_flags[@]+"${c_flags[@]}"}" \
+ "${src_files[@]+"${src_files[@]}"}"
+
+ "$output_name" "${prog_flags[@]+"${prog_flags[@]}"}"
+)
+
+CXX_FLAGS=('-Wall' '-Wextra' '-std=c++14')
+
+runcxx() (
+ set -o errexit
+
+ local cxx_flags=("${CXX_FLAGS[@]}")
+ local -a src_files=()
+ local -a prog_flags=()
+
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --cxx-flags)
+ if [ "$#" -le 1 ]; then
+ echo "$FUNCNAME: usage error: missing value for option: $1" >&2
+ return 1
+ fi
+ shift ; cxx_flags+=("$1") ; shift ;;
+
+ --)
+ shift ; break ;;
+
+ *)
+ src_files+=("$( realpath "$1" )") ; shift ;;
+ esac
+ done
+
+ prog_flags=("$@")
+
+ local build_dir="$( mktemp --directory )"
+ trap "$( printf 'popd > /dev/null && rm -rf %q' "$build_dir" )" 0
+ pushd "$build_dir" > /dev/null
+ local output_name="$( mktemp --tmpdir=. "${FUNCNAME}XXX.exe" )"
+
+ g++ -o "$output_name" \
+ "${cxx_flags[@]+"${cxx_flags[@]}"}" \
+ "${src_files[@]+"${src_files[@]}"}"
+
+ "$output_name" "${prog_flags[@]+"${prog_flags[@]}"}"
+)
diff --git a/.bashrc_distr b/.bashrc_distr
new file mode 100644
index 0000000..10df5b2
--- /dev/null
+++ b/.bashrc_distr
@@ -0,0 +1,15 @@
+[ ! -z "${BASHRC_DISTR+x}" ] && return || readonly BASHRC_DISTR=1
+
+checksums_path='sha1sums.txt'
+
+update_checksums() {
+ sha1sum "$@" > "$checksums_path"
+}
+
+update_checksums_distr() {
+ update_checksums *.exe *.iso
+}
+
+verify_checksums() {
+ sha1sum --check "$checksums_path"
+}
diff --git a/.bashrc_git b/.bashrc_git
index cfc1c9c..9de238b 100644
--- a/.bashrc_git
+++ b/.bashrc_git
@@ -1,3 +1,5 @@
+[ ! -z "${BASHRC_GIT+x}" ] && return || readonly BASHRC_GIT=1
+
alias list_repo_files='git ls-files -z'
list_repo_dirs() (
diff --git a/.bashrc_netwrix b/.bashrc_netwrix
index a7bf8dc..4a33947 100644
--- a/.bashrc_netwrix
+++ b/.bashrc_netwrix
@@ -1,3 +1,7 @@
+[ ! -z "${BASHRC_NETWRIX+x}" ] && return || readonly BASHRC_NETWRIX=1
+
+source .bashrc_text || return
+
nwx_host=172.28.10.2
nwx_dev2=172.28.19.60
nwx_dev3=172.28.19.61
diff --git a/.bashrc_pgn b/.bashrc_pgn
new file mode 100644
index 0000000..373c5b3
--- /dev/null
+++ b/.bashrc_pgn
@@ -0,0 +1,38 @@
+[ ! -z "${BASHRC_PGN+x}" ] && return || readonly BASHRC_PGN=1
+
+source .bashrc_text || return
+
+alias strip_pgn_clk='sed --binary --in-place '"'"'s/ {\[%clk [[:digit:]]\+:[[:digit:]]\+\(:[[:digit:]]\+\)*\]}//g'"'"
+alias slice_pgn_moves='sed --binary --in-place '"'"'s/ \([[:digit:]]\+\.\)/\n\1/g'"'"
+
+normalize_pgn() {
+ dos2eol "$@" \
+ && lint "$@" \
+ && strip_pgn_clk "$@" \
+ && slice_pgn_moves "$@" \
+ && eol2dos "$@"
+}
+
+append_pgn() {
+ if [ "$#" -ne 2 ]; then
+ echo "$FUNCNAME: usage: $FUNCNAME DEST_PGN SRC_PGN" >&2
+ return 1
+ fi
+
+ printf '\r\n' >> "$1" \
+ && cat "$2" >> "$1"
+}
+
+join_pgns() (
+ [ "$#" -eq 0 ] && return
+
+ set -o errexit
+
+ cat "$1"
+
+ local i
+ for i in "${@:2}"; do
+ printf '\r\n'
+ cat "$i"
+ done
+)
diff --git a/.bashrc_text b/.bashrc_text
new file mode 100644
index 0000000..2c25ff3
--- /dev/null
+++ b/.bashrc_text
@@ -0,0 +1,25 @@
+[ ! -z "${BASHRC_TEXT+x}" ] && return || readonly BASHRC_TEXT=1
+
+# Handy sed one-liners
+# --------------------
+
+alias dos2eol='sed --binary --in-place '"'"'s/\(\r\?\)$//'"'"
+alias eol2dos='sed --binary --in-place '"'"'s/\r\?$/\r/'"'"
+
+alias trim='sed --binary --in-place '"'"'s/[[:blank:]]*\(\r\?\)$/\1/'"'"
+
+alias trimeol='sed --binary --in-place -e :a -e '"'"'/^\n*$/{$d;N;ba}'"'"
+alias trimdoseol='sed --binary --in-place -e :a -e '"'"'/^\(\r\n\)*\r$/{$d;N;ba}'"'"
+
+alias eol='sed --binary --in-place '"'"'$a\'"'"
+alias doseol='sed --binary --in-place '"'"'$s/\r\?$/\r/;a\'"'"
+
+alias trimbom='sed --binary --in-place '"'"'1 s/^\xef\xbb\xbf//'"'"
+
+lint() {
+ trim "$@" && trimeol "$@" && eol "$@"
+}
+
+doslint() {
+ trim "$@" && trimdoseol "$@" && doseol "$@"
+}
diff --git a/.bashrc_third_party b/.bashrc_third_party
index be33720..30a3b2b 100644
--- a/.bashrc_third_party
+++ b/.bashrc_third_party
@@ -1,3 +1,5 @@
+[ ! -z "${BASHRC_THIRD_PARTY+x}" ] && return || readonly BASHRC_THIRD_PARTY=1
+
ensure_symlinks_enabled() {
[ -z "${CYGWIN+x}" ] && return 1