Stuck on Zsh prompt

I'm really stuck. Harvesting my way through all the sources I've had the enlightened idea to make my prompt spit out a color that reflects about the owner of the current directory - such as green for owned, blue for foreign and red for root.
However - I dare not speak but cannot figure how to do that! --- I'd be glad to hear about suggestions where to look though.

What I figured out so far is to check whether I can read or write to the folder. So, currently I'm using that - plus that I'm using Asterisk's to color out access flags. What my vision implies is that I just get a colored line - which I got colored relative to the writable flag - to see more. I tend to play around with my filesystem a lot - and to see whether I own that folder or if it is just writable would make kindof an awesome treat. Anyhow - I got a bit further - but I can't figure it out.
What I'm using is [[ -w $PWD ]] - while here [http://zsh.sourceforge.net/Doc/Release/ … nsion.html] I read that this formula returns true if pwd is writable. Further down there is the s or f option which would return user specific information - but somehow it doesn't work out. I suppose that these are meant for something else - but I couldn't find anything else so far.

Similar Messages

  • Urxvt and zsh prompt

    Hello!
    I would like to run different instances of Urxvt using "-name", each one with a different zsh prompt.
    Is there any way to achieve this?
    "PROMPT=" works if urxvt is already open, but I can't seem to find a way to run it when it starts.
    Thanks.

    In bash you can update /home/user/.bashrc . I am not a zsh user but after a quick look at the man page there appears to be a .zshrc file that does the same.
    Hope this helps.

  • [Solved] Zsh prompt issues

    Hello,
    Ive recently restored my arch system from a backup due to some problems. However I am now having an issue with my zsh prompt.
    I have a .zshrc file in my home dir that was always obeyed by zsh before. Now when I log in the ~/.zshrc file is loaded because all my aliases still work but my prompt is not the one specified in ~/.zshrc file.
    If I copy ~/.zshrc to /etc/zsh/zshrc then the prompt is loaded along with all the other aliases etc.
    Can anyone suggest why this maybe as id like to keep the zsh settings on a per-user basis?
    Thanks
    EDIT: Sorry fixed by reinstalling zsh
    Last edited by ck3mp (2013-04-07 13:01:27)

    Not sure if this is directly relevant to your situation or not, but I encountered a very similar issue starting the other week; loading promptinit and selecting a theme would work, but setting a custom PS1= etc. through my ~/.zshrc no longer did, even though it was still being loaded. I similarly did not think to re-install the package, until I came across this thread. As part of doing so I had to remove several packages with a Zsh dependency. After re-installing Zsh, my normal PS1 etc. came back, but went away again after re-installing the other packages.
    In my case, it appears extra/grml-zsh-config was the culprit; this package adds a lengthy /etc/zsh/zshrc, and the behaviour occurs when that file is present. I couldn't say if this is a bug or just intended behaviour (indeed, I only had GRML-Zsh-Config installed as a dependency for another package); either way, once identified, workarounds became possible.
    Would be curious to know if this was also the case at your end (and if not, well... it seems there are a number of ways one can lose their Zsh prompt configuration!)

  • Multiline zsh prompt messes RPROMPT

    Hello,
    I have a multiline zsh prompt which is fine, but I'd like to add the hour in the RPROMPT. Unfortunately, the RPROMPT displays at the end of the second line of the prompt, whereas I want it at the first line. What I have looks like this:
    ~
    >>= archey 3:22
    And I would like this:
    ~ 3:22
    >>= archey
    So, I tried adding a control character to move the cursor up one line, but it still doesn't work. Before adding a control char:
    autoload -U colors && colors
    setopt prompt_subst
    PROMPT=$'%{$fg[blue]%}%~%{$reset_color%}
    %{$fg[red]%}>>=%{$reset_color%} '
    RPROMPT="%D{%L:%M:%S}"
    And after:
    autoload -U colors && colors
    setopt prompt_subst
    PROMPT=$'%{$fg[blue]%}%~%{$reset_color%}
    %{$fg[red]%}>>=%{$reset_color%} '
    RPROMPT="\033[1A%D{%L:%M:%S}"
    Could you help me sort this out ?
    Last edited by Mathuin (2014-04-23 14:36:57)

    You may want to move precmd() outside of the setprompt() function ...
    Also, there's no reason to create $PR_COLORS. ZSH supports %B...%b for bold and %F{color}...%f for foreground colors. If you're using a 256 color terminal, you can specify 001-255 in %F{}.
    Here is my prompt;
    setprompt () {
    # Need this so the prompt will work.
    setopt prompt_subst
    # see if we can use colors.
    autoload colors zsh/terminfo
    colors
    if [[ $UID == 0 ]] ; then
    PROMPT='[%B%F{red}%n%f%b@%F{green}%m%f:%y] %B%F{yellow}%~%f%b %# '
    else
    PROMPT='[%F{025}%n%f@%F{200}%m%f:%y] %B%F{035}%~%f%b %# '
    fi
    setprompt
    See also
    man zshall | less -p "Visual effects"

  • [SOLVED] Font problem. Zsh prompt shows strange characters.

    I am seeing strange characters in Zsh prompt only, bash works fine. I probably did not follow the font configuration section of Arch Beginner's Guide properly during installation. Earlier I had problems with login consoles too (tty2, tty3, all those black screens you can go to using CTRL+ALT+F2/F3 etc.) But I fixed those problems by creating /etc/vconsole.conf.
    Zsh problem still remains. I am using oh-my-zsh.
    I am out of ideas as to what to do. Please help.
    Last edited by Hindol (2013-04-23 08:37:47)

    What happens if you remove all the oh-my-zsh stuff?
    From your screenshot it looks like you are in X: you might want to change your thread title as it is a little misleading.
    Check your locale while you are at it.

  • Bash prompt vs Zsh prompt problem [SOLVED]

    I have set up my .zshrc and it works perfectly
    function bat1()
    echo $(( $(awk ' /remaining/ {print $3} ' /proc/acpi/battery/BAT0/state) * 100 / 71590 ))
    # 71590 is the capacity of my #1 bat in mWh
    function bat2()
    echo $(( $(awk ' /remaining/ {print $3} ' /proc/acpi/battery/BAT1/state) * 100 / 46620 ))
    # 46620 is the capacity of my #2 bat in mWh
    #Right-side zsh promp :
    RPROMPT=' $PR_RED$(bat1)/$(bat2)$PR_NO_COLOR'
    Each time I get a new prompt(when a command finishes or I simply type <Return>) the battery info is updated.
    Now let's consider bash :
    Same functions, same way of working :
    PS1="$(bat1)/$(bat2) >"
    The problem is that bash does not automatically update the battery info. I need to source my .bashrc, which is, of course, a real pain.
    Can any bash guru help me to find a solution to make bash work like zsh ?

    Try
    PS1="$(bat1)/$(bat2) >"

  • [SOLVED] zsh prompt colors misaligns the prompt

    Im using urxvt.
    For some reason, using colors in zsh somewhat screws up my prompt.
    In effect, the cursor ends up inside the left hand prompt (see screenhot).
    Also; the right hand prompt gets indented about 5 spaces to much from the right.
    This is my .zshrc:
    #open tmux on startup
    #[[ $TERM != "screen" ]] && tmux && exit
    autoload -Uz compinit
    compinit
    #zstyle ':completion*' menu select
    #setopt completealiases
    #autoload -U promptinit
    #promptinit
    autoload -U colors && colors
    function precmd () {
    local battp=$(ibam --percentbattery | grep % | awk '{print $3}')
    RPROMPT="[%~] [$battp]"
    PROMPT="[%n@%m:]$ "
    #keybindings
    bindkey "^[[7~" beginning-of-line # Home
    bindkey "^[[8~" end-of-line # End
    bindkey "^[[5~" history-beginning-search-backward # PageUp
    bindkey "^[[6~" history-beginning-search-forward # PageDown
    bindkey "^[[2~" quoted-insert # Ins
    bindkey "^[[3~" delete-char # Del
    bindkey "^[[1;5C" forward-word
    bindkey "\eOc" emacs-forward-word
    bindkey "^[[1;5D" backward-word
    bindkey "\eOd" emacs-backward-word
    bindkey "^[[Z" reverse-menu-complete # Shift+Tab
    HISTFILE=~/.histfile
    HISTSIZE=65536
    SAVEHIST=65000
    #aliases
    alias ls='ls --color=auto'
    alias df='df -hT'
    alias cl='clear'
    alias ll='ls -l'
    alias la='ls -A'
    alias free='free -m'
    alias wcu='wicd-curses'
    # The following lines were added by compinstall
    zstyle ':completion:*' completer _complete _ignored
    zstyle ':completion:*' file-sort name
    zstyle ':completion:*' format 'Completing %d'
    zstyle ':completion:*' list-colors ''
    zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[. -]=** r:|=**'
    zstyle ':completion:*' menu select=0
    zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
    zstyle ':completion:*' use-compctl false
    zstyle ':completion:*' verbose true
    zstyle :compinstall filename '/home/bladt/.zshrc'
    autoload -Uz compinit
    compinit
    # End of lines added by compinstall
    # Lines configured by zsh-newuser-install
    HISTFILE=~/.histfile
    HISTSIZE=10000
    SAVEHIST=15000
    bindkey -e
    # End of lines configured by zsh-newuser-install
    It seems to have been messed up a little by compinit, lets pretend that didn't happen
    (note that "autoload -U promptinit" and "promptinit" are commented out. This doesnt seem to change anything though)
    Last edited by Bladtman242 (2012-02-17 17:59:34)

    Well, yeah actually. It's the colours
    Adding a color in the left-hand prompt moves the right-hand prompt to far to the left.
    Adding a color to the right-hand prompt misplaces the cursor
    Any suggestions?
    EDIT: If I come across seeming a bit smug, it is unintended. Promise
    Last edited by Bladtman242 (2012-02-15 23:18:54)

  • Macbook Air Mid 2011 - Stuck in Grub Prompt

    Hi Archers,
    I am trying to install Arch on an Mid 2011 Macbook Air. So far it looks ok, I am following the Wiki and this guide. The bootloader stuff is confusing me a little. I do not want to replace the bootloader from OSx, so I do not use rEFInd, right? I want to use the "Press alt while booting"-method, so does the above guide.
    First problem:
    While generating the standalone "boot.efi" file the "-C" option is not recognized.
    grub-mkstandalone -o boot.efi -d usr/lib/grub/x86_64-efi -O x86_64-efi -C xz boot/grub/grub.cfg
    It complains that -C is not a valid parameter, so I just skipped it.
    After deleting the boot partition in OSx and creating the directories and files and copying the boot.efi file I am able to boot from this partition. Problem #2: After booting the partition I am stuck in a Grub prompt. It recognizes HD0 and 1 and after fiddling around with
    ls (hd0)
    ls (hd1)
    ls (hd0,4)
    It always complains about an unrecognized partition type.
    Any help appreciated. Will I get it working in this state?
    Booting from USB and installing the base system worked like a charm, I have a feeling I nearly got it but the bootloader stuff is just plain confusing.
    Thanks in advance.
    Last edited by Urfaust (2014-01-29 18:55:29)

    Ok, I cannot find another guide which uses the OSx Bootloader. I installed rEFInd, reformated /boot with mkfs.ext2, chrooted to the base system and:
    # pacman -S grub-efi-x86_64
    # mkdir -p /boot/efi
    # mount -t vfat /dev/sda1 /boot/efi
    # modprobe dm-mod
    # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug
    # mkdir -p /boot/grub/locale
    # cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
    The boot partition is recognized in rEFind, if I choose to boot from it Grub is firing up, I can see 2 menu entries (normal and fallback) after choosing the first I get:
    error: no such device: someUID
    Loading Linux core repo kernel ...
    error: no such partition
    Loading initial ramdiks ...
    unaligned pointer 0x22
    Aborted. Press any key to exit
    Why won't Grub find the partition?
    Last edited by Urfaust (2014-01-30 16:14:39)

  • [Solved] $LANG and zsh prompt color problems

    Hi,
    I recently discovered, trying to use Newsbeuter, that, in X, certain parts of my profile aren't set. Until now it only seemed to be $LANG, which is empty if I echo it from urxvt in XMonad, but yields the correct setting if I do the same in a tty.
    To make things worse now, my zsh seems to be acting up. I have differently colored prompts for my normal user and root. But since a few days ago, the root colors aren't applied unless I source .zshrc again after sudo-ing.
    I updated a lot recently and it's gotten hard to track these issues, especially the $LANG one, to a specific update. The only thing I know is that my desktop, running Kdemod, doesn't have these problems.
    I'm using Slim and XMonad. Neither issue is limited to a certain terminal.
    Most of my configs can be found in my GitHub dotfiles repository. If anything's missing to get a clear picture, ask for it.
    My rc.conf can be found here [Gist].
    Last edited by count-corrupt (2010-08-22 13:33:06)

    jac wrote:
    I finally went through the new sudoers file and got mine to work, see this thread for details. Using that, and using a workaround for libetc, your prompt works for me.
    You appear not to use libetc, but if you do and don't also have root set up to use libetc, you will need to create a link to/from ~/.zshrc from/to ~/.config/zshrc
    I actually just solved it in another way. Your original point, that sudo changed it's default behavior was the key. In the official zsh documentation somewhere it says that all settings that are wanted for root should be put into /root/.zshrc. I just did that and it works.
    Your solution works too by the way. Just enabling
    Defaults env_keep += "HOME"
    does the trick and also (logically) re-enables other things that I hadn't even realized were gone yet like syntax highlighting in vim. I guess I should read into the nature of said privilige escalation problems. Maybe there's a way to selectively keep parts of HOME.
    So thank you very much for the help.

  • Nexus 5010 Won't Load System Image - Stuck at Boot Prompt

    I have a 5010 that simply won't load any system image.  Loads the kickstart image just fine, but once at the Switch(boot)# prompt just give me garbage when I enter "load bootflash:n5000-uk9.5.1.3.N2.1b.bin
    Restarting system.
    Loader Version pr-1.3
    loader> dir
    bootflash:
      lost+found
      n5000-uk9-kickstart.5.2.1.N1.1b.bin
      n5000-uk9.5.2.1.N1.1b.bin
      n5000-uk9-kickstart.5.1.3.N2.1b.bin
      n5000-uk9.5.1.3.N2.1b.bin
    loader> show version
    Version is pr-1.3
    loader> boot fb
    Booting kickstart image: fb....
    Error 15: File not found
    loader> boot bootflash:n5000-uk9-kickstart.5.1.3.N2.1b.bin
    Booting kickstart image: bootflash:n5000-uk9-kickstart.5.1.3.N2.1b.bin....
    .................................Image verification OK
    ÿserial 00:04: unable to assign resources
    INIT: platform_type cmdline parameter not found. Asssuming Oregon.
    I2C - Mezz absent
    sprom_drv_init_platform: nuova_i2c_register_get_card_index
    Starting Nexus5010 POST...
      Executing Mod 1 1 SEEPROM Test......done
      Executing Mod 1 1 GigE Port Test.......done
      Executing Mod 1 1 Inband GigE Test.....done
      Executing Mod 1 1 NVRAM Test....done
      Executing Mod 1 1 PCIE Test...............................done
      Mod 1 1 Post Completed Successfully
      Mod 2 Post Completed Successfully
    POST is completed
    can't create lock file /var/lock/mtab~185: No such file or directory (use -n flag to override)
    nohup: redirecting stderr to stdout
    autoneg unmodified, ignoring
    autoneg unmodified, ignoring
    Checking all filesystems..... done.
    Warning: switch is starting up with default configuration
    Loading system software
    No system image
    INIT: Sending processes the TERM signal
    INIT: Sending processes the KILL signal
    Cisco Nexus Operating System (NX-OS) Software
    TAC support: http://www.cisco.com/tac
    Copyright (c) 2002-2012, Cisco Systems, Inc. All rights reserved.
    The copyrights to certain works contained in this software are
    owned by other third parties and used and distributed under
    license. Certain components of this software are licensed under
    the GNU General Public License (GPL) version 2.0 or the GNU
    Lesser General Public License (LGPL) Version 2.1. A copy of each
    such license is available at
    http://www.opensource.org/licenses/gpl-2.0.php and
    http://www.opensource.org/licenses/lgpl-2.1.php
    switch(boot)# dir
          16384  Jan 01 2005 20:57:47  lost+found/
       34349568  Jan 10 2005 20:05:23  n5000-uk9-kickstart.5.1.3.N2.1b.bin
       31642624  Jan 09 2005 04:23:49  n5000-uk9-kickstart.5.2.1.N1.1b.bin
      172705188  Jan 10 2005 20:34:02  n5000-uk9.5.1.3.N2.1b.bin
      173082673  Jan 09 2005 22:07:23  n5000-uk9.5.2.1.N1.1b.bin
    Usage for bootflash: filesystem
              0 bytes used
    2147483647 bytes free
    2147483647 bytes total
    switch(boot)# load bootflash:n5000-uk9.5.1.3.N2.1b.bin
    INIT: Sending processes the TERM signal
    INIT: (boot)#
    INIT: Sending processes the TERM signal
    INIT: Sending processes the KILL signal
    Cisco Nexus Operating System (NX-OS) Software
    TAC support: http://www.cisco.com/tac
    Copyright (c) 2002-2012, Cisco Systems, Inc. All rights reserved.
    The copyrights to certain works contained in this software are
    owned by other third parties and used and distributed under
    license. Certain components of this software are licensed under
    the GNU General Public License (GPL) version 2.0 or the GNU
    Lesser General Public License (LGPL) Version 2.1. A copy of each
    such license is available at
    http://www.opensource.org/licenses/gpl-2.0.php and
    http://www.opensource.org/licenses/lgpl-2.1.php
    switch(boot)#
    Any help greatly appreciated.

    Hi, I have the same problem as you.

  • Installed, but stuck at GRUB prompt

    After 4 tries, I have managed to install 0.8.  On the reboot, however, I only get as far as a "GRUB>" prompt. 
    If I put the install disk in the drive, enter "reboot" at the GRUB prompt, and choose the option "Run installed system (/boot on a separate partition)", I am able to get a login prompt and start what appears to be a functional (base) system. But I have clearly missed something in the installation.  I have a /boot/grub/menu.lst file; the noncommented lines are as follows:
    timeout 5
    default 0
    color light-blue/black light-cyan/blue
    # (0) Arch Linux
    title Arch Linux
    root (hd0,0)
    kernel /vmlinuz26 root=/dev/sda3 ro
    initrd /kernel26.img
    # (1) Arch Linux
    title Arch Linux Fallback
    root (hd0,0)
    kernel /vmlinuz26 root=/dev/sda3 ro
    initrd /kernel26-fallback.img
    kernel26.img and kernel26-fallback.img are both in the /boot directory.
    What do I need to fix to make the system boot without a rescue disk?

    If you indeed have a boot partition on first partition of first drive (hd0,0; sda1) and a root one on third partition of a first drive (sda3), then your grub config seems to be alright. The example above is appropriate if there's no separate /boot partition.
    When you're in a GRUB prompt, try entering those root/kernel/initrd lines by hand and check the output.
    Last edited by lucke (2007-04-08 15:51:32)

  • Help Please, forgot my new   admin password..  so im stuck at password prompts.. any ideas to retireve it or make a new one?

    I went to turn off file vault andafter much prompting i had to change my password to login. After trying to use the new password i made it turns out it isnt correct...
    i know i did something wrong in the process..any ideas?

    Hi R%%^Y,
    Since you changed your admin password via the Install disc, your keychain passwod is stil set to the old one. You need to make the keychain password the same as your login password.
    First, try opening Keychain First Aid by opening Keychain Access and going to Keychain Access (right next to the Apple menu) and coming down to Keychain First Aid.
    Click Verify and see what happends. If it comes up with issues, hit the repair button.
    if for some reason, you can't repair it, take a look at keychain Access asks for keychain "login" after changing login password.
    Hope this helps and let me know how it goes.

  • Stuck at grub prompt

    Hi, i'm new to solaris and am trying to install it on my pc.
    I downloaded bot the a and b dvd images and burned them to disc
    I then put the disk in and start up, I see:
    Loading stage2...
    Then I see:
    GNU GRUB version 0.95
    [some stuff here about minimal BASH-like line editing]
    grub>
    Now what do I do?
    I tried typing install but that was unrecognised.. What do i need to type to start the install process?

    The 'a' and 'b' files need to be combined into one ISO file. You can do it like this:
    % for i in sol-10-u4-ga-x86-dvd-iso-?.zip; do unzip -p $i; done > sol-10-u4-ga-x86-dvd.iso
    Alternatively, if you've already unzipped the files, you can make one file like this:
    % cat sol-10-u4-ga-x86-dvd-iso-? > sol-10-u4-ga-x86-dvd.iso
    Then, burn the resulting ISO and boot off of it.

  • [SOLVED] help converting bash PS1 prompt to zsh PS1 prompt

    I guess they don't use the same syntax because simply copying it over to my zshrc does not work... it literally changes my prompt to the exact string of backlslashes etc
    If anyone can help me convert the following to zsh syntax I would be much in their debt:
        PS1="$TITLEBAR [\[\e[37m\]\u\[\e[31m\]@\[\e[37m\]\h\[\e[0m\]:\[\e[33m\]\w\[\e[0m\]] \$ ${NONE}"
    full bit copied from some thread in this forums... it had served me well
    bash_prompt() {
    case $TERM in
    xterm*|rxvt*)
    local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'
    local TITLEBAR=""
    esac
    local NONE="\[\033[0m\]" # unsets color to term's fg color
    # regular colors
    local K="\[\033[0;30m\]" # black
    local R="\[\033[0;31m\]" # red
    local G="\[\033[0;32m\]" # green
    local Y="\[\033[0;33m\]" # yellow
    local B="\[\033[0;34m\]" # blue
    local M="\[\033[0;35m\]" # magenta
    local C="\[\033[0;36m\]" # cyan
    local O="\[\033[0;37m\]" # orange
    local W="\[\033[0;38m\]" # white
    # emphasized (bolded) colors
    local EMK="\[\033[1;30m\]"
    local EMR="\[\033[1;31m\]"
    local EMG="\[\033[1;32m\]"
    local EMY="\[\033[1;33m\]"
    local EMB="\[\033[1;34m\]"
    local EMM="\[\033[1;35m\]"
    local EMC="\[\033[1;36m\]"
    local EMW="\[\033[1;37m\]"
    # background colors
    local BGK="\[\033[40m\]"
    local BGR="\[\033[41m\]"
    local BGG="\[\033[42m\]"
    local BGY="\[\033[43m\]"
    local BGB="\[\033[44m\]"
    local BGM="\[\033[45m\]"
    local BGC="\[\033[46m\]"
    local BGW="\[\033[47m\]"
    local UC=$W # user's color
    [ $UID -eq "0" ] && UC=$R # root's color
    PS1="$TITLEBAR [\[\e[37m\]\u\[\e[31m\]@\[\e[37m\]\h\[\e[0m\]:\[\e[33m\]\w\[\e[0m\]] \$ ${NONE}"
    #PS1="$TITLEBAR ${EMK}[${UC}\u${EMK}@${UC}\h ${EMB}\${NEW_PWD}${EMK}]${UC}\\$ ${NONE}"
    # without colors: PS1="[\u@\h \${NEW_PWD}]\\$ "
    # extra backslash in front of \$ to make bash colorize the prompt
    PROMPT_COMMAND=bash_prompt_command
    bash_prompt
    unset bash_prompt
    Last edited by ugkbunb (2009-09-04 17:56:55)

    If it spits out errors you should read them.. They generally tell you what the script expects. I saved your prompt in test and passed it to the script:
    $ perl tozsh.pl test && rm test
    # Converted to zsh prompt theme by bash2zshprompt, written by <[email protected]>
    [%{$fg[white]%}%n%{$fg[red]%}@%{$fg[white]%}%m%{$reset_color%}:%{$fg[yellow]%}%~%{$reset_color%}] \

  • [zsh] phil's prompt, incorrect terminal width

    Hi,
    so, I recently discovered phil's zsh prompt and it works fine when i start the terminal and then source the file in which i saved the prompt functions.
    But when i put the prompt functions directly into my .zshrc or let my .zshrc source the prompt file at startup, it doesn't calculate the terminal width correctly.
    Where's the problem?
    Greets,
    demian
    Last edited by demian (2010-07-02 08:46:24)

    See this thread

Maybe you are looking for