From cc8e82941800a8ebb8a59ab22987a41c5aaa9c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Fri, 7 Apr 2023 20:27:28 +0300 Subject: Use zsh config with root user as well --- dotfiles/.config/zsh/.zshrc | 10 ++++++++-- install-root-zsh.sh | 10 ++++++++++ root/.profile | 10 ++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100755 install-root-zsh.sh create mode 100644 root/.profile diff --git a/dotfiles/.config/zsh/.zshrc b/dotfiles/.config/zsh/.zshrc index aa1bc69..99ab1d1 100644 --- a/dotfiles/.config/zsh/.zshrc +++ b/dotfiles/.config/zsh/.zshrc @@ -6,8 +6,14 @@ precmd_vcs_info() { vcs_info } precmd_functions+=( precmd_vcs_info ) setopt prompt_subst -PROMPT=$'\n''%{%}%B%~ ${reset_color}%F{yellow}${vcs_info_msg_0_}%f'$'\n''%F{green}→%f ' -RPROMPT='%{%} %n%f@%F{red}%m%f' +if [ "$USER" = "root" ]; then + # Make it so that we display root's user@host on the left and colored red so + # that it is quite clear that we are under root. + PROMPT=$'\n''%{%}%B%~ ${reset_color}%F{yellow}${vcs_info_msg_0_}%f'$'\n''%F{red}%n%f@%F{red}%m%f %F{green}→%f ' +else + PROMPT=$'\n''%{%}%B%~ ${reset_color}%F{yellow}${vcs_info_msg_0_}%f'$'\n''%F{green}→%f ' + RPROMPT='%{%} %n%f@%F{red}%m%f' +fi zstyle ':vcs_info:git:*' formats ' %b' # Basic auto/tab complete: diff --git a/install-root-zsh.sh b/install-root-zsh.sh new file mode 100755 index 0000000..486001b --- /dev/null +++ b/install-root-zsh.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Make root use zsh and our zsh config, but with a slightly modified profile + +cp root/.profile /root/.profile +ln -s /root/.profile /root/.zprofile +mkdir -p /root/.config/zsh +ln -s $PWD/dotfiles/.config/zsh/.* /root/.config/zsh/ +ln -s $PWD/dotfiles/.config/zsh/* /root/.config/zsh/ + +chsh -s /bin/zsh root diff --git a/root/.profile b/root/.profile new file mode 100644 index 0000000..bb0f394 --- /dev/null +++ b/root/.profile @@ -0,0 +1,10 @@ +export LANG=en_US.UTF-8 +export TERMINAL=foot +export EDITOR="nvim" +export PAGER="less -R -j.5" +export MANPAGER='nvim +Man!' +export MANWIDTH=80 + +export LESSHISTFILE="-" +export ZDOTDIR="$HOME/.config/zsh" +export INPUTRC="$HOME/.config/zsh/inputrc" -- cgit v1.2.3