diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-26 02:10:27 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-26 02:10:27 +0300 |
commit | 4042abe156b4f9cad30d66238b52fcd938043ded (patch) | |
tree | b351938efa93930aed703119e28c9c269516121f /.bashrc_pgn | |
parent | add append_pgn, join_pgns (diff) | |
download | linux-home-4042abe156b4f9cad30d66238b52fcd938043ded.tar.gz linux-home-4042abe156b4f9cad30d66238b52fcd938043ded.zip |
split .bashrc into multiple files
Diffstat (limited to '')
-rw-r--r-- | .bashrc_pgn | 38 |
1 files changed, 38 insertions, 0 deletions
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 +) |