unify home and etc dotfiles

This commit is contained in:
Diego Fernando Carrión 2024-09-29 16:11:19 +00:00 committed by Diego Ferando Carrión
parent 99f05cdbac
commit 6be4b3af24
Signed by: CRThaze
GPG Key ID: 8279B79A1A7F8194
110 changed files with 535 additions and 1 deletions

View File

@ -0,0 +1,3 @@
# run a script on lid open/close events
event=button/lid
action=/etc/acpi/lid.sh "%e"

19
_backup/.bak_acpi/acpi/lid.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
state=$(echo "$1" | cut -d " " -f 3)
case "$state" in
open)
# do what needs to be done when the lid is opened
if ! xbanish_loc="$(type -p "xbanish")" || [[ -z $xbanish_loc ]]
then
killall xbanish
xbanish &
fi
;;
close)
# do what needs to be done when the lid is closed
;;
*)
# panic: not a state I know about!
esac

108
etc/any/bash/bash.bashrc Normal file
View File

@ -0,0 +1,108 @@
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# case "$(basename $(tty))" in
# ttyS*|ttyUSB*|ttyACM*|ttyAMA)
# # Don't try to set the window title on serial ports
# shopt -u checkwinsize
# export TERM=vt220
# ;;
# esac
limited_terminal() {
case $TERM in
*-color*|*-256color*)
return 1
;;
*unicode*)
return 1
;;
dumb|linux|hurd|vt*|mach*|wsvt*|tmux*|cons25*|rxvt*|screen*|sun)
return 0
;;
*)
return 1
;;
esac
}
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, overwrite the one in /etc/profile)
# but only if not SUDOing and have SUDO_PS1 set; then assume smart user.
if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# ;;
#*)
# ;;
#esac
# enable bash completion in interactive shells
#if ! shopt -oq posix; then
# if [ -f /usr/share/bash-completion/bash_completion ]; then
# . /usr/share/bash-completion/bash_completion
# elif [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
#fi
# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ]
then
case " $(groups) " in *\ admin\ *|*\ sudo\ *)
if [ -x /usr/bin/sudo ]; then
cat <<-EOF
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
EOF
fi
esac
fi
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]
then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]
then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]
then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
}
fi
if [ -d /etc/bashrc.d ]; then
for i in /etc/bashrc.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
fi

View File

@ -0,0 +1,111 @@
function cl() {
cd $1
ls
}
function cll() {
cd $1
ls -l
}
function inline_exrc() {
local file_path="$1"
if [[ ! -f "$file_path" ]]; then
echo "File not found: $file_path"
return 1
fi
# Read the file and process it
local processed_content=$(sed '/^$/d; /^"/d' "$file_path" | tr '\n' '|')
# Remove the trailing |
processed_content=$(echo "$processed_content" | sed 's/|$//')
# Output the processed content
echo "$processed_content"
}
function whence() {
local print_links=false
local command=""
local batch=false
# Manual option parsing
for arg in "$@"; do
case "$arg" in
-p)
print_links=true
;;
-h)
tabs 2
echo "Usage:"
echo -e "\twhence [-q] [-p | -h] <command>"
echo -e "\t\t-h: Print Usage"
echo -e "\t\t-p: Print each symlink path"
echo -e "\t\t-b: Batch mode, only print paths"
tabs
return
;;
-b)
batch=true
;;
-*)
echo "Invalid option: $arg" >&2
return
;;
*)
command="$arg"
;;
esac
done
# Ensure a command was provided
if [[ -z "$command" ]]; then
echo "No command provided" >&2
return
fi
# Find the initial path using which
local original_path=$(which "$command" 2> /dev/null)
local path=$original_path
if [[ -z "$path" ]]; then
if (type -t "$command" >/dev/null)
then
type=$(type -t "$command")
echo "$command is a $type"
if [[ "$type" == "function" ]]
then
echo "Run: \`type $command\` to see its definition."
fi
return
else
echo "$command not found"
return
fi
fi
# Follow symlinks
while [[ -L "$path" ]]; do
if [[ "$print_links" == "true" ]]
then
if [[ "$batch" == "false" ]]
then
echo -ne "Link:\t\t"
fi
echo "$path -> $(readlink -f "$path")"
fi
path=$(readlink -f "$path")
done
if [[ "$batch" == "false" ]]
then
if [[ "$path" == "$original_path" ]]
then
echo -ne "Executable:\t"
else
echo -ne "Ultimate Exe:\t"
fi
fi
echo "$path"
}

