Merge branch 'main' of git.yrz.am:yrzam/workspace
This commit is contained in:
commit
b1d63d0e67
@ -12,7 +12,6 @@ parse() {
|
||||
local expanded=()
|
||||
for arg in "$@"; do
|
||||
if [[ $arg =~ ^-[a-zA-Z]{2,}$ ]]; then
|
||||
# This is a combined flag like -iu
|
||||
local chars="${arg:1}"
|
||||
for ((j=0; j<${#chars}; j++)); do
|
||||
expanded+=("-${chars:$j:1}")
|
||||
@ -34,36 +33,26 @@ parse() {
|
||||
if [[ $i -lt $arg_count ]]; then
|
||||
sudo_user="${args[$i]}"
|
||||
fi
|
||||
((i++))
|
||||
;;
|
||||
((i++));;
|
||||
-i|--login)
|
||||
sudo_login_shell=true
|
||||
((i++))
|
||||
;;
|
||||
((i++));;
|
||||
-s|--shell)
|
||||
((i++))
|
||||
;;
|
||||
((i++));;
|
||||
--)
|
||||
((i++))
|
||||
sudo_command="${args[*]:$i}"
|
||||
break
|
||||
;;
|
||||
break;;
|
||||
-*)
|
||||
# Unknown flag, skip it
|
||||
((i++))
|
||||
;;
|
||||
((i++));;
|
||||
su)
|
||||
((i++))
|
||||
local su_user=""
|
||||
local su_args=()
|
||||
|
||||
# Collect all remaining args for su processing
|
||||
while [[ $i -lt $arg_count ]]; do
|
||||
su_args+=("${args[$i]}")
|
||||
((i++))
|
||||
done
|
||||
|
||||
# Expand combined flags in su arguments
|
||||
local su_expanded=()
|
||||
for arg in "${su_args[@]}"; do
|
||||
if [[ $arg =~ ^-[a-zA-Z]{2,}$ ]]; then
|
||||
@ -75,58 +64,47 @@ parse() {
|
||||
su_expanded+=("$arg")
|
||||
fi
|
||||
done
|
||||
|
||||
# Process expanded su arguments
|
||||
local k=0
|
||||
local su_count=${#su_expanded[@]}
|
||||
while [[ $k -lt $su_count ]]; do
|
||||
case "${su_expanded[$k]}" in
|
||||
-|-l|--login)
|
||||
sudo_login_shell=true
|
||||
((k++))
|
||||
;;
|
||||
((k++));;
|
||||
-c|--command)
|
||||
((k++))
|
||||
if [[ $k -lt $su_count ]]; then
|
||||
sudo_command="${su_expanded[$k]}"
|
||||
((k++))
|
||||
fi
|
||||
;;
|
||||
fi;;
|
||||
--session-command=*)
|
||||
sudo_command="${su_expanded[$k]#*=}"
|
||||
((k++))
|
||||
;;
|
||||
((k++));;
|
||||
-m|-p|--preserve-environment)
|
||||
((k++))
|
||||
;;
|
||||
((k++));;
|
||||
-s|--shell)
|
||||
((k++))
|
||||
if [[ $k -lt $su_count && "${su_expanded[$k]}" != -* ]]; then
|
||||
((k++))
|
||||
fi
|
||||
;;
|
||||
fi;;
|
||||
-*)
|
||||
((k++))
|
||||
;;
|
||||
((k++));;
|
||||
*)
|
||||
if [[ -z "$su_user" ]]; then
|
||||
su_user="${su_expanded[$k]}"
|
||||
((k++))
|
||||
else
|
||||
((k++))
|
||||
fi
|
||||
;;
|
||||
fi;;
|
||||
esac
|
||||
done
|
||||
if [[ -n "$su_user" ]]; then
|
||||
sudo_user="$su_user"
|
||||
fi
|
||||
break
|
||||
;;
|
||||
break;;
|
||||
*)
|
||||
sudo_command="${args[*]:$i}"
|
||||
break
|
||||
;;
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
11
arch-user/config/workspace-compat/bashrc
Normal file
11
arch-user/config/workspace-compat/bashrc
Normal file
@ -0,0 +1,11 @@
|
||||
[ -f ~/.bashrc ] && . ~/.bashrc
|
||||
stty intr ^K
|
||||
alias ssh='wssh'
|
||||
alias sudo='wsudo'
|
||||
su() {
|
||||
if [ "$1" = "-" ]; then
|
||||
shift && wsudo - -u "$@"
|
||||
else
|
||||
wsudo -u "$@"
|
||||
fi
|
||||
}
|
@ -12,18 +12,7 @@ export SHELL=/bin/bash
|
||||
export PATH="$WSCOMPAT_DIR:$PATH"
|
||||
|
||||
cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/bashrc"
|
||||
|
||||
[ -f ~/.bashrc ] && . ~/.bashrc
|
||||
stty intr ^K
|
||||
alias ssh='wssh'
|
||||
alias sudo='wsudo'
|
||||
su() {
|
||||
if [ "$1" = "-" ]; then
|
||||
shift && wsudo - -u "$@"
|
||||
else
|
||||
wsudo -u "$@"
|
||||
fi
|
||||
}
|
||||
{{ tmpl.Inline (file.Read "config/workspace-compat/bashrc") . }}
|
||||
WSCOMPAT_EOF_04tcIQE7
|
||||
|
||||
export VIMINIT="source $WSCOMPAT_DIR/vimrc"
|
||||
|
@ -71,7 +71,8 @@ gomplate --input-dir config \
|
||||
--plugin jq=/bin/jq \
|
||||
-c theme=config/theme.json \
|
||||
-c user="file:///$HOME/.config/workspace.conf?type=application/x-env" \
|
||||
--exclude /workspace.conf --exclude /workspace-compat/profile.tmpl
|
||||
--exclude /workspace.conf \
|
||||
--exclude /workspace-compat/* --exclude !/workspace-compat/env.sh
|
||||
|
||||
ln -sf ~/.config/bash/bashrc ~/.bashrc
|
||||
ln -sf ~/.config/profile ~/.profile
|
||||
|
Loading…
Reference in New Issue
Block a user