From 539e4ec2f12280c96c6e35180d2f3c9b7d9613a8 Mon Sep 17 00:00:00 2001 From: phone Date: Mon, 29 Jan 2024 04:12:31 +0300 Subject: [PATCH] Bash : Remove conflicting names. --- .config/bash/module/Cp.sh | 18 ++++++------------ .config/bash/module/Disk.sh | 8 ++++---- .config/bash/module/Export.sh | 3 +++ .config/bash/module/Group.sh | 2 +- .config/bash/module/Ncdu.sh | 6 ------ .config/bash/module/Own.sh | 6 +++++- .../module/{Permissions.sh => Permission.sh} | 2 +- .config/bash/module/Umask.sh | 1 - 8 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 .config/bash/module/Ncdu.sh rename .config/bash/module/{Permissions.sh => Permission.sh} (95%) delete mode 100644 .config/bash/module/Umask.sh diff --git a/.config/bash/module/Cp.sh b/.config/bash/module/Cp.sh index e52d37d..87ccc31 100644 --- a/.config/bash/module/Cp.sh +++ b/.config/bash/module/Cp.sh @@ -1,12 +1,12 @@ # Replaces default cp with rsync. -# Usage: cp -function cp() { +# Usage: rcp +function rcp() { rsync -ahP --chmod=u+w "${@}" } # Copy and also merge all changes (delete dst files that do not exist in src). -# Usage: cp_merge -function cp_merge() { +# Usage: rcp_merge +function rcp_merge() { rsync -ahP --chmod=u+w --delete "${@}" } @@ -17,14 +17,8 @@ function cp_link() { /usr/bin/env cp -lr "${@}" } -# Default cp, a.k.a builtin cp. -# When you don't need rsync. -function bcp() { - /usr/bin/env cp "${@}" -} - # Print output of cp_merge without writing anything. -# Usage: cp_test -function cp_test() { +# Usage: rcp_test +function rcp_test() { rsync -ahP --chmod=u+w --delete -n "${@}" } diff --git a/.config/bash/module/Disk.sh b/.config/bash/module/Disk.sh index 1ed89e3..2e8cd54 100644 --- a/.config/bash/module/Disk.sh +++ b/.config/bash/module/Disk.sh @@ -1,11 +1,11 @@ # Show only physical drives info. -function df() { +function pdf() { /usr/bin/env df --si | sed -e '1p' -e '/^\/dev\//!d' } -# Show combined size in SI. +# Show total size in SI. # Current dir by default. -# Usage: du [DIRS] -function du() { +# Usage: tdu [DIRS] +function tdu() { /usr/bin/env du -sh --si } diff --git a/.config/bash/module/Export.sh b/.config/bash/module/Export.sh index 091e4dc..ef16f14 100644 --- a/.config/bash/module/Export.sh +++ b/.config/bash/module/Export.sh @@ -1,3 +1,6 @@ +# Set umask. +umask 077 + # add all links in ~/app/bin/ export PATH=$( find -L ${HOME}/app/bin/ -type d -printf ":%p" 2> /dev/null ):${PATH} diff --git a/.config/bash/module/Group.sh b/.config/bash/module/Group.sh index bda2b57..4d80a56 100644 --- a/.config/bash/module/Group.sh +++ b/.config/bash/module/Group.sh @@ -51,7 +51,7 @@ function group_year_current() { year=${year%%-*} if [[ "${year}" = "${today}" ]]; then - /usr/bin/env cp -- ${target} ./${today}/ + rcp -- ${target} ./${today}/ else _iterate_skip fi diff --git a/.config/bash/module/Ncdu.sh b/.config/bash/module/Ncdu.sh deleted file mode 100644 index 2bddf69..0000000 --- a/.config/bash/module/Ncdu.sh +++ /dev/null @@ -1,6 +0,0 @@ -# Search only on current filesystem. -# Current dir by default. -# Usage: ncdu [DIRS] -function ncdu() { - ncdu -x -- "${@}" -} diff --git a/.config/bash/module/Own.sh b/.config/bash/module/Own.sh index 6029a11..f28d274 100644 --- a/.config/bash/module/Own.sh +++ b/.config/bash/module/Own.sh @@ -5,6 +5,7 @@ function own() { local IFS=$'\n' local files=("${@:2}") local user="${1}" + local group="${1}" # default to current dir. if [ "${files[*]}" = "" ]; then @@ -16,9 +17,12 @@ function own() { user="${UID}" fi + # If not root, default to users group. + _is_root || group="100" + for file in "${files[@]}"; do # set ownership. - chown "${user}":"${user}" -R "${file}" &> /dev/null + chown "${user}":"${group}" -R "${file}" &> /dev/null # remove access from group and others. chmod -077 -R "${file}" diff --git a/.config/bash/module/Permissions.sh b/.config/bash/module/Permission.sh similarity index 95% rename from .config/bash/module/Permissions.sh rename to .config/bash/module/Permission.sh index e91a5da..7d2bd24 100644 --- a/.config/bash/module/Permissions.sh +++ b/.config/bash/module/Permission.sh @@ -1,4 +1,4 @@ -# Recursively change permissions to allow read sharing with group and others. +# Recursively change permissions to allow read sharing with group and others. function perm_share() { find . -type d -exec chmod 755 {} \;; find . -type f -exec chmod 644 {} \; } diff --git a/.config/bash/module/Umask.sh b/.config/bash/module/Umask.sh deleted file mode 100644 index 08b18ee..0000000 --- a/.config/bash/module/Umask.sh +++ /dev/null @@ -1 +0,0 @@ -umask 077