View File

@ -0,0 +1,72 @@
alias mv="mv -iv"
alias cp="cp -riv"
alias mkdir="mkdir -vp"
alias red_october="ping -c1"
alias ro="red_october"
if [ -n "$DISPLAY" ]
then
alias clipboard="xclip -selection c -i"
alias cb="clipboard"
fi
if [ -f /usr/share/X11/locale/en_US.UTF-8/Compose ]
then
alias compose_ref="less /usr/share/X11/locale/en_US.UTF-8/Compose"
fi
# Editors
alias ed="ed -p': '"
if [ -x "$(command -v nvim)" ] && ! limited_terminal
then
vim_path="$(command -v vim)"
vimdiff_path="$(command -v vimdiff)"
if [ -x "$vim_path" ]
then
alias vvim="$vim_path"
fi
if [ -x "$vimdiff_path" ]
then
alias vvimdiff="$vimdiff_path"
fi
alias vim=nvim
alias vimdiff="nvim -d"
fi
if [[ "$(whence -b vi)" == "/usr/local/bin/ex" ]]
then
alias vi='EXINIT="$(inline_exrc $HOME/.exrc)" vi'
fi
if [ -x "$(command -v xdg-open)" ]
then
alias open="xdg-open"
fi
# cat && less
if ! limited_terminal && [[ -x "$(command -v batcat)" || -x "$(command -v bat)" ]]
then
if [ -x "$(command -v batcat)" ]
then
alias bat=batcat
fi
alias ccat="$(which cat)"
alias lless="$(which less)"
alias less=bat
alias cat=bat
fi
# ls
if ! limited_terminal
then
if [ -x "$(command -v lsd)" ]
then
alias lls="$(which ls)"
alias ls=lsd
else
alias ls='ls --color=auto'
fi
fi
alias la='ls -A'
alias ll='ls -lh'
alias lla='ls -lA'

View File

@ -0,0 +1,8 @@
if [ -x "$(which nvim)" ]
then
export EDITOR=nvim
export VISUAL=nvim
else
export EDITOR=vim
export VISUAL=vim
fi

View File

@ -0,0 +1,7 @@
# Enable Source Highlighting in less
LESSPIPE=/usr/bin/src-hilite-lesspipe.sh
if [ -x $LESSPIPE ]
then
export LESSOPEN="| ${LESSPIPE} %s"
export LESS=' -R '
fi

View File

