refactor(shell): nixify remaining shell config

This commit is contained in:
2026-09-28 20:58:46 +02:00
parent b2bd384d0e
commit 30dfcb6141
20 changed files with 155 additions and 295 deletions
-57
View File
@@ -1,57 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
alias ..="cd .."
alias ls="ls --color=auto"
alias l="ls -1p"
alias ll="ls -lhp"
alias lt="ls -lhtp"
alias la="ls -lhap"
alias lta="ls -lhatp"
alias ldir="ls -dp" # list directories
alias grep="grep --color=auto"
alias rm="rm -I --preserve-root"
alias mv="mv -iv"
alias cp="cp -iv"
alias ln="ln -i"
alias mkdir="mkdir -pv"
alias chown="chown --preserve-root"
alias chmod="chmod --preserve-root"
alias chgrp="chgrp --preserve-root"
alias ip="ip --color"
alias ipa="ip -brief address"
alias ipl="ip -brief link"
alias ipr="ip route"
alias df="df -kTh"
alias fzfpac="pacman -Slq | fzf -m --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S"
alias path='echo -e ${PATH//:/\\n}' # Pretty print path variables
# Programs
alias h="history"
alias o="xdg-open"
alias v="nvim"
alias vf="fzf --bind 'enter:become(nvim {})'"
alias g='git'
alias k="kubectl"
alias t='task'
alias tsh='tasksh'
alias z='zathura --fork'
alias f='fzf'
alias fm='pcmanfm &>/dev/null &'
alias mm='micromamba'
# Languages
alias r5="plt-r5rs --no-prim"
alias hs="ghci"
alias pl="swipl"
alias py="python"
alias r="R"
alias azerty="setxkbmap be"
alias qwerty="setxkbmap us"
alias cole="setxkbmap us -variant colemak"
-16
View File
@@ -1,16 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
reboot-to-windows ()
{
# Check if grub is installed by checking if the command exists, if it does
# not, then assume that the system is using systemd-boot
if grub-install --version &>/dev/null; then
windows_title=$(grep -i windows /boot/grub/grub.cfg | cut -d "'" -f 2)
sudo grub-reboot "$windows_title"
echo "Grub set to reboot to Windows"
else
sudo bootctl set-oneshot windows.conf
echo "Systemd set to reboot to Windows"
fi
}
-7
View File
@@ -1,7 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
source "$HOME/.bash_aliases/dualboot"
alias lm='ddcutil setvcp 10'
alias cuda-available='python -c "import torch; print(\"CUDA enabled:\", torch.cuda.is_available());"'
-6
View File
@@ -1,6 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
source "$HOME/.bash_aliases/dualboot"
alias lm='xbacklight -set'
-35
View File
@@ -1,35 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
alias js="node"
alias ts="ts-node"
yarn() {
if [[ -f "package-lock.json" ]]; then
echo "WARNING: package-lock.json exists"
read -p "Are you sure you want to run yarn? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
command yarn "$@"
else
echo "Aborted"
fi
else
command yarn "$@"
fi
}
npm() {
if [[ -f "yarn.lock" ]]; then
echo "WARNING: yarn.lock exists"
read -p "Are you sure you want to run npm? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
command npm "$@"
else
echo "Aborted"
fi
else
command npm "$@"
fi
}
-9
View File
@@ -1,9 +0,0 @@
# shellcheck shell=bash
# shellcheck disable=SC1090
[[ -f ~/.bashrc ]] && . ~/.bashrc
export _JAVA_AWT_WM_NONREPARENTING=1
if [[ -z "${DISPLAY}" ]] && [[ "${XDG_VTNR}" -eq 1 ]]; then
exec startx "$HOME/.config/X11/xinitrc" >& ~/.xsession-errors
fi
-76
View File
@@ -1,76 +0,0 @@
# shellcheck shell=bash
# shellcheck disable=SC1091,SC1090
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
. /etc/os-release
# Prompt configuration
[ -f "$HOME/.bashrc.d/prompt" ] && . "$HOME/.bashrc.d/prompt"
# Aliases {{{
# Load aliases dynamically
[ -f "$HOME/.bash_aliases/all" ] && . "$HOME/.bash_aliases/all"
[ -f "$HOME/.bash_aliases/hosts/$HOSTNAME" ] && . "$HOME/.bash_aliases/hosts/$HOSTNAME"
[ -f "$HOME/.bash_aliases/private" ] && . "$HOME/.bash_aliases/private"
[ -f "$HOME/.bash_aliases/lang-js" ] && . "$HOME/.bash_aliases/lang-js"
# Completions {{{
[ -d "$HOME/.bash_completions" ] && for file in "$HOME/.bash_completions"/*; do
[ -f "$file" ] && . "$file"
done
# }}}
# Host-specific and private configurations
[ -f "$HOME/.bashrc.d/hosts/$HOSTNAME" ] && . "$HOME/.bashrc.d/hosts/$HOSTNAME"
[ -f "$HOME/.bashrc.d/private" ] && . "$HOME/.bashrc.d/private"
# }}}
# Prompt {{{
[ -f "$HOME/.bashrc.d/prompt" ] && . "$HOME/.bashrc.d/prompt"
# }}}
# X11 {{{
export XDG_SESSION_TYPE=X11
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DATA_HOME=$HOME/.local/share
# }}}
# FZF {{{
# Check if fzf is installed
if [ -f "/usr/bin/fzf" ]; then
if [[ $ID == "raspbian" ]]; then
. /usr/share/doc/fzf/examples/completion.bash
. /usr/share/doc/fzf/examples/key-bindings.bash
elif [[ $ID == "arch" ]]; then
. /usr/share/fzf/completion.bash
. /usr/share/fzf/key-bindings.bash
fi
_fzf_setup_completion path vim zathura xournalpp nvim mpv
else
echo "fzf not installed"
fi
# }}}
# Jupyter {{{
export JUPYTERLAB_DIR=$HOME/.local/share/jupyter/lab
# }}}
# Conda {{{
[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && . /opt/miniconda3/etc/profile.d/conda.sh
# }}}
# Codi
# Usage: codi [filetype] [filename]
codi() {
local syntax="${1:-python}"
shift
nvim -c \
"let g:startify_disable_at_vimenter = 1 |\
set bt=nofile ls=0 noru nonu nornu |\
hi ColorColumn ctermbg=NONE |\
hi VertSplit ctermbg=NONE |\
hi NonText ctermfg=0 |\
Codi $syntax" "$@"
}
-1
View File
@@ -1 +0,0 @@
# Desktop configuration
-19
View File
@@ -1,19 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE="/usr/bin/micromamba";
export MAMBA_ROOT_PREFIX="/home/h/.local/share/micromamba";
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
if [ -f "/home/h/.local/share/micromamba/etc/profile.d/micromamba.sh" ]; then
. "/home/h/.local/share/micromamba/etc/profile.d/micromamba.sh"
else
export PATH="/home/h/.local/share/micromamba/bin:$PATH" # extra space after export prevents interference from conda init
fi
fi
unset __mamba_setup
# <<< mamba initialize <<<
-22
View File
@@ -1,22 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
get_branch_name() {
git symbolic-ref --quiet --short HEAD 2>/dev/null \
|| git rev-parse --short HEAD 2>/dev/null \
|| echo 'some branch'
}
get_git_info() {
git rev-parse --is-inside-work-tree &>/dev/null || return
echo -e "($(get_branch_name))"
}
if [[ $SSH_CONNECTION ]]; then
PS1='\[\033[01;31m\]\u@\h\[\033[00m\] $(get_git_info)\W❭\[$(tput sgr0)\] '
else
PS1='\u $(get_git_info)\W❭\[$(tput sgr0)\] '
fi
# Ellipsis when deep in directory
export PROMPT_DIRTRIM=2
export PS1
-33
View File
@@ -1,33 +0,0 @@
$include /etc/inputrc
set editing-mode vi
set keymap vi
set show-mode-in-prompt on
set vi-ins-mode-string "\1\e[1;32m\2■ \1\e[0m\2"
set vi-cmd-mode-string "\1\e[1;31m\2■ \1\e[0m\2"
set show-all-if-ambiguous on
set show-all-if-unmodified off
set completion-ignore-case on
set completion-map-case on
set completion-display-width 0
set page-completions off
set completion-query-items 128
set visible-stats on
set skip-completed-text on
set mark-symlinked-directories on
set colored-completion-prefix on
$if mode=vi
set keyseq-timeout 200
set keymap vi-command
"\e[A": history-search-backward
"\e[B": history-search-forward
j: history-search-forward
k: history-search-backward
set keymap vi-insert
"jj": vi-movement-mode
"\e[A": history-search-backward
"\e[B": history-search-forward
"\C-l": clear-screen
$endif