Rework shell

This commit is contained in:
LinuxSquare 2023-09-29 17:53:55 +02:00
parent 5f1a9e63ba
commit 600732234b
5 changed files with 41 additions and 76 deletions

View file

@ -1,6 +1,4 @@
{% set noveria = {
'bin_dir': '/usr/local/noveria/bin',
'app_dir': '/usr/local/noveria/apps',
'commonrc_dir': '/etc/commonrc.d',
'zsh_dir': '/etc/zsh.d'
'app_dir': '/usr/local/noveria/apps'
} %}

View file

@ -1,21 +0,0 @@
# This is the global common rc file sourced by all shells. This is not
# something the shells do natively, we just source this file in the appropriate
# places (/etc/bash.bashrc for bash, /etc/.zshrc for zsh). This file is intended
# for basic stuff that works in all shells, like env vars and aliases.
#
# Notes:
# - The code must be able to run in all shells, so keep it simple
# - Keep in mind that what's put in here affects all users on the system
# add custom bin to PATH variable
export PATH="${PATH}:{{ CUSTOM_BIN }}"
# source files from {{ COMMONRC_DIR }}
# use ls in a subshell because zsh will warn about an emtpy glob result by
# default. there's a glob flag to avoid that, but that would be zfs specific.
if [ -d {{ COMMONRC_DIR }} ]; then
for i in $(ls {{ COMMONRC_DIR }}/); do
[ -r "{{ COMMONRC_DIR }}/$i" ] && . "{{ COMMONRC_DIR }}/$i"
done
unset i
fi

View file

@ -1,13 +0,0 @@
# zsh keys configuration
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[2~" overwrite-mode
bindkey "^[[3~" delete-char
bindkey "^[[A" up-line-or-history
bindkey "^[[B" down-line-or-history
bindkey "^[[D" backward-char
bindkey "^[[C" forward-char
bindkey "^[[1;5D" backward-word
bindkey "^[[1;5C" forward-word
bindkey "^[[5~" beginning-of-buffer-or-history
bindkey "^[[6~" end-of-buffer-or-history

View file

@ -0,0 +1,34 @@
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ CUSTOM_BIN }}"
export PAGER=less
export EDITOR=vim
umask 022
# use nicer PS1 for bash and busybox ash
if [ -n "$BASH_VERSION" -o "$BB_ASH_VERSION" ]; then
PS1='\h:\w\$ '
# use nicer PS1 for zsh
elif [ -n "$ZSH_VERSION" ]; then
PS1='%m:%~%# '
# set up fallback default PS1
else
: "${HOSTNAME:=$(hostname)}"
PS1='${HOSTNAME%%.*}:$PWD'
[ "$(id -u)" -eq 0 ] && PS1="${PS1}# " || PS1="${PS1}\$ "
fi
if [ -n "$BASH_VERSION" ] && [ "$BASH" != "/bin/sh" ]; then
# if we're bash (and not /bin/sh bash), also source the bashrc
# by default, bash sources the bashrc for non-login,
# and only /etc/profile on login (-l). so, make it do both on login.
# this ensures that login-shell bash (e.g. -bash or bash -l) still sources the
# system bashrc, which e.g. loads bash-completion
. /etc/bash/bashrc
fi
for script in /etc/profile.d/*.sh ; do
if [ -r "$script" ] ; then
. "$script"
fi
done
unset script

View file

@ -7,25 +7,25 @@ system_shell_pkgs:
pkg.installed:
- pkgs:
- zsh
- alpine-zsh-config
- bash
- require:
- system_base_pkgs
system_shell_commonrc:
system_shell_profile:
file.managed:
- name: /etc/commonrc
- source: salt://{{ tpldir }}/files/shell_commonrc.jinja
- name: /etc/profile
- source: salt://{{ tpldir }}/files/shell_profile.jinja
- template: jinja
- context:
CUSTOM_BIN: {{ noveria.bin_dir }}
COMMONRC_DIR: {{ noveria.commonrc_dir }}
- user: root
- group: root
- mode: '0644'
- require:
- system_shell_pkgs
system_shell_zsh_include_commonrc:
system_shell_zsh_include_profile:
file.managed:
- name: /etc/.zshrc
- source: salt://{{ tpldir }}/files/shell_zshrc.jinja
@ -37,37 +37,4 @@ system_shell_zsh_include_commonrc:
- mode: '0644'
- makedirs: false
- require:
- system_shell_commonrc
system_shell_zsh_zshenv:
file.managed:
- name: /etc/.zshenv
- source: salt://{{ tpldir }}/files/shell_zshenv.jinja
- template: jinja
- user: root
- group: root
- mode: '0644'
- makedirs: false
- require:
- system_shell_commonrc
system_shell_zshd_directory:
file.directory:
- name: {{ noveria.zsh_dir }}
- user: root
- group: root
- dir_mode: '0755'
- file_mode: '0644'
- makedirs: true
- require:
- system_shell_pkgs
system_shell_zsh_keybinds:
file.managed:
- name: {{ noveria.zsh_dir }}/00-keybinds
- source: salt://{{ tpldir }}/files/shell_keybinds
- user: root
- group: root
- mode: '0644'
- require:
- system_shell_zshd_directory
- system_shell_profile