Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: xown, xrm #204

Open
whoizit opened this issue Feb 4, 2021 · 2 comments
Open

feature request: xown, xrm #204

whoizit opened this issue Feb 4, 2021 · 2 comments

Comments

@whoizit
Copy link

whoizit commented Feb 4, 2021

xown() { 
    [ -f "$@" ] \ 
        && xbps-query -o "$@" \
        || xbps-query -o $(readlink -f $(which "$@"))
}

~ $ xown /usr/share/tor/geoip
tor-0.4.4.6_1: /usr/share/tor/geoip (regular file)
~ $ xown tor
tor-0.4.4.6_1: /usr/bin/tor (regular file)
xrm() {
    doas xbps-remove -R "$@"
}
@Vaelatern
Copy link
Collaborator

xlocate

@gt7-void
Copy link

gt7-void commented Apr 1, 2021

my xrm, based almost verbatim on xi.

#! /bin/sh
# xrm PKGS... - like xbps-remove, using sudo/su

which_sudo() {
	if command -v sudo >/dev/null && sudo -l | grep -q -e ' ALL$' -e xbps-remove; then
		echo sudo
	elif command -v doas >/dev/null && [ -f /etc/doas.conf ]; then
		echo doas
	elif [ "$(id -u)" != 0 ]; then
		echo su
	fi
}

do_remove() {
	if [ "$SUDO" = su ]; then
		su root -c 'xbps-remove "$@"' -- sh "$@"
	else
		$SUDO xbps-remove "$@"
	fi
}

SUDO=$(which_sudo)
do_remove "$@"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants