1 minute read

  1. append to .zshrc in home folder to import file:
    $ vim ~/.zshrc
    ...
    source .zshrc-prompt
  2. create .zshrc-prompt in home dir:
    [code language="bash" collapse="true" title="~/.zshrc-prompt"]
    $ cat .zshrc-prompt
    # Prompt format: [USER@MACHINE:DIRECTORY] [TIME] \n →;

    # create bold fonting+color
    PROMPT="%{$terminfo[bold]$fg[green]%}[%{$fg[yellow]%}"

    # username@MACHINE:
    # %n username
    # %M machine
    PROMPT="$PROMPT%n@%M:"

    # directory
    # %~ directory and $HOME is repalced by ~
    PROMPT="$PROMPT$fg[blue]%}%~"

    # color stuff
    PROMPT="$PROMPT%{$fg[green]%}]%{$reset_color%}"

    # add time
    PROMPT="$PROMPT%{$terminfo[bold]$fg[black]%} [%*]"

    # add 2nd line
    PROMPT="$PROMPT
    %{$terminfo[bold]$fg[white]%}→ %{$reset_color%}"
    [/code]

  3. do same for root (same as (1)):
    $ vim /root/.zshrc
    ...
    source .zshrc-prompt
  4. similar to (2):
    [code language="bash" collapse="true" title="/root/.zshrc-prompt" highlight="2,5,24"]
    $ cat /root/.zshrc-prompt
    # Prompt format: [USER@MACHINE:DIRECTORY] [TIME] \n #;

    # create bold fonting+color
    PROMPT="%{$terminfo[bold]$fg[green]%}[%{$fg[red]%}"

    # username@MACHINE:
    # %n username
    # %M machine
    PROMPT="$PROMPT%n@%M:"

    # directory
    # %~ directory and $HOME is repalced by ~
    PROMPT="$PROMPT$fg[blue]%}%~"

    # color stuff
    PROMPT="$PROMPT%{$fg[green]%}]%{$reset_color%}"

    # add time
    PROMPT="$PROMPT%{$terminfo[bold]$fg[black]%} [%*]"

    # add 2nd line
    PROMPT="$PROMPT
    %{$terminfo[bold]$fg[red]%}# %{$reset_color%}"
    [/code]