You are not logged in.

#1 2013-04-24 17:07:16

silenc3r
Member
From: Poland
Registered: 2009-08-29
Posts: 149

[Solved] Automatic sudo with pacman in Fish shell

I'm trying to write function which automatically runs pacman with sudo if needed. Basically equivalent of this in bash:

pacman() {
    case $1 in
        -S | -D | -S[^sih]* | -R* | -U*)
            /usr/bin/sudo /usr/bin/pacman "$@" ;;
    *)      /usr/bin/pacman "$@" ;;
    esac
}

Here's what I got so far:

function pacman
    switch $argv[1]
        case '-S' '-D' '-S[^sih]*' '-R*' '-U*'
            /usr/bin/sudo /usr/bin/pacman $argv
        case '*'
            /usr/bin/pacman $argv
    end
end

After successful execution of /usr/bin/sudo /usr/bin/pacman I cannot see the character's I'm typing.
Also if I deny installation/removal of package the shell prompt spawns in the same line as the query instead of a new line.

Last edited by silenc3r (2013-05-12 14:49:03)

Offline

#2 2013-05-12 14:48:43

silenc3r
Member
From: Poland
Registered: 2009-08-29
Posts: 149

Re: [Solved] Automatic sudo with pacman in Fish shell

It seems to be some bug in current repo version of fish (fish 2.0b2-4). After installing fish-shell-git from AUR all problems disappeared.

Here's final version of the pacman.fish in case anyone's interested:

function pacman
	switch $argv[1]
		case '-D' '-R*' '-U*' '-S' '-Sc*' '-Sd*' '-Su*' '-Sw*' '-Sy*'
			/usr/bin/sudo /usr/bin/pacman $argv
		case '*'
			/usr/bin/pacman $argv
	end
end

Offline

Board footer

Powered by FluxBB