more : magic + some array args + setfacl rework
This commit is contained in:
@@ -59,3 +59,22 @@ alias FUNCTION_PRELUDE_NO_XTRACE="setopt LOCAL_OPTIONS PIPE_FAIL NO_XTRACE ERR_R
|
|||||||
|
|
||||||
# pottering recommendation
|
# pottering recommendation
|
||||||
alias psc="ps xawf -eo pid,user,cgroup,args"
|
alias psc="ps xawf -eo pid,user,cgroup,args"
|
||||||
|
|
||||||
|
local arr=(
|
||||||
|
rsync
|
||||||
|
--info=PROGRESS2
|
||||||
|
--progress
|
||||||
|
--recursive
|
||||||
|
--compress
|
||||||
|
--human-readable
|
||||||
|
--update
|
||||||
|
--times
|
||||||
|
--no-whole-file
|
||||||
|
--itemize-changes
|
||||||
|
--stats
|
||||||
|
--verbose
|
||||||
|
--links
|
||||||
|
--no-perms
|
||||||
|
--chmod=ugo=rwX
|
||||||
|
)
|
||||||
|
alias rsync2="$arr"
|
@@ -1,12 +1,21 @@
|
|||||||
|
# : magic
|
||||||
|
# ':' just evaluates the given expression
|
||||||
|
# : "${1:?dirs?}" exits saying "dirs?" if $1 is unset or null
|
||||||
|
# : "${1:=best}" sets $1 to "best" if $1 is unset or null
|
||||||
|
|
||||||
|
# ${(j:,:)arr} joins arr with commas
|
||||||
|
|
||||||
|
|
||||||
function reset_facl {
|
function reset_facl {
|
||||||
FUNCTION_PRELUDE
|
FUNCTION_PRELUDE
|
||||||
|
|
||||||
: "${1:?dirs?}"
|
: "${1:?dirs?}"
|
||||||
|
|
||||||
setfacl -Rb "${@:1}"
|
# reassign owner to root
|
||||||
|
chown --recursive "root:root" "${@:1}"
|
||||||
chown -R "root:root" "${@:1}"
|
chmod --recursive "u=rwX,g=,o=" "${@:1}"
|
||||||
chmod -R "u=rwX,g=rwX,o=" "${@:1}"
|
# clear facl
|
||||||
|
setfacl --recursive --remove-all "${@:1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_facl {
|
function add_facl {
|
||||||
@@ -15,12 +24,19 @@ function add_facl {
|
|||||||
: "${1:?user?}"
|
: "${1:?user?}"
|
||||||
: "${2:?dirs?}"
|
: "${2:?dirs?}"
|
||||||
|
|
||||||
setfacl -Rm "\
|
local arr=(
|
||||||
user:${1}:rwX,\
|
user::rwX
|
||||||
default:user:${1}:rwX,\
|
user:${1}:rwX
|
||||||
group:${1}:rwX,\
|
default:user:${1}:rwX
|
||||||
default:group:${1}:rwX,\
|
group::0
|
||||||
" "${@:2}"
|
default:group::0
|
||||||
|
mask::rwX
|
||||||
|
default:mask::rwX
|
||||||
|
other::0
|
||||||
|
default:other::0
|
||||||
|
)
|
||||||
|
|
||||||
|
setfacl --recursive --modify "${(j:,:)arr}" "${@:2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_local {
|
function is_local {
|
||||||
@@ -76,14 +92,14 @@ function mount_sshfs {
|
|||||||
" | zsh -x
|
" | zsh -x
|
||||||
}
|
}
|
||||||
|
|
||||||
function sublr {
|
# function sublr {
|
||||||
FUNCTION_PRELUDE
|
# FUNCTION_PRELUDE
|
||||||
|
|
||||||
local HOSTNAME=$(hostname)
|
# local HOSTNAME=$(hostname)
|
||||||
local FULL_PATH=$(realpath $1)
|
# local FULL_PATH=$(realpath $1)
|
||||||
|
|
||||||
echo "subl /Users/abra/mount/$HOSTNAME/$FULL_PATH" > /tmp/sshfs_command_pipe
|
# echo "subl /Users/abra/mount/$HOSTNAME/$FULL_PATH" > /tmp/sshfs_command_pipe
|
||||||
}
|
# }
|
||||||
|
|
||||||
function cdtmp {
|
function cdtmp {
|
||||||
FUNCTION_PRELUDE
|
FUNCTION_PRELUDE
|
||||||
@@ -107,10 +123,7 @@ function cdtmp {
|
|||||||
function mkcd {
|
function mkcd {
|
||||||
FUNCTION_PRELUDE_NO_XTRACE
|
FUNCTION_PRELUDE_NO_XTRACE
|
||||||
|
|
||||||
if [[ -z $1 ]]; then
|
: "${1:?where?}"
|
||||||
echo ':('
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -e $1 ]]; then
|
if [[ -e $1 ]]; then
|
||||||
echo "file exists"
|
echo "file exists"
|
||||||
@@ -196,25 +209,6 @@ function beet_comments {
|
|||||||
levi_beet modify \'"comments=$2"\' \'"albumartist::$1"\'
|
levi_beet modify \'"comments=$2"\' \'"albumartist::$1"\'
|
||||||
}
|
}
|
||||||
|
|
||||||
function rsync2 {
|
|
||||||
rsync \
|
|
||||||
--info=PROGRESS2 \
|
|
||||||
--progress \
|
|
||||||
--recursive \
|
|
||||||
--compress \
|
|
||||||
--human-readable \
|
|
||||||
--update \
|
|
||||||
--times \
|
|
||||||
--no-whole-file \
|
|
||||||
--itemize-changes \
|
|
||||||
--stats \
|
|
||||||
--verbose \
|
|
||||||
--links \
|
|
||||||
--no-perms \
|
|
||||||
--chmod=ugo=rwX \
|
|
||||||
"${(@)@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function sync_music {
|
function sync_music {
|
||||||
FUNCTION_PRELUDE
|
FUNCTION_PRELUDE
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user