aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--%HOME%/.bash_utils/git.sh34
-rw-r--r--%HOME%/.bash_utils/os.sh47
-rw-r--r--%HOME%/.bash_utils/path.sh6
-rw-r--r--%HOME%/.bash_utils/ruby.sh13
-rw-r--r--%HOME%/.bashrc6
5 files changed, 59 insertions, 47 deletions
diff --git a/%HOME%/.bash_utils/git.sh b/%HOME%/.bash_utils/git.sh
index c557607..c99f2e2 100644
--- a/%HOME%/.bash_utils/git.sh
+++ b/%HOME%/.bash_utils/git.sh
@@ -7,14 +7,14 @@
source "$HOME/.bash_utils/text.sh"
-alias list_repo_files='git ls-tree -r --name-only HEAD'
-alias list_repo_dirs='git ls-tree -r --name-only HEAD -d'
+alias repo_files='git ls-tree -r --name-only HEAD'
+alias repo_dirs='git ls-tree -r --name-only HEAD -d'
-list_repo_branches() {
+repo_branches() {
git for-each-ref --format='%(refname:short)' refs/heads/
}
-is_repo_clean() (
+repo_is_clean() (
set -o errexit -o nounset -o pipefail
test -z "$( git status --porcelain )"
)
@@ -25,7 +25,7 @@ alias repo_clean_ignored='git clean -fdX'
branch_eol_normalized() (
set -o errexit -o nounset -o pipefail
- if is_repo_clean; then
+ if repo_is_clean; then
repo_clean_ignored
else
echo "${FUNCNAME[0]}: repository isn't clean" >&2
@@ -55,7 +55,7 @@ branch_eol_normalized() (
repo_eol_normalized() (
set -o errexit -o nounset -o pipefail
- if is_repo_clean; then
+ if repo_is_clean; then
repo_clean_ignored
else
echo "${FUNCNAME[0]}: repository isn't clean" >&2
@@ -66,18 +66,18 @@ repo_eol_normalized() (
while IFS= read -r branch; do
git checkout --quiet "$branch"
branch_eol_normalized "$branch"
- done < <( list_repo_branches )
+ done < <( repo_branches )
)
-tighten_repo_security() (
+repo_tighten_permissions() (
set -o errexit -o nounset -o pipefail
- list_repo_files -z | xargs -0 -- chmod 0600 --
- list_repo_dirs -z | xargs -0 -- chmod 0700 --
+ repo_files -z | xargs -0 -- chmod 0600 --
+ repo_dirs -z | xargs -0 -- chmod 0700 --
chmod 0700 .git
)
-doslint_repo() (
+repo_doslint() (
set -o errexit -o nounset -o pipefail
local -a paths
@@ -85,12 +85,12 @@ doslint_repo() (
while IFS= read -d '' -r path; do
paths+=("$path")
- done < <( list_repo_files -z )
+ done < <( repo_files -z )
doslint ${paths[@]+"${paths[@]}"}
)
-lint_repo() (
+repo_lint() (
set -o errexit -o nounset -o pipefail
local -a paths
@@ -98,12 +98,12 @@ lint_repo() (
while IFS= read -d '' -r path; do
paths+=("$path")
- done < <( list_repo_files -z )
+ done < <( repo_files -z )
lint ${paths[@]+"${paths[@]}"}
)
-backup_repo() (
+repo_backup() (
set -o errexit -o nounset -o pipefail
local repo_dir
@@ -129,8 +129,8 @@ backup_repo() (
HEAD
)
-backup_repo_dropbox() (
+repo_backup_dropbox() (
set -o errexit -o nounset -o pipefail
- backup_repo "$USERPROFILE/Dropbox/backups"
+ repo_backup "$USERPROFILE/Dropbox/backups"
)
diff --git a/%HOME%/.bash_utils/os.sh b/%HOME%/.bash_utils/os.sh
index 640c693..193b272 100644
--- a/%HOME%/.bash_utils/os.sh
+++ b/%HOME%/.bash_utils/os.sh
@@ -1,8 +1,13 @@
#!/usr/bin/env bash
+# Copyright (c) 2016 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "Cygwin configuration files" project.
+# For details, see https://github.com/egor-tensin/cygwin-home.
+# Distributed under the MIT License.
+
_os=''
-detect_os() {
+os_detect() {
command -v uname > /dev/null \
&& [ "$( uname -o )" == 'Cygwin' ] \
&& _os='Cygwin' \
@@ -15,25 +20,25 @@ detect_os() {
return 1
}
-detect_os
+os_detect
os_detected() {
test -n "$_os"
}
-is_cygwin() {
+os_is_cygwin() {
test "$_os" == 'Cygwin'
}
-is_ubuntu() {
+os_is_ubuntu() {
test "$_os" == 'Ubuntu'
}
-is_arch() {
+os_is_arch() {
test "$_os" == 'Arch Linux'
}
-list_packages_cygwin() (
+packages_list_cygwin() (
set -o errexit -o nounset -o pipefail
cygcheck --check-setup --dump-only \
@@ -41,7 +46,7 @@ list_packages_cygwin() (
| cut -d ' ' -f 1
)
-list_initial_packages_ubuntu() (
+setup_packages_list_ubuntu() (
set -o errexit -o nounset -o pipefail
local -r initial_status='/var/log/installer/initial-status.gz'
@@ -52,14 +57,14 @@ list_initial_packages_ubuntu() (
| uniq
)
-list_manually_installed_packages_ubuntu() (
+user_packages_list_ubuntu() (
set -o errexit -o nounset -o pipefail
comm -23 <( apt-mark showmanual | sort | uniq ) \
- <( list_initial_packages_ubuntu )
+ <( setup_packages_list_ubuntu )
)
-list_packages_ubuntu() (
+packages_list_ubuntu() (
set -o errexit -o nounset -o pipefail
dpkg --get-selections \
@@ -68,7 +73,7 @@ list_packages_ubuntu() (
| cut -d ':' -f 1
)
-list_initial_packages_arch() (
+setup_packages_list_arch() (
set -o errexit -o nounset -o pipefail
local -ra groups=(base base-devel)
@@ -76,26 +81,26 @@ list_initial_packages_arch() (
pacman -Q --groups -q -- ${groups[@]+"${groups[@]}"} | sort
)
-list_manually_installed_packages_arch() (
+user_packages_list_arch() (
set -o errexit -o nounset -o pipefail
comm -23 <( pacman -Q --explicit -q | sort ) \
- <( list_initial_packages_arch )
+ <( setup_packages_list_arch )
)
-list_packages_arch() {
+packages_list_arch() {
pacman -Qq
}
-list_packages() (
+packages_list() (
set -o errexit -o nounset -o pipefail
- if is_cygwin; then
- list_packages_cygwin
- elif is_ubuntu; then
- list_packages_ubuntu
- elif is_arch; then
- list_packages_arch
+ if os_is_cygwin; then
+ packages_list_cygwin
+ elif os_is_ubuntu; then
+ packages_list_ubuntu
+ elif os_is_arch; then
+ packages_list_arch
else
return 1
fi
diff --git a/%HOME%/.bash_utils/path.sh b/%HOME%/.bash_utils/path.sh
index 57f1ab5..9a0e1a2 100644
--- a/%HOME%/.bash_utils/path.sh
+++ b/%HOME%/.bash_utils/path.sh
@@ -7,7 +7,7 @@
source "$HOME/.bash_utils/text.sh"
-add_missing_path() (
+path_add() (
set -o errexit -o nounset -o pipefail
[ "$#" -eq 0 ] && return 0
@@ -45,9 +45,9 @@ add_missing_path() (
str_join ':' ${dest_list[@]+"${dest_list[@]}"}
)
-add_path() {
+path_export() {
local new_path
- new_path="$( add_missing_path "$@" )" \
+ new_path="$( path_add "$@" )" \
&& export PATH="$new_path"
}
diff --git a/%HOME%/.bash_utils/ruby.sh b/%HOME%/.bash_utils/ruby.sh
index 86c2c27..abcd9b7 100644
--- a/%HOME%/.bash_utils/ruby.sh
+++ b/%HOME%/.bash_utils/ruby.sh
@@ -1,6 +1,13 @@
#!/usr/bin/env bash
-update_ruby_settings() {
+# Copyright (c) 2016 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "Cygwin configuration files" project.
+# For details, see https://github.com/egor-tensin/cygwin-home.
+# Distributed under the MIT License.
+
+source "$HOME/.bash_utils/path.sh"
+
+ruby_setup() {
local user_dir
local bin_dir
@@ -9,7 +16,7 @@ update_ruby_settings() {
&& user_dir="$( ruby -e 'puts Gem.user_dir' )" \
&& export GEM_HOME="$user_dir" \
&& bin_dir="$( ruby -e 'puts Gem.bindir' )" \
- && add_path "$bin_dir"
+ && path_export "$bin_dir"
}
-update_ruby_settings
+ruby_setup
diff --git a/%HOME%/.bashrc b/%HOME%/.bashrc
index 5c5308e..3555171 100644
--- a/%HOME%/.bashrc
+++ b/%HOME%/.bashrc
@@ -45,12 +45,12 @@ alias cls='echo -en "\ec"'
export PYTHONSTARTUP="$HOME/.pythonrc"
-is_cygwin && set -o igncr
-is_cygwin || complete -r
+os_is_cygwin && set -o igncr
+os_is_cygwin || complete -r
export SHELLOPTS
-if is_cygwin; then
+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'