Gentoo Archives: gentoo-user

From: Stefan Schmiedl <s@×××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Autoexecute when "returning" from sudo ?
Date: Wed, 31 Oct 2018 16:50:03
Message-Id: 1086613450.20181031174950@xss.de
In Reply to: Re: [gentoo-user] Autoexecute when "returning" from sudo ? by tuxic@posteo.de
1 You could also define a function like
2
3 function surh() { sudo "$@" ; rehash ; }
4
5 in your ~/.zshrc and skip the extra script file.
6
7 s.
8
9 "tuxic@××××××.de" <tuxic@××××××.de>, 31.10.2018, 16:36:
10
11 > Hi Anton,
12
13 > thank you very much ! :)
14
15 > Your solution creates the flat-hand-against-my-forehead
16 > effect... ;)
17
18 > Of course! Yes!
19
20 > Cheers!
21 > Meino
22
23
24
25 > On 10/31 07:37, Anton Molyboha wrote:
26 >> Hi, Meino
27 >>
28 >> I'd make a script, sudo_with_rehash:
29 >>
30 >> sudo "$@"
31 >> rehash
32 >>
33 >> and add to whatever is the equivalent of .bashrc for zsh:
34 >>
35 >> alias sudo="source sudo_with_rehash"
36 >>
37 >> Would that work for you?
38 >>
39 >> Best,
40 >> Anton
41 >>
42 >> On Wed, Oct 31, 2018 at 4:49 AM <tuxic@××××××.de> wrote:
43 >>
44 >> > Hi,
45 >> >
46 >> > often I have this scenario:
47 >> > I miss an application/script, a setting or something like that.
48 >> > To apply the modifikation I becom root from the shell I was using as user.
49 >> > I modificate/install or whatever change is needed...
50 >> > I CTRL-D back to my user shell.
51 >> >
52 >> > Now I have to do a "rehash" (I am using zsh) to make the change
53 >> > visible/accessible. Sometimes I forget that.
54 >> >
55 >> > So...is it possible to auto-execute a "rehash" or whatever is needed,
56 >> > when the user is comeing back from his alternate life as root?
57 >> >
58 >> > Thanks a lot for any help in advance!
59 >> > Cheers!
60 >> > Meino
61 >> >
62 >> >
63 >> >
64 >> >
65
66
67
68 --
69 Stefan Schmiedl
70 EDV-Beratung Schmiedl, Berghangstr. 5, 93413 Cham
71 Büro: +49 (0) 9971 9966 989, Mobil: +49 (0) 160 9981 6278

Replies

Subject Author
Re: [gentoo-user] Autoexecute when "returning" from sudo ? Grant Taylor <gtaylor@×××××××××××××××××××××.net>