From bb25466e394456cca34733c7e8e91af5567fedef Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 2 Apr 2022 08:51:52 +0300 Subject: bash: remove unused or low-value stuff --- %HOME%/.bash_utils/git.sh | 38 +------------------ %HOME%/.bash_utils/text.sh | 95 ---------------------------------------------- %HOME%/.bashrc | 15 -------- 3 files changed, 1 insertion(+), 147 deletions(-) diff --git a/%HOME%/.bash_utils/git.sh b/%HOME%/.bash_utils/git.sh index 021e0e8..5095610 100644 --- a/%HOME%/.bash_utils/git.sh +++ b/%HOME%/.bash_utils/git.sh @@ -8,8 +8,6 @@ alias branch_files='git ls-tree -r --name-only HEAD' alias branch_dirs='git ls-tree -r --name-only HEAD -d' -alias repo_branches='git for-each-ref '"'"'--format=%(refname:short)'"'"' refs/heads/' - workdir_is_clean() ( set -o errexit -o nounset -o pipefail shopt -s inherit_errexit @@ -23,9 +21,6 @@ workdir_is_clean() ( fi ) -alias workdir_clean_all='git clean -fdx' -alias workdir_clean_ignored='git clean -fdX' - branch_eol_normalized() ( set -o errexit -o nounset -o pipefail shopt -s inherit_errexit lastpipe @@ -62,28 +57,6 @@ branch_eol_normalized() ( return "$normalized" ) -repo_eol_normalized() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit lastpipe - - workdir_is_clean - - local branch - repo_branches | while IFS= read -r branch; do - git checkout --quiet "$branch" - branch_eol_normalized "$branch" - done -) - -workdir_tighten_permissions() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit - - branch_files -z | xargs -0 -- chmod 0600 -- - branch_dirs -z | xargs -0 -- chmod 0700 -- - chmod 0700 .git -) - branch_doslint() ( set -o errexit -o nounset -o pipefail shopt -s inherit_errexit lastpipe @@ -117,7 +90,7 @@ branch_backup() ( shopt -s inherit_errexit local repo_dir - repo_dir="$( pwd )" + repo_dir="$( git rev-parse --show-toplevel )" local repo_name repo_name="$( basename -- "$repo_dir" )" local backup_dir="$repo_dir" @@ -138,12 +111,3 @@ branch_backup() ( --remote="$repo_dir" \ HEAD ) - -branch_backup_dropbox() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit - - branch_backup "$USERPROFILE/Dropbox/backups" -) - -alias branch_fixup_committer_dates='git filter-branch --force --env-filter '"'"'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'"'" diff --git a/%HOME%/.bash_utils/text.sh b/%HOME%/.bash_utils/text.sh index e4e5929..ea5b1af 100644 --- a/%HOME%/.bash_utils/text.sh +++ b/%HOME%/.bash_utils/text.sh @@ -123,26 +123,6 @@ str_replace() ( echo "${str//$sub/$rep}" ) -str_tolower() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit - - local s - for s; do - echo "${s,,}" - done -) - -str_toupper() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit - - local s - for s; do - echo "${s^^}" - done -) - _bash_escape_pattern() ( set -o errexit -o nounset -o pipefail shopt -s inherit_errexit @@ -295,78 +275,3 @@ str_join() ( done echo ) - -str_grep() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit - - if [ "$#" -ne 1 ]; then - echo "usage: ${FUNCNAME[0]} PATTERN" >&2 - return 1 - fi - - local pattern="$1" - - find . -type f -exec grep --fixed-strings --binary-files=without-match --regexp="$pattern" -- {} + -) - -str_grep_word() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit - - if [ "$#" -ne 1 ]; then - echo "usage: ${FUNCNAME[0]} PATTERN" >&2 - return 1 - fi - - local pattern="$1" - - find . -type f -exec grep --basic-regexp --binary-files=without-match --regexp="\b$pattern\b" -- {} + -) - -str_iconv_fromto() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit - - if [ "$#" -lt 3 ]; then - echo "usage: ${FUNCNAME[0]} SRC_ENCODING DEST_ENCODING PATH..." >&2 - return 1 - fi - - local src_encoding="$1" - shift - local dest_encoding="$1" - shift - - local path path_dir tmp_path rm_tmp_path - - for path; do - path_dir="$( dirname -- "$path" )" - tmp_path="$( mktemp -- "$path_dir/${FUNCNAME[0]}_XXX" )" - if iconv --from-code="$src_encoding" --to-code="$dest_encoding" -- "$path" > "$tmp_path"; then - mv -f -- "$tmp_path" "$path" - else - rm -f -- "$tmp_path" - return 1 - fi - done -) - -str_iconv() ( - set -o errexit -o nounset -o pipefail - shopt -s inherit_errexit - - if [ "$#" -lt 2 ]; then - echo "usage: ${FUNCNAME[0]} DEST_ENCODING PATH..." >&2 - return 1 - fi - - local dest_encoding="$1" - shift - - local src_encoding path - for path; do - src_encoding="$( file --brief --mime-encoding -- "$path" )" - str_iconv_fromto "$src_encoding" "$dest_encoding" "$path" - done -) diff --git a/%HOME%/.bashrc b/%HOME%/.bashrc index d3cc531..5ed9119 100644 --- a/%HOME%/.bashrc +++ b/%HOME%/.bashrc @@ -46,9 +46,6 @@ alias tree='tree -a' alias sed='sed --follow-symlinks' -# Clear the screen (https://stackoverflow.com/a/5367075/514684): -alias cls='echo -en "\ec"' - alias copy='xclip -sel clip' # Make sure ssh-copy-id copies public keys along with their comments. @@ -91,24 +88,12 @@ os_is_cygwin || complete -r #export SHELLOPTS #export BASHOPTS -if os_is_cygwin; then - alias mingcc32='i686-w64-mingw32-gcc' - alias ming++32='i686-w64-mingw32-g++' - alias mingcc='x86_64-w64-mingw32-gcc' - alias ming++='x86_64-w64-mingw32-g++' -fi - # I've bumped into this on Linux Mint: Ctrl+S causes my terminal to freeze # completely (Ctrl+Q is a temporary escape, stty is the cure). os_is_cygwin \ || command -v stty > /dev/null 2>&1 \ && stty -ixon -# Vagrant: fix `vagrant plugin install`. -# https://github.com/hashicorp/vagrant/issues/12202 -# TODO: remove when 2.2.15 is released? -export VAGRANT_DISABLE_STRICT_DEPENDENCY_ENFORCEMENT=1 - # nnn # --- -- cgit v1.2.3