Bash : Remove conflicting names.

This commit is contained in:
Dmitry Voronin 2024-01-29 04:12:31 +03:00
parent cc68c536b3
commit 539e4ec2f1
8 changed files with 20 additions and 26 deletions

View file

@ -1,12 +1,12 @@
# Replaces default cp with rsync. # Replaces default cp with rsync.
# Usage: cp <FROM> <TO> # Usage: rcp <FROM> <TO>
function cp() { function rcp() {
rsync -ahP --chmod=u+w "${@}" rsync -ahP --chmod=u+w "${@}"
} }
# Copy and also merge all changes (delete dst files that do not exist in src). # Copy and also merge all changes (delete dst files that do not exist in src).
# Usage: cp_merge <FROM> <TO> # Usage: rcp_merge <FROM> <TO>
function cp_merge() { function rcp_merge() {
rsync -ahP --chmod=u+w --delete "${@}" rsync -ahP --chmod=u+w --delete "${@}"
} }
@ -17,14 +17,8 @@ function cp_link() {
/usr/bin/env cp -lr "${@}" /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. # Print output of cp_merge without writing anything.
# Usage: cp_test <FROM> <TO> # Usage: rcp_test <FROM> <TO>
function cp_test() { function rcp_test() {
rsync -ahP --chmod=u+w --delete -n "${@}" rsync -ahP --chmod=u+w --delete -n "${@}"
} }

View file

@ -1,11 +1,11 @@
# Show only physical drives info. # Show only physical drives info.
function df() { function pdf() {
/usr/bin/env df --si | sed -e '1p' -e '/^\/dev\//!d' /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. # Current dir by default.
# Usage: du [DIRS] # Usage: tdu [DIRS]
function du() { function tdu() {
/usr/bin/env du -sh --si /usr/bin/env du -sh --si
} }

View file

@ -1,3 +1,6 @@
# Set umask.
umask 077
# add all links in ~/app/bin/ # add all links in ~/app/bin/
export PATH=$( find -L ${HOME}/app/bin/ -type d -printf ":%p" 2> /dev/null ):${PATH} export PATH=$( find -L ${HOME}/app/bin/ -type d -printf ":%p" 2> /dev/null ):${PATH}

View file

@ -51,7 +51,7 @@ function group_year_current() {
year=${year%%-*} year=${year%%-*}
if [[ "${year}" = "${today}" ]]; then if [[ "${year}" = "${today}" ]]; then
/usr/bin/env cp -- ${target} ./${today}/ rcp -- ${target} ./${today}/
else else
_iterate_skip _iterate_skip
fi fi

View file

@ -1,6 +0,0 @@
# Search only on current filesystem.
# Current dir by default.
# Usage: ncdu [DIRS]
function ncdu() {
ncdu -x -- "${@}"
}

View file

@ -5,6 +5,7 @@ function own() {
local IFS=$'\n' local IFS=$'\n'
local files=("${@:2}") local files=("${@:2}")
local user="${1}" local user="${1}"
local group="${1}"
# default to current dir. # default to current dir.
if [ "${files[*]}" = "" ]; then if [ "${files[*]}" = "" ]; then
@ -16,9 +17,12 @@ function own() {
user="${UID}" user="${UID}"
fi fi
# If not root, default to users group.
_is_root || group="100"
for file in "${files[@]}"; do for file in "${files[@]}"; do
# set ownership. # set ownership.
chown "${user}":"${user}" -R "${file}" &> /dev/null chown "${user}":"${group}" -R "${file}" &> /dev/null
# remove access from group and others. # remove access from group and others.
chmod -077 -R "${file}" chmod -077 -R "${file}"

View file

@ -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() { function perm_share() {
find . -type d -exec chmod 755 {} \;; find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \;; find . -type f -exec chmod 644 {} \;
} }

View file

@ -1 +0,0 @@
umask 077