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
|
||||
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_PRELUDE
|
||||
|
||||
: "${1:?dirs?}"
|
||||
|
||||
setfacl -Rb "${@:1}"
|
||||
|
||||
chown -R "root:root" "${@:1}"
|
||||
chmod -R "u=rwX,g=rwX,o=" "${@:1}"
|
||||
# reassign owner to root
|
||||
chown --recursive "root:root" "${@:1}"
|
||||
chmod --recursive "u=rwX,g=,o=" "${@:1}"
|
||||
# clear facl
|
||||
setfacl --recursive --remove-all "${@:1}"
|
||||
}
|
||||
|
||||
function add_facl {
|
||||
@@ -15,12 +24,19 @@ function add_facl {
|
||||
: "${1:?user?}"
|
||||
: "${2:?dirs?}"
|
||||
|
||||
setfacl -Rm "\
|
||||
user:${1}:rwX,\
|
||||
default:user:${1}:rwX,\
|
||||
group:${1}:rwX,\
|
||||
default:group:${1}:rwX,\
|
||||
" "${@:2}"
|
||||
local arr=(
|
||||
user::rwX
|
||||
user:${1}:rwX
|
||||
default:user:${1}:rwX
|
||||
group::0
|
||||
default:group::0
|
||||
mask::rwX
|
||||
default:mask::rwX
|
||||
other::0
|
||||
default:other::0
|
||||
)
|
||||
|
||||
setfacl --recursive --modify "${(j:,:)arr}" "${@:2}"
|
||||
}
|
||||
|
||||
function is_local {
|
||||
@@ -76,14 +92,14 @@ function mount_sshfs {
|
||||
" | zsh -x
|
||||
}
|
||||
|
||||
function sublr {
|
||||
FUNCTION_PRELUDE
|
||||
# function sublr {
|
||||
# FUNCTION_PRELUDE
|
||||
|
||||
local HOSTNAME=$(hostname)
|
||||
local FULL_PATH=$(realpath $1)
|
||||
# local HOSTNAME=$(hostname)
|
||||
# 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_PRELUDE
|
||||
@@ -107,10 +123,7 @@ function cdtmp {
|
||||
function mkcd {
|
||||
FUNCTION_PRELUDE_NO_XTRACE
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo ':('
|
||||
return 1
|
||||
fi
|
||||
: "${1:?where?}"
|
||||
|
||||
if [[ -e $1 ]]; then
|
||||
echo "file exists"
|
||||
@@ -196,25 +209,6 @@ function beet_comments {
|
||||
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_PRELUDE
|
||||
|
||||
|
Reference in New Issue
Block a user