@ -0,0 +1,89 @@
BASE_COLOR=4
[ "$(id -u)" -eq 0 ] && BASE_COLOR=1
REMOTE=false
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
REMOTE=true
else
case $(ps -o comm= -p $PPID) in
sshd|*/sshd) REMOTE=true;;
esac
fi
if [ $REMOTE = true ]
then
if [ -f /etc/nickname ]
then
NICK="$(cat /etc/nickname | tr '[:lower:]' '[:upper:]' | xargs echo)"
else
NICK="SSH"
fi
PREFIX="\[$(tput setaf $BASE_COLOR)\]\[$(tput bold)\][\[$(tput setaf 1)\]$NICK\[$(tput setaf $BASE_COLOR)\]]\[$(tput sgr0)\]"
else
PREFIX=
fi
prompt_cmd() {
EXITSTATUS=$?
tput bold
tput setaf $BASE_COLOR
echo -n "["
tput setaf 3
echo -n "$(date -u +%H:%M:%S) UTC"
tput setaf $BASE_COLOR
echo -n "]"
k8scontext=$(kubectl config current-context 2>/dev/null | perl -pe 's/\n$//')
if [ ! -z "$k8scontext" ]
then
tput setaf $BASE_COLOR
echo -n "["
tput setaf 2
echo -n "K8s: "
tput setaf 1
echo -n "$k8scontext"
tput setaf $BASE_COLOR
echo -n "]"
fi
awsprofile=$(aws-creds 2>/dev/null)
if [ ! -z "$awsprofile" ]
then
tput setaf $BASE_COLOR
echo -n "["
tput setaf 2
echo -n "AWS: "
tput setaf 1
echo -n "$awsprofile"
tput setaf $BASE_COLOR
echo -n "]"
fi
tput setaf 2
echo -n "["
if [[ $EXITSTATUS -eq 0 ]]
then
tput setaf 2
else
tput setaf 1
fi
echo -n "$EXITSTATUS"
tput setaf 2
echo -n "]"
branch=$(hg branch 2>/dev/null || git branch 2>/dev/null | grep "\*" | perl -pe 's/\* ([^(]\S+)|\* \(HEAD detached at (\S+)\)/\1\2/')
if [ ! -z "$branch" ]
then
echo
tput setaf $BASE_COLOR
echo -n "["
tput setaf 1
echo -n "$branch"
tput setaf $BASE_COLOR
echo -n "]"
fi
tput sgr0
echo
}
if ! limited_terminal
then
export PROMPT_COMMAND="prompt_cmd"
export PS1="$PREFIX\[$(tput setaf $BASE_COLOR)\]\[$(tput bold)\][\[$(tput setaf 1)\]\u\[$(tput setaf $BASE_COLOR)\]@\h \[$(tput setaf 3)\]\W\[$(tput setaf $BASE_COLOR)\]]\[$(tput setaf 1)\]\\$ \[$(tput sgr0)\]"
fi

View File

@ -0,0 +1,2 @@
# enable vi key navigation
set -o vi

27
etc/any/bash/profile Normal file
View File

@ -0,0 +1,27 @@
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "$(id -u)" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi

View File

@ -0,0 +1,22 @@
if (locale -a | grep -q en_US.iso88591)
then
case $TERM in
vt*)
export LANG=en_US.ISO-8859-1
export LANGUAGE=
export LC_CTYPE="en_US.ISO-8859-1"
export LC_NUMERIC="en_US.ISO-8859-1"
export LC_TIME="en_US.ISO-8859-1"
export LC_COLLATE="en_US.ISO-8859-1"
export LC_MONETARY="en_US.ISO-8859-1"
export LC_MESSAGES="en_US.ISO-8859-1"
export LC_PAPER="en_US.ISO-8859-1"
export LC_NAME="en_US.ISO-8859-1"
export LC_ADDRESS="en_US.ISO-8859-1"
export LC_TELEPHONE="en_US.ISO-8859-1"
export LC_MEASUREMENT="en_US.ISO-8859-1"
export LC_IDENTIFICATION="en_US.ISO-8859-1"
export LC_ALL=en_US.ISO-8859-1
;;
esac
fi

View File

@ -0,0 +1,2 @@
Ubuntu 22.04.4 LTS \n \l

View File

@ -0,0 +1 @@
Pop!_OS 22.04 LTS

View File

@ -0,0 +1 @@
Ubuntu 22.04.4 LTS

View File

@ -0,0 +1 @@
../serial-getty@ttyUSB0.service

View File

@ -0,0 +1,52 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Serial Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=https://0pointer.de/blog/projects/serial-console.html
BindsTo=dev-%i.device
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service
[Service]
# The '-o' option value tells agetty to replace 'login' arguments with an
# option to preserve environment (-p), followed by '--' for safety, and then
# the entered username.
# ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,57600,38400,9600 %I $TERM
# ExecStart=-/sbin/agetty -8 -o '-p -- \\u' %I 19200 vt220
ExecStart=/sbin/agetty -8 -L -h 19200 %I vt220
Environment=TERM=vt220
Type=idle
Restart=always
UtmpIdentifier=%I
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
IgnoreSIGPIPE=no
SendSIGHUP=yes
ImportCredential=agetty.*
ImportCredential=login.*
[Install]
WantedBy=getty.target

Some files were not shown because too many files have changed in this diff Show More