home · contact · privacy
Create new login/shell setup init script cascade. master
authorChristian Heller <c.heller@plomlompom.de>
Sat, 1 Mar 2025 09:32:56 +0000 (10:32 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 1 Mar 2025 09:32:56 +0000 (10:32 +0100)
testing/home/all/.bash_profile [new file with mode: 0644]
testing/home/all/.bashrc [new file with mode: 0644]
testing/home/all/.profile [new file with mode: 0644]
testing/home/desktop/.bashrc_bonus [new file with mode: 0644]

diff --git a/testing/home/all/.bash_profile b/testing/home/all/.bash_profile
new file mode 100644 (file)
index 0000000..316cf19
--- /dev/null
@@ -0,0 +1,8 @@
+# ~/.bash_profile, if it exists, is sourced by Bash for all login shells,
+# instead of ~/.profile
+#
+# While I prefer using ~/.profile, I provide ~/.bash_profile because some
+# applications write to it even if it does not previously exist, which
+# deactivates ~/.profile if not explicitly sourced from within here.
+. "${HOME}/.profile"
+
diff --git a/testing/home/all/.bashrc b/testing/home/all/.bashrc
new file mode 100644 (file)
index 0000000..001a880
--- /dev/null
@@ -0,0 +1,30 @@
+# ~/.bashrc is sourced by Bash for any interactive shells. 
+
+# Use vim as default editor for anything.
+export VISUAL=vim
+export EDITOR="${VISUAL}"
+
+# Some helpful aliases.
+alias curlpost='curl -H "Content-Type: application/json" -X POST'
+alias ls="ls --color=auto"
+alias sshauth='eval $(ssh-agent) && ssh-add'
+
+# Colored prompt with username, hostname, date/time, directory.
+COLOR_NUMBER=7  # default to white
+COLOR_NUMBER_FILE="${HOME}/.shell_prompt_color"
+[ -f "${COLOR_NUMBER_FILE}" ] && COLOR_NUMBER=`cat "${COLOR_NUMBER_FILE}"`
+tput_color="$(tput setaf "${COLOR_NUMBER}")$(tput bold)"
+tput_reset="$(tput sgr0)"
+# Bash confuses the line length when not told to not count escape sequences.
+if [ -n "${BASH}" ]; then
+    tput_color="\[$tput_color\]"
+    tput_reset="\[$tput_reset\]"
+fi
+PS1="${tput_color}["\$\(date\ +%Y-%m-%d/%H:%M:%S/%Z\)" $(whoami)@$(hostname):"\$\(pwd\)"]$ ${tput_reset}"
+PS2="${tput_color}> ${tput_reset}"
+PS3="${tput_color}select: ${tput_reset}"
+PS4="${tput_color}+ ${tput_reset}"
+
+# Optional additional stuff.
+PATH_BASHRC_BONUS="${HOME}/.bashrc_bonus"
+[ -f "${PATH_BASHRC_BONUS}" ] && . "${PATH_BASHRC_BONUS}"
diff --git a/testing/home/all/.profile b/testing/home/all/.profile
new file mode 100644 (file)
index 0000000..5a8ac46
--- /dev/null
@@ -0,0 +1,17 @@
+# ~/.profile is sourced on login, with its exports inherited by all processes
+# started below it under the same login, i.e. it has a very deep effect, but
+# changes to it only apply to new login sessions (compare to e.g. ~/.bashrc
+# which by is sourced anew for every new interactive Bash, login or not).
+#
+# Notably this makes ~/.profile (outside its optional sourcing of ~/.bashrc)
+# useful for providing environment variables to non-shell applications started
+# within a login session.
+
+PATH_BASHRC="${HOME}/.bashrc"
+[ -n "${BASH_VERSION}" -a -f "${PATH_BASHRC}" ] && . "${PATH_BASHRC}"
+
+PATH_LOCAL_BIN="${HOME}/.local/bin"
+[ -d "${PATH_LOCAL_BIN}" ] && PATH="${PATH_LOCAL_BIN}:${PATH}"
+
+# local changes to this shell variable otherwise will get lost
+export PATH
diff --git a/testing/home/desktop/.bashrc_bonus b/testing/home/desktop/.bashrc_bonus
new file mode 100644 (file)
index 0000000..b0419c2
--- /dev/null
@@ -0,0 +1,4 @@
+# mere "kb" might be more flexible, but this way I won't accidentally try for
+# a non-existing "en" layout
+alias kb_de="swaymsg input * xkb_layout de"
+alias kb_us="swaymsg input * xkb_layout us"