You are not logged in.

#1 2010-09-18 03:37:43

vi3dr0
Member
From: Poland
Registered: 2009-03-22
Posts: 208

[SOLVED] zsh config (.zshrc) no longer working for root.

Hi,

I must've done something stupid a while ago, cause whenever I sudo -s to get some root privilages it seems .zshrc is not read.

Prompt is default and aliases don't work.

Here's my .zshrc, just in case.  I'm quite sure it's okay.

##################################################
# OPTIONS FOR ZSH
#
#
#
# PS1=$'%(!.%{\e[0;31m%}#.%{\e[0;32m%}$)>_ %{\e[0m%}' # $>_ / #>_
#
PS1=$'%(!.%{\e[1;31m%}%{\e[5;31m%}>>>.%{\e[1;31m%}>%{\e[1;33m%}>%{\e[1;32m%}>) %{\e[0m%}' # >>> / >>>
RPS1=$'%{\e[0;33m%}[%~]%{\e[0m%}'
# RPROMPT=$'[~]'

export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/opt/mozilla/bin:$HOME/linux/bin:/opt/kde/bin:/opt/java/jre/bin:/usr/local/bin"
export EDITOR="vim"
export MANPATH="/usr/share/man:/usr/man"
export DE=kde
#export TERM=xterm-256color

# key bindings

bindkey -v

bindkey "^[[2~" overwrite-mode
bindkey "^[[3~" delete-char
bindkey "\e[7~" beginning-of-line
bindkey "\e[8~" end-of-line
bindkey "$(echotc kl)" backward-char
bindkey "\E[A" up-line-or-search 
bindkey "\E[B" down-line-or-search
bindkey '^R' history-incremental-search-backward
bindkey -M vicmd 'k' up-line-or-search 
bindkey -M vicmd 'j' down-line-or-search

HISTFILE=~/.zshhistory
HISTSIZE=50000
SAVEHIST=50000

# aliases

alias    ..='cd ..'
alias    cl='clear'
alias    ls='ls --color=auto'
alias    lsl='ls -hl --color=auto'
alias    rm='rm -v'
alias    pg='pgrep -lf'
alias    ka='killall -s 9'
alias    sus='sudo -s'
alias    hdtemp='sudo hddtemp /dev/sda'
alias    du="du -h"
alias    df="df -h"
alias   freq="cpufreq-info | grep decide"
alias   mpdkill="sudo mpd --kill && killall -s 9 mpdscribble"
alias   sudo="sudo "
alias   nc="ncmpcpp"
alias   cmatrix="cmatrix -abu2"
alias   x="startx"
alias   thinkpad-smapi="thinkpad-smapi -b 0"

alias   relap="sudo /etc/rc.d/laptop-mode restart"
alias   rewlan="sudo ifconfig wlan0 {down,up}"
alias   rentpd="sudo /etc/rc.d/openntpd restart"
alias   resamba="sudo /etc/rc.d/samba restart"
alias   recups="sudo /etc/rc.d/cups restart"
alias   reblue="sudo /etc/rc.d/bluetooth restart"

alias   fancool="/etc/rc.d/thinkfan stop && echo level 7 > /proc/acpi/ibm/fan"
alias   fanstart="sudo /etc/rc.d/thinkfan start"

# functions
fs() { find $1 -iname '*'$2'*'; }
gcurses() { gcc $1 -o $(cut -d . -f 1 $1) -lncurses;}
ranger () {
    command ranger --fail-unless-cd $@ &&
    cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)"
}


# completion
autoload -U compinit
compinit


# correction
setopt correctall

# prompt
# autoload -U promptinit
# promptinit
# prompt redhat
# options

setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt nohup               # don't kill bg jobs when tty quits
setopt nocheckjobs          # don't complain about background jobs on exit

#Some functions, like _apt and _dpkg, are very slow. You can use a cache in order to proxy the list of results (like the list of available debian packages) Use a cache:
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
#Prevent CVS files/directories from being completed:
zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
#Ignore completion functions for commands you don't have:
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
zstyle ':completion:*:processes-names' command 'ps -e -o comm='

Last edited by vi3dr0 (2010-09-19 15:10:41)


Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox

Offline

#2 2010-09-18 13:11:04

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED] zsh config (.zshrc) no longer working for root.

Do you have a .zshrc for root, or only for your user?

Last edited by Mr.Elendig (2010-09-18 13:11:28)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#3 2010-09-18 16:18:35

vi3dr0
Member
From: Poland
Registered: 2009-03-22
Posts: 208

Re: [SOLVED] zsh config (.zshrc) no longer working for root.

I never had one for root.

Maybe I'm getting the whole idea of using sudo wrong? I always used sudo -s when I needed root privileges for few things in a row, instead of putting sudo in every command. All my aliases, functions from ~/.zshrc were still working. Prompt also did change, as specified in this file.

Suddenly, some time ago it changed.

Last edited by vi3dr0 (2010-09-18 16:19:04)


Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox

Offline

#4 2010-09-18 21:56:59

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED] zsh config (.zshrc) no longer working for root.

When you sudo, you become root, so the PS1/PROMPT is read from /root/.zshrc (if it exists) instead of /home/youruser/.zshrc


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#5 2010-09-19 00:53:25

vi3dr0
Member
From: Poland
Registered: 2009-03-22
Posts: 208

Re: [SOLVED] zsh config (.zshrc) no longer working for root.

Makes sense. However I never had one in /root wink So why was it working earlier?


Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox

Offline

#6 2010-09-19 05:54:16

o1911
Member
From: Hobart, Australia
Registered: 2009-04-28
Posts: 106

Re: [SOLVED] zsh config (.zshrc) no longer working for root.

This took me a while to work out.  Put in your /etc/sudoers file this (using the command visudo):

Defaults !env_reset

I put this just under the "## Defaults specification" header, not that it should matter.  Let us know if it worked.


Arch x86_64

Offline

#7 2010-09-19 06:03:50

vi3dr0
Member
From: Poland
Registered: 2009-03-22
Posts: 208

Re: [SOLVED] zsh config (.zshrc) no longer working for root.

Indeed, it's just how it was. Thank you very much smile

I'm really curious, what has changed and when did it occur?


Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox

Offline

#8 2010-09-19 12:52:59

o1911
Member
From: Hobart, Australia
Registered: 2009-04-28
Posts: 106

Re: [SOLVED] zsh config (.zshrc) no longer working for root.

I think this was a pushed /etc/sudoers file that pacdiffviewer prompts you to replace with, maybe a month ago?  If you were like me, you probably only added yourself being able to sudo.  I don't have the old version, but I don't remember requiring the code I gave you... maybe they've changed something necessitating the new file.  Anyway, happy times, my prompt turns red when I 'sudo -s' smile


Arch x86_64

Offline

#9 2010-09-19 15:10:27

vi3dr0
Member
From: Poland
Registered: 2009-03-22
Posts: 208

Re: [SOLVED] zsh config (.zshrc) no longer working for root.

Well, actually now that you mentioned I remember that...

Thank you one more time wink


Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox

Offline

Board footer

Powered by FluxBB