add ~/.bash*
This commit is contained in:
parent
f38125626a
commit
f6485eb7e4
12 changed files with 1115 additions and 0 deletions
14
home/bash.nix
Normal file
14
home/bash.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{ config, pkgs, ... }:
|
||||
{
|
||||
home.file.".bash_aliases".source = files/bash_aliases;
|
||||
home.file.".bash_functions".source = files/bash_functions;
|
||||
home.file.".bash_hosts".source = files/bash_hosts;
|
||||
home.file.".bash_keychain".source = files/bash_keychain;
|
||||
home.file.".bash_logout".source = files/bash_logout;
|
||||
home.file.".bash_motd".source = files/bash_motd;
|
||||
home.file.".bash_motd_ownscript.sh".source = files/bash_motd_ownscript.sh;
|
||||
home.file.".bash_profile".source = files/bash_profile;
|
||||
home.file.".bashrc".source = files/bashrc;
|
||||
home.file.".bash_ssh".source = files/bash_ssh;
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
home-manager.useUserPackages = true;
|
||||
home-manager.users.don = {
|
||||
imports = [
|
||||
./bash.nix
|
||||
./packages-cli.nix
|
||||
./packages-gui.nix
|
||||
./services.nix
|
||||
|
|
|
|||
29
home/files/bash_aliases
Executable file
29
home/files/bash_aliases
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
alias x="myX"
|
||||
alias build='xmessage -buttons okay:0 -default okay "`hostname -s`: Build in `pwd` completed at `date`" || xmessage -buttons okay:0 -default okay "`hostname -s`: Build in `pwd` failed at `date`"'
|
||||
alias tbuild='/usr/share/doc/Xdialog-2.0.6/samples/Xmessage "Build in `pwd` completed at `date`" || /usr/share/doc/Xdialog-2.0.6/samples/Xmessage "Build in `pwd` failed at `date`"'
|
||||
alias mroe=more
|
||||
alias moer=more
|
||||
alias ls="ls -hCF"
|
||||
alias l="ls -l"
|
||||
alias df="df -h -x squashfs"
|
||||
alias du="du -h"
|
||||
if [ -x /home/don/.local/bin/dotdrop ]
|
||||
then
|
||||
alias dotdrop="/home/don/.local/bin/dotdrop -c ~/.dotfiles/config.yaml"
|
||||
else
|
||||
alias dotdrop="/usr/bin/dotdrop -c ~/.dotfiles/config.yaml"
|
||||
fi
|
||||
test -x /usr/bin/bat && alias cat='bat'
|
||||
alias ip='COLORFGBG=";0" ip -c '
|
||||
|
||||
# Taskwarrior
|
||||
alias t=task
|
||||
alias ttoday="task +TODAY or +OVERDUE -BLOCKED"
|
||||
alias ttom="task +OVERDUE or +TOMORROW -BLOCKED"
|
||||
alias to="task list +OVERDUE"
|
||||
alias turl="task nnext | urlview"
|
||||
alias tfollow="task list +followup"
|
||||
alias tnext="task list +nextactions"
|
||||
alias open=xdg-open
|
||||
alias tt=timew
|
||||
alias top=btop
|
||||
203
home/files/bash_functions
Executable file
203
home/files/bash_functions
Executable file
|
|
@ -0,0 +1,203 @@
|
|||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: .bash_functions
|
||||
#
|
||||
# USAGE: source ~/.bash_functions
|
||||
#
|
||||
# DESCRIPTION: bash functions for interactive shell
|
||||
#
|
||||
# OPTIONS: ---
|
||||
# REQUIREMENTS: ---
|
||||
# BUGS: ---
|
||||
# NOTES: ---
|
||||
# AUTHOR: Don Harper (), duckunix@gmail.com
|
||||
# COMPANY: Don Harper
|
||||
# VERSION: 1.2
|
||||
# CREATED: 06/11/2007 11:17:14 PM CDT
|
||||
# REVISION: ---
|
||||
#===============================================================================
|
||||
|
||||
function nssh ()
|
||||
{
|
||||
. ~/.bash_ssh
|
||||
ssh-keygen -R "${1}"
|
||||
ssh "${@}"
|
||||
}
|
||||
|
||||
function ss ()
|
||||
{
|
||||
tmux neww -n "${1}" ". ~/.bash_ssh ; ssh ${*}"
|
||||
}
|
||||
|
||||
function mss ()
|
||||
{
|
||||
tmux neww -n "${1}" ". ~/.bash_ssh ; mosh ${*}"
|
||||
}
|
||||
|
||||
function nss ()
|
||||
{
|
||||
ssh-keygen -R "${1}"
|
||||
tmux neww -n "${1}" ". ~/.bash_ssh ; ssh ${*}"
|
||||
}
|
||||
|
||||
function pss ()
|
||||
{
|
||||
tmux split-window -h ". ~/.bash_ssh ; ssh ${*}"
|
||||
}
|
||||
|
||||
function pnss ()
|
||||
{
|
||||
ssh-keygen -R "${1}"
|
||||
tmux split-window -h ". ~/.bash_ssh ; ssh ${*}"
|
||||
}
|
||||
|
||||
function yay ()
|
||||
{
|
||||
echo "$(pwd) : yay $*" | plod
|
||||
unset LOGFILE
|
||||
/usr/bin/yay "$@"
|
||||
}
|
||||
|
||||
function doas ()
|
||||
{
|
||||
echo "$(pwd) : doas $*" | plod
|
||||
unset LOGFILE
|
||||
/usr/bin/env doas "$@"
|
||||
}
|
||||
|
||||
function sudo ()
|
||||
{
|
||||
echo "$(pwd) : sudo $*" | plod
|
||||
unset LOGFILE
|
||||
/usr/bin/env sudo "$@"
|
||||
}
|
||||
|
||||
function pushnew ()
|
||||
{
|
||||
plod Pushing configs to "${1}"
|
||||
cd "${HOME}" || exit
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
echo "usage: pushnew <host> <user>"
|
||||
return
|
||||
fi
|
||||
if [ -z "${2}" ]
|
||||
then
|
||||
echo "usage: pushnew <host> <user>"
|
||||
return
|
||||
fi
|
||||
ssh-copy-id "${2}"@"${1}"
|
||||
ssh "${2}"@"${1}" mkdir -p .ssh Nextcloud/bin Nextcloud/lib Nextcloud/dotfiles .config
|
||||
scp .ssh/{authorized_keys,config,id_*} "${2}"@"${1}":.ssh
|
||||
scp -r .dotfilesrc .myapps .tmux.conf "${2}"@"${1}":
|
||||
ssh "${2}"@"${1}" which rsync
|
||||
if [ $? == 1 ]
|
||||
then
|
||||
echo "${1} needs rsync. Press enter when installed"
|
||||
read foo
|
||||
fi
|
||||
rsync -avt .config/polybar "${2}"@"${1}":.config
|
||||
rsync -avt Nextcloud/bin "${2}"@"${1}":Nextcloud
|
||||
rsync -avt Nextcloud/lib "${2}"@"${1}":Nextcloud
|
||||
rsync -avt Nextcloud/dotfiles "${2}"@"${1}":Nextcloud
|
||||
rsync -avt Nextcloud/sigs "${2}"@"${1}":Nextcloud
|
||||
rsync -avt Nextcloud/ansible "${2}"@"${1}":Nextcloud
|
||||
ssh "${2}"@"${1}" 'for dir in bin lib web sigs ansible; do ln -s ${HOME}/Nextcloud/${dir} ${HOME}/${dir};done'
|
||||
}
|
||||
|
||||
function crontab ()
|
||||
{
|
||||
CRONFILE=$HOME/lib/crontab/$HOSTNAME_SHORT
|
||||
if which fcrontab > /dev/null 2>&1
|
||||
then
|
||||
CTEXEC=$(which fcrontab)
|
||||
elif which crontab > /dev/null 2>&1
|
||||
then
|
||||
CTEXEC=$(which crontab)
|
||||
fi
|
||||
case "${1}" in
|
||||
-e)
|
||||
"${CTEXEC}" -e ; "${CTEXEC}" -l >| "${CRONFILE}"
|
||||
;;
|
||||
*)
|
||||
cat "${CRONFILE}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
function add_cxoffice_path ()
|
||||
{
|
||||
if test -d ~/.cxoffice
|
||||
then
|
||||
OLDLANG=$LANG
|
||||
export LANG=C
|
||||
for cxdir in ~/.cxoffice/[A-Za-z]*/{desktopdata/cxmenu/StartMenu*/Programs,drive_c/users/*/Start*/Programs}
|
||||
do
|
||||
for dir in $(find "$cxdir" -type f -exec dirname {} \;)
|
||||
do
|
||||
buildpath PATH "$dir"
|
||||
done
|
||||
done
|
||||
export LANG=$OLDLANG
|
||||
fi
|
||||
}
|
||||
|
||||
cd_func ()
|
||||
{
|
||||
local x2 the_new_dir adir index
|
||||
local -i cnt
|
||||
|
||||
if [[ "${1}" == "--" ]]; then
|
||||
dirs -v
|
||||
return 0
|
||||
fi
|
||||
|
||||
the_new_dir="${1}"
|
||||
[[ -z "${1}" ]] && the_new_dir=$HOME
|
||||
|
||||
if [[ ${the_new_dir:0:1} == '-' ]]; then
|
||||
#
|
||||
# Extract dir N from dirs
|
||||
index=${the_new_dir:1}
|
||||
[[ -z $index ]] && index=1
|
||||
adir=$(dirs +$index)
|
||||
[[ -z $adir ]] && return 1
|
||||
the_new_dir=$adir
|
||||
fi
|
||||
|
||||
#
|
||||
# '~' has to be substituted by ${HOME}
|
||||
[[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
|
||||
|
||||
#
|
||||
# Now change to the new dir and add to the top of the stack
|
||||
pushd "${the_new_dir}" > /dev/null
|
||||
[[ $? -ne 0 ]] && return 1
|
||||
the_new_dir=$(pwd)
|
||||
|
||||
#
|
||||
# Trim down everything beyond 11th entry
|
||||
popd -n +21 2>/dev/null 1>/dev/null
|
||||
|
||||
#
|
||||
# Remove any other occurence of this dir, skipping the top of the stack
|
||||
for ((cnt=1; cnt <= 20; cnt++)); do
|
||||
x2=$(dirs +${cnt} 2>/dev/null)
|
||||
[[ $? -ne 0 ]] && return 0
|
||||
[[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
|
||||
if [[ "${x2}" == "${the_new_dir}" ]]; then
|
||||
popd -n +$cnt 2>/dev/null 1>/dev/null
|
||||
cnt=$((cnt-1))
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
alias cd=cd_func
|
||||
|
||||
tgrep ()
|
||||
{
|
||||
task info ${*} | egrep '(Parent|Due|Last)'
|
||||
}
|
||||
1
home/files/bash_hosts
Executable file
1
home/files/bash_hosts
Executable file
|
|
@ -0,0 +1 @@
|
|||
${1}
|
||||
1
home/files/bash_keychain
Executable file
1
home/files/bash_keychain
Executable file
|
|
@ -0,0 +1 @@
|
|||
test -x /usr/local/bin/keychain && /usr/local/bin/keychain -q ~/.ssh/id_dsa && . ~/.keychain/$HOSTNAME-sh
|
||||
11
home/files/bash_logout
Executable file
11
home/files/bash_logout
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
# ~/.bash_logout: executed by bash(1) when login shell exits.
|
||||
|
||||
# when leaving the console clear the screen to increase privacy
|
||||
|
||||
if [ "$SHLVL" = 1 ]; then
|
||||
if [ -x /usr/bin/clear_console ]; then
|
||||
/usr/bin/clear_console -q
|
||||
else
|
||||
clear
|
||||
fi
|
||||
fi
|
||||
617
home/files/bash_motd
Normal file
617
home/files/bash_motd
Normal file
|
|
@ -0,0 +1,617 @@
|
|||
#!/bin/sh
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
|
||||
BAR_ELEMENT="-"
|
||||
BAR_HEALTHY_COLOR="32"
|
||||
BAR_WARNING_THRESHOLD=70
|
||||
BAR_WARNING_COLOR="33"
|
||||
BAR_CRITICAL_THRESHOLD=90
|
||||
BAR_CRITICAL_COLOR="31"
|
||||
|
||||
BANNER_KERNEL_ICON="#"
|
||||
BANNER_KERNEL_COLOR="33"
|
||||
BANNER_UPTIME_ICON="#"
|
||||
BANNER_UPTIME_COLOR="94"
|
||||
BANNER_DEBIAN_ICON="#"
|
||||
BANNER_DEBIAN_COLOR="95"
|
||||
BANNER_FEDORA_ICON="#"
|
||||
BANNER_FEDORA_COLOR="34"
|
||||
BANNER_ARCH_ICON="#"
|
||||
BANNER_ARCH_COLOR="95"
|
||||
BANNER_FONTPATH="standard"
|
||||
BANNER_TEXT="$(hostnamectl | awk -F: '$1=/Static hostname/{print $2}' | sed 's/^ //')"
|
||||
|
||||
PROCESSOR_LOADAVG_ICON="#"
|
||||
PROCESSOR_LOADAVG_HEALTHY_COLOR="32"
|
||||
PROCESSOR_LOADAVG_WARNING_THRESHOLD=2
|
||||
PROCESSOR_LOADAVG_WARNING_COLOR="33"
|
||||
PROCESSOR_LOADAVG_CRITICAL_THRESHOLD=4
|
||||
PROCESSOR_LOADAVG_CRITICAL_COLOR="31"
|
||||
PROCESSOR_MODEL_ICON="#"
|
||||
|
||||
MEMORY_ICON="#"
|
||||
|
||||
SWAP_ICON="#"
|
||||
|
||||
DISKSPACE_ICON="#"
|
||||
|
||||
SERVICES_UP_ICON="#"
|
||||
SERVICES_UP_COLOR="32"
|
||||
SERVICES_DOWN_ICON="#"
|
||||
SERVICES_DOWN_COLOR="31"
|
||||
SERVICES_FILE=".bashrc_motd_services.txt"
|
||||
|
||||
PODMAN_VERSION_ICON="#"
|
||||
PODMAN_IMAGES_ICON="#"
|
||||
PODMAN_RUNNING_ICON="#"
|
||||
PODMAN_RUNNING_COLOR="32"
|
||||
PODMAN_OTHER_ICON="#"
|
||||
PODMAN_OTHER_COLOR="90"
|
||||
|
||||
DOCKER_VERSION_ICON="#"
|
||||
DOCKER_IMAGES_ICON="#"
|
||||
DOCKER_RUNNING_ICON="#"
|
||||
DOCKER_RUNNING_COLOR="32"
|
||||
DOCKER_OTHER_ICON="#"
|
||||
DOCKER_OTHER_COLOR="90"
|
||||
|
||||
UPDATES_ZERO_ICON="#"
|
||||
UPDATES_ZERO_COLOR="32"
|
||||
UPDATES_AVAILIABLE_ICON="#"
|
||||
UPDATES_AVAILIABLE_COLOR="33"
|
||||
UPDATES_SECURITY_ICON="#"
|
||||
UPDATES_SECURITY_COLOR="31"
|
||||
|
||||
LETSENCRYPT_VALID_ICON="#"
|
||||
LETSENCRYPT_VALID_COLOR="32"
|
||||
LETSENCRYPT_WARNING_ICON="#"
|
||||
LETSENCRYPT_WARNING_COLOR="33"
|
||||
LETSENCRYPT_INVALID_ICON="#"
|
||||
LETSENCRYPT_INVALID_COLOR="31"
|
||||
LETSENCRYPT_CERTPATH="/etc/letsencrypt/live"
|
||||
|
||||
LOGIN_LOGIN_ICON="#"
|
||||
LOGIN_LOGOUT_ICON="#"
|
||||
LOGIN_IP_ICON="#"
|
||||
|
||||
INCLUDE_FILE=".bash_motd_ownscript.sh"
|
||||
|
||||
generate_unit_byte() {
|
||||
# 1 - unit in M
|
||||
|
||||
if [ "$1" -ge 1024 ]; then
|
||||
unit_symbol="G"
|
||||
unit_value=$(echo "$1/1024" | bc -l | LANG=C xargs printf "%.1f\n")
|
||||
else
|
||||
unit_symbol="M"
|
||||
unit_value=$1
|
||||
fi
|
||||
|
||||
echo "$unit_value$unit_symbol"
|
||||
}
|
||||
|
||||
generate_space() {
|
||||
# 1 - already used
|
||||
# 2 - total
|
||||
|
||||
space_fill=$(( $2 - ${#1} ))
|
||||
space_chars=""
|
||||
|
||||
while [ $space_fill -ge 0 ]; do
|
||||
space_chars="$space_chars "
|
||||
space_fill=$(( space_fill - 1 ))
|
||||
done
|
||||
|
||||
echo "$space_chars"
|
||||
}
|
||||
|
||||
generate_bar() {
|
||||
# 1 - icon
|
||||
# 2 - total
|
||||
# 3 - used_1
|
||||
# 4 - [ used_2 ]
|
||||
|
||||
bar_percent=$(( $3 * 100 / $2 ))
|
||||
bar_separator=$(( $3 * 100 * 10 / $2 / 25 ))
|
||||
|
||||
if [ $bar_percent -ge "$BAR_WARNING_THRESHOLD" ]; then
|
||||
bar_color=$BAR_WARNING_COLOR
|
||||
elif [ $bar_percent -ge "$BAR_CRITICAL_THRESHOLD" ]; then
|
||||
bar_color=$BAR_CRITICAL_COLOR
|
||||
else
|
||||
bar_color=$BAR_HEALTHY_COLOR
|
||||
fi
|
||||
|
||||
printf " %s \\033[%dm" "$1" "$bar_color"
|
||||
|
||||
if [ -z "$4" ] ; then
|
||||
bar_piece=0
|
||||
while [ $bar_piece -le 40 ]; do
|
||||
if [ "$bar_piece" -ne "$bar_separator" ]; then
|
||||
printf "%s" "$BAR_ELEMENT"
|
||||
else
|
||||
printf "%s\\033[1;30m" "$BAR_ELEMENT"
|
||||
fi
|
||||
|
||||
bar_piece=$(( bar_piece + 1 ))
|
||||
done
|
||||
else
|
||||
bar_cached_val=$(( $3 + $4 ))
|
||||
bar_cached_separator=$(( bar_cached_val * 100 * 10 / $2 / 25 ))
|
||||
|
||||
bar_piece=0
|
||||
while [ $bar_piece -le 40 ]; do
|
||||
if [ $bar_piece -eq $bar_separator ]; then
|
||||
printf "%s\\033[1;36m" "$BAR_ELEMENT"
|
||||
elif [ $bar_piece -eq $bar_cached_separator ]; then
|
||||
printf "%s\\033[1;30m" "$BAR_ELEMENT"
|
||||
else
|
||||
printf "%s" "$BAR_ELEMENT"
|
||||
fi
|
||||
|
||||
bar_piece=$(( bar_piece + 1 ))
|
||||
done
|
||||
fi
|
||||
|
||||
printf "\\033[0m\\n"
|
||||
}
|
||||
|
||||
generate_bar_memory() {
|
||||
# 1 - icon
|
||||
# 2 - total memory in M
|
||||
# 3 - used memory in M
|
||||
# 4 - cached memory in M
|
||||
|
||||
bar_memory_used=$(generate_unit_byte "$3")
|
||||
bar_memory_cached=$(generate_unit_byte "$4")
|
||||
bar_memory_available=$(generate_unit_byte $(( $2 - $3 )) )
|
||||
|
||||
printf " %s used / %s cached / %s available\\n" "$bar_memory_used" "$bar_memory_cached" "$bar_memory_available"
|
||||
generate_bar "$1" "$2" "$3" "$4"
|
||||
}
|
||||
|
||||
generate_bar_swap() {
|
||||
# 1 - icon
|
||||
# 2 - total swap in M
|
||||
# 3 - used swap in M
|
||||
|
||||
bar_swap_used=$(generate_unit_byte "$3")
|
||||
|
||||
bar_swap_available=$(( $2 - $3 ))
|
||||
bar_swap_available=$(generate_unit_byte "$bar_swap_available")
|
||||
|
||||
printf " %s used / %s available\\n" "$bar_swap_used" "$bar_swap_available"
|
||||
generate_bar "$1" "$2" "$3"
|
||||
}
|
||||
|
||||
generate_bar_disk() {
|
||||
# 1 - icon
|
||||
# 2 - total size in M
|
||||
# 3 - used space in M
|
||||
# 4 - mount path
|
||||
|
||||
bar_disk_mount="$4$(generate_space "$4" 10)"
|
||||
|
||||
bar_disk_used=$(generate_unit_byte "$3")
|
||||
bar_disk_used="$(generate_space "$bar_disk_used" 5)$bar_disk_used used"
|
||||
|
||||
bar_disk_available=$(( $2 - $3 ))
|
||||
bar_disk_available="$(generate_unit_byte "$bar_disk_available") available"
|
||||
|
||||
printf " %s %s / %s\\n" "$bar_disk_mount" "$bar_disk_used" "$bar_disk_available"
|
||||
|
||||
generate_bar "$1" "$2" "$3"
|
||||
}
|
||||
|
||||
print_banner() {
|
||||
printf "\\n%s\\n" "$(figlet -t -f "$BANNER_FONTPATH" " $BANNER_TEXT")"
|
||||
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
|
||||
if [ "$ID" = "debian" ]; then
|
||||
banner_distro_icon=$BANNER_DEBIAN_ICON
|
||||
banner_distro_color=$BANNER_DEBIAN_COLOR
|
||||
banner_distro_name="Debian"
|
||||
banner_distro_version=$(cat /etc/debian_version)
|
||||
elif [ "$ID" = "ubuntu" ]; then
|
||||
banner_distro_icon=$BANNER_DEBIAN_ICON
|
||||
banner_distro_color=$BANNER_DEBIAN_COLOR
|
||||
banner_distro_name="Ubuntu"
|
||||
banner_distro_version=$VERSION_ID
|
||||
elif [ "$ID" = "fedora" ]; then
|
||||
banner_distro_icon=$BANNER_FEDORA_ICON
|
||||
banner_distro_color=$BANNER_FEDORA_COLOR
|
||||
banner_distro_name="Fedora"
|
||||
banner_distro_version=$VERSION_ID
|
||||
elif [ "$ID" = "arch" ] || [ "$ID_LIKE" = "arch" ]; then
|
||||
banner_distro_icon=$BANNER_ARCH_ICON
|
||||
banner_distro_color=$BANNER_ARCH_COLOR
|
||||
banner_distro_name="Arch-Based"
|
||||
banner_distro_version=$BUILD_ID
|
||||
elif [ "$ID" = "nixos" ] || [ "$ID_LIKE" = "nixos" ]; then
|
||||
banner_distro_icon=$BANNER_ARCH_ICON
|
||||
banner_distro_color=$BANNER_ARCH_COLOR
|
||||
banner_distro_name="NixOS"
|
||||
banner_distro_version=$BUILD_ID
|
||||
else
|
||||
banner_distro_icon="?"
|
||||
banner_distro_color="0"
|
||||
banner_distro_name="Unknown"
|
||||
banner_distro_version="?"
|
||||
fi
|
||||
|
||||
banner_distro_space=$(generate_space "$banner_distro_name" 13)
|
||||
|
||||
printf " \\033[%sm%s %s\\033[0m%s%s\\n" "$banner_distro_color" "$banner_distro_icon" "$banner_distro_name" "$banner_distro_space" "$banner_distro_version"
|
||||
printf " \\033[%sm%s Linux\\033[0m %s\\n\\n" "$BANNER_KERNEL_COLOR" "$BANNER_KERNEL_ICON" "$(cut -d ' ' -f 3 < /proc/version)"
|
||||
printf " \\033[%sm%s Uptime\\033[0m %s\\n" "$BANNER_UPTIME_COLOR" "$BANNER_UPTIME_ICON" "$(awk '{printf("%d days, %d hours, %d minutes \n",($1/60/60/24),($1/60/60%24),($1/60%60))}' /proc/uptime)"
|
||||
fi
|
||||
}
|
||||
|
||||
print_processor() {
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mProcessor:\\033[0m\\n"
|
||||
|
||||
processor_loadavg="$(cut -d " " -f 1,2,3 < /proc/loadavg)"
|
||||
if [ "$(echo "$processor_loadavg" | cut -d "." -f 1)" -ge "$PROCESSOR_LOADAVG_CRITICAL_THRESHOLD" ]; then
|
||||
processor_loadavg_color=$PROCESSOR_LOADAVG_CRITICAL_COLOR
|
||||
elif [ "$(echo "$processor_loadavg" | cut -d "." -f 1)" -ge "$PROCESSOR_LOADAVG_WARNING_THRESHOLD" ]; then
|
||||
processor_loadavg_color=$PROCESSOR_LOADAVG_WARNING_COLOR
|
||||
else
|
||||
processor_loadavg_color=$PROCESSOR_LOADAVG_HEALTHY_COLOR
|
||||
fi
|
||||
|
||||
processor_info=$(cat /proc/cpuinfo)
|
||||
|
||||
processor_arch=$(uname -m)
|
||||
|
||||
if [ "$processor_arch" = "x86_64" ]; then
|
||||
processor_model="$(echo "$processor_info" | grep "model name" | sort -u | cut -d ':' -f 2)"
|
||||
processor_count=$(echo "$processor_info" | grep "physical id" | sort -u | wc -l)
|
||||
processor_cores=$(echo "$processor_info" | grep "cpu cores" | sort -u | cut -d ':' -f 2)
|
||||
processor_threads=$(( $(echo "$processor_info" | grep "siblings" | tail -n 1 | cut -d ':' -f 2) ))
|
||||
|
||||
if [ ! "$processor_cores" -eq $processor_threads ]; then
|
||||
processor_threads=", $processor_threads Threads"
|
||||
else
|
||||
processor_threads=""
|
||||
fi
|
||||
elif [ "$processor_arch" = "mips64" ]; then
|
||||
processor_model="$(echo "$processor_info" | grep "cpu model" | sort -u | cut -d ':' -f 2)"
|
||||
processor_count=$(echo "$processor_info" | grep "package" | sort -u | wc -l)
|
||||
processor_cores=$(echo "$processor_info" | grep -c processor)
|
||||
processor_threads=""
|
||||
else
|
||||
processor_model="?"
|
||||
processor_count=0
|
||||
processor_cores=0
|
||||
processor_threads=0
|
||||
fi
|
||||
|
||||
processor_model=$(echo "$processor_model" | sed "s/(R)//g")
|
||||
processor_model=$(echo "$processor_model" | sed "s/(tm)//g")
|
||||
processor_model=$(echo "$processor_model" | sed "s/ @/,/")
|
||||
processor_model=$(echo "$processor_model" | sed "s/ CPU//")
|
||||
processor_model=$(echo "$processor_model" | sed "s/ / /")
|
||||
processor_model=$(echo "$processor_model" | sed "s/^ //g")
|
||||
|
||||
processor_cores=$(( processor_cores * processor_count ))
|
||||
|
||||
if [ "$processor_count" -gt 1 ]; then
|
||||
processor_count="$processor_count""x "
|
||||
else
|
||||
processor_count=""
|
||||
fi
|
||||
|
||||
printf " %s \\033[%dm%s\\033[0m\\n" "$PROCESSOR_LOADAVG_ICON" "$processor_loadavg_color" "$processor_loadavg"
|
||||
printf " %s %s%s = %s Cores%s\\n" "$PROCESSOR_MODEL_ICON" "$processor_count" "$processor_model" "$processor_cores" "$processor_threads"
|
||||
}
|
||||
|
||||
print_memory() {
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mMemory:\\033[0m\\n"
|
||||
|
||||
memory_usage=$(LANG=C free --mega | grep "Mem:")
|
||||
memory_total=$(echo "$memory_usage" | awk '{ print $2 }')
|
||||
memory_used=$(echo "$memory_usage" | awk '{ print $3 }')
|
||||
memory_cached=$(echo "$memory_usage" | awk '{ print $6 }')
|
||||
|
||||
generate_bar_memory "$MEMORY_ICON" "$memory_total" "$memory_used" "$memory_cached"
|
||||
}
|
||||
|
||||
print_swap() {
|
||||
swap_usage=$(LANG=C free --mega | grep "Swap:")
|
||||
|
||||
swap_total=$(echo "$swap_usage" | awk '{ print $2 }')
|
||||
swap_used=$(echo "$swap_usage" | awk '{ print $3 }')
|
||||
|
||||
if [ "$swap_total" -ne 0 ]; then
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mSwap:\\033[0m\\n"
|
||||
|
||||
generate_bar_swap "$SWAP_ICON" "$swap_total" "$swap_used"
|
||||
fi
|
||||
}
|
||||
|
||||
print_diskspace() {
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mDiskspace:\\033[0m\\n"
|
||||
|
||||
diskspace_partitions=$(df -tvfat -text4 -tbtrfs -tzfs -B M -P | sed -e "s/M//g" | grep -v "^Filesystem")
|
||||
|
||||
diskspace_index=0
|
||||
echo "$diskspace_partitions" | while read -r line; do
|
||||
|
||||
diskspace_disk_mount="$(echo "$line" | awk '{ print $1 }')"
|
||||
diskspace_disk_size="$(echo "$line" | awk '{ print $2 }')"
|
||||
diskspace_disk_used="$(echo "$line" | awk '{ print $3 }')"
|
||||
|
||||
if [ "$diskspace_index" -ne 0 ]; then
|
||||
printf "\\n"
|
||||
fi
|
||||
|
||||
diskspace_index=$(( diskspace_index + 1 ))
|
||||
|
||||
generate_bar_disk "$DISKSPACE_ICON" "$diskspace_disk_size" "$diskspace_disk_used" "$diskspace_disk_mount"
|
||||
done
|
||||
}
|
||||
|
||||
print_services() {
|
||||
if [ -f $SERVICES_FILE ] && [ "$(wc -l < $SERVICES_FILE )" != 0 ]; then
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mServices:\\033[0m \\033[1;37mVersion:\\033[0m\\n"
|
||||
|
||||
while read -r line; do
|
||||
service_description=$(echo "$line" | cut -d ';' -f 1)
|
||||
|
||||
service_name=$(echo "$line" | cut -d ';' -f 2)
|
||||
|
||||
service_package=$(echo "$line" | cut -d ';' -f 3)
|
||||
|
||||
if [ -n "$service_description" ] && [ -n "$service_name" ]; then
|
||||
if systemctl is-active --quiet "$service_name".service; then
|
||||
service_icon=$SERVICES_UP_ICON
|
||||
service_color=$SERVICES_UP_COLOR
|
||||
else
|
||||
service_icon=$SERVICES_DOWN_ICON
|
||||
service_color=$SERVICES_DOWN_COLOR
|
||||
fi
|
||||
|
||||
service_space=$(generate_space "$service_description" 34)
|
||||
|
||||
if [ -n "$service_package" ]; then
|
||||
if [ -f /usr/bin/apt ]; then
|
||||
package_version=$(dpkg -s "$service_package" | grep '^Version:' | cut -d ' ' -f 2 | cut -d ':' -f 2 | cut -d '-' -f 1)
|
||||
elif [ -f /usr/bin/rpm ]; then
|
||||
package_version=$(rpm -q --queryformat '%{VERSION}' "$service_package")
|
||||
else
|
||||
package_version="?"
|
||||
fi
|
||||
else
|
||||
package_version="--"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf " \\033[%sm%s\\033[0m %s%s%s\\n" "$service_color" "$service_icon" "$service_description" "$service_space" "$package_version"
|
||||
done < $SERVICES_FILE | grep -v '#'
|
||||
fi
|
||||
}
|
||||
|
||||
print_podman() {
|
||||
if ! which podman >> /dev/null 2>&1
|
||||
then
|
||||
return
|
||||
fi
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mPodman:\\033[0m\\n"
|
||||
|
||||
podman_version=$(podman version --format json | jq -r '.Client.Version')
|
||||
podman_space=$(generate_space "$podman_version" 23)
|
||||
podman_images=$(podman images --format json | jq '. | length')
|
||||
|
||||
printf " %s Version %s%s%s %s Images\\n\\n" "$PODMAN_VERSION_ICON" "$podman_version" "$podman_space" "$PODMAN_IMAGES_ICON" "$podman_images"
|
||||
|
||||
podman_list=$(podman pod ls --sort name --format json)
|
||||
podman_pods=$(echo "$podman_list" | jq -r '.[] .Name')
|
||||
|
||||
echo "$podman_pods" | while read -r pod; do
|
||||
if [ "$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Status")" = "Running" ]; then
|
||||
pod_space=$(generate_space "$pod" 34)
|
||||
|
||||
pod_container_running="$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Containers[] | select(.Status == \"running\") | .Status" | wc -l)"
|
||||
|
||||
if [ "$pod_container_running" -ne 0 ]; then
|
||||
pod_container_running=$(printf "\\033[%um%u Running\\033[0m" "$PODMAN_RUNNING_COLOR" "$pod_container_running")
|
||||
fi
|
||||
|
||||
pod_container_other="$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Containers[] | select(.Status != \"running\") | .Status" | wc -l)"
|
||||
|
||||
if [ "$pod_container_other" -ne 0 ]; then
|
||||
pod_container_other=$(printf ", \\033[%um%u Other\\033[0m" "$PODMAN_OTHER_COLOR" "$pod_container_other")
|
||||
else
|
||||
pod_container_other=""
|
||||
fi
|
||||
|
||||
pod_status="$pod_container_running$pod_container_other"
|
||||
|
||||
printf " \\033[%um%s\\033[0m %s%s%s\\n" "$PODMAN_RUNNING_COLOR" "$PODMAN_RUNNING_ICON" "$pod" "$pod_space" "$pod_status"
|
||||
else
|
||||
printf " \\033[%um%s\\033[0m \\033[%um%s\\033[0m\\n" "$PODMAN_OTHER_COLOR" "$PODMAN_OTHER_ICON" "$PODMAN_OTHER_COLOR" "$pod"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
print_docker() {
|
||||
if [ "$(systemctl is-active docker.service)" = "active" ]; then
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mDocker:\\033[0m\\n"
|
||||
|
||||
docker_info=$(sudo curl -sf --unix-socket /var/run/docker.sock http:/v1.40/info)
|
||||
|
||||
docker_version=$(echo "$docker_info" | jq -r '.ServerVersion')
|
||||
|
||||
docker_space=$(generate_space "$docker_version" 23)
|
||||
|
||||
docker_images=$(echo "$docker_info" | jq -r '.Images')
|
||||
|
||||
printf " %s Version %s%s%s %s Images\\n\\n" "$DOCKER_VERSION_ICON" "$docker_version" "$docker_space" "$DOCKER_IMAGES_ICON" "$docker_images"
|
||||
|
||||
docker_list=$(sudo curl -sf --unix-socket /var/run/docker.sock "http://v1.40/containers/json?all=true" | jq -c ' .[]')
|
||||
|
||||
echo "$docker_list" | while read -r line; do
|
||||
container_name="$(echo "$line" | jq -r '.Names[]' | sed 's/\///')"
|
||||
|
||||
container_status="$(echo "$line" | jq -r '.Status' | sed 's/.*/\l&/')"
|
||||
|
||||
container_space=$(generate_space "$container_name" 34)
|
||||
|
||||
if [ "$(echo "$line" | jq -r '.State')" = "running" ]; then
|
||||
printf " \\033[%um%s\\033[0m %s%s%s\\n" "$DOCKER_RUNNING_COLOR" "$DOCKER_RUNNING_ICON" "$container_name" "$container_space" "$container_status"
|
||||
else
|
||||
printf " \\033[%um%s\\033[0m \\033[%um%s\\033[0m%s\\033[%um%s\\033[0m\\n" "$DOCKER_OTHER_COLOR" "$DOCKER_OTHER_ICON" "$DOCKER_OTHER_COLOR" "$container_name" "$container_space" "$DOCKER_OTHER_COLOR" "$container_status"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
print_updates() {
|
||||
if [ -f /usr/bin/apt ]; then
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mUpdates:\\033[0m\\n"
|
||||
|
||||
updates_count_regular=$(apt-get upgrade -s | grep -c ^Inst)
|
||||
updates_count_security=$(apt-get upgrade -s | grep ^Inst | grep -c Security)
|
||||
|
||||
if [ -n "$updates_count_regular" ] && [ "$updates_count_regular" -ne 0 ]; then
|
||||
if [ -n "$updates_count_security" ] && [ "$updates_count_security" -ne 0 ]; then
|
||||
updates_icon=$UPDATES_SECURITY_ICON
|
||||
updates_color=$UPDATES_SECURITY_COLOR
|
||||
updates_message="$updates_count_regular packages can be updated, $updates_count_security are security updates."
|
||||
else
|
||||
updates_icon=$UPDATES_AVAILIABLE_ICON
|
||||
updates_color=$UPDATES_AVAILIABLE_COLOR
|
||||
updates_message="$updates_count_regular packages can be updated."
|
||||
fi
|
||||
else
|
||||
updates_icon=$UPDATES_ZERO_ICON
|
||||
updates_color=$UPDATES_ZERO_COLOR
|
||||
updates_message="Everything is up to date!"
|
||||
fi
|
||||
|
||||
printf " \\033[%sm%s\\033[0m %s\\n" "$updates_color" "$updates_icon" "$updates_message"
|
||||
elif [ -f /usr/bin/dnf ]; then
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mUpdates:\\033[0m\\n"
|
||||
|
||||
updates_count=$(dnf updateinfo -C -q --list)
|
||||
updates_count_regular=$(echo "$updates_count" | wc -l)
|
||||
updates_count_security=$(echo "$updates_count" | grep -c "Important/Sec")
|
||||
|
||||
if [ -n "$updates_count_regular" ] && [ "$updates_count_regular" -ne 0 ]; then
|
||||
if [ -n "$updates_count_security" ] && [ "$updates_count_security" -ne 0 ]; then
|
||||
updates_icon=$UPDATES_SECURITY_ICON
|
||||
updates_color=$UPDATES_SECURITY_COLOR
|
||||
updates_message="$updates_count_regular packages can be updated, $updates_count_security are security updates."
|
||||
else
|
||||
updates_icon=$UPDATES_AVAILIABLE_ICON
|
||||
updates_color=$UPDATES_AVAILIABLE_COLOR
|
||||
updates_message="$updates_count_regular packages can be updated."
|
||||
fi
|
||||
else
|
||||
updates_icon=$UPDATES_ZERO_ICON
|
||||
updates_color=$UPDATES_ZERO_COLOR
|
||||
updates_message="Everything is up to date!"
|
||||
fi
|
||||
|
||||
printf " \\033[%sm%s\\033[0m %s\\n" "$updates_color" "$updates_icon" "$updates_message"
|
||||
fi
|
||||
}
|
||||
|
||||
print_letsencrypt() {
|
||||
if [ -d $LETSENCRYPT_CERTPATH ] && [ "$(ls -a $LETSENCRYPT_CERTPATH)" ]; then
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mSSL / let’s encrypt:\\033[0m\\n"
|
||||
|
||||
cert_list=$(sudo find $LETSENCRYPT_CERTPATH -name cert.pem)
|
||||
|
||||
for cert_file in $cert_list; do
|
||||
sudo openssl x509 -checkend $((25 * 86400)) -noout -in "$cert_file" >> /dev/null
|
||||
result=$?
|
||||
|
||||
cert_name=$(echo "$cert_file" | rev | cut -d '/' -f 2 | rev)
|
||||
|
||||
if [ "$result" -eq 0 ]; then
|
||||
printf " \\033[%sm%s\\033[0m %s\\n" "$LETSENCRYPT_VALID_COLOR" "$LETSENCRYPT_VALID_ICON" "$cert_name"
|
||||
else
|
||||
sudo openssl x509 -checkend $((0 * 86400)) -noout -in "$cert_file" >> /dev/null
|
||||
result=$?
|
||||
|
||||
if [ "$result" -eq 0 ]; then
|
||||
printf " \\033[%sm%s\\033[0m %s\\n" "$LETSENCRYPT_WARNING_COLOR" "$LETSENCRYPT_WARNING_ICON" "$cert_name"
|
||||
else
|
||||
printf " \\033[%sm%s\\033[0m %s\\n" "$LETSENCRYPT_INVALID_COLOR" "$LETSENCRYPT_INVALID_ICON" "$cert_name"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
print_login() {
|
||||
login_last=$(last -n 2 -a -d --time-format iso "$(whoami)" | head -n 2 | tail -n 1)
|
||||
|
||||
if [ "$( echo "$login_last" | awk '{ print $1 }')" = "$(whoami)" ]; then
|
||||
login_ip=$(echo "$login_last" | awk '{ print $7 }')
|
||||
|
||||
login_login=$(date -d "$(echo "$login_last" | awk '{ print $3 }' | cut -d '+' -f 1 | sed "s/T/ /")" "+%a, %d.%m.%y %H:%M")
|
||||
|
||||
login_space=$(generate_space "$login_login" 25)
|
||||
|
||||
if [ "$(echo "$login_last" | awk '{ print $4 }')" = "still" ]; then
|
||||
login_logout="still connected"
|
||||
else
|
||||
login_logout=$(date -d "$(echo "$login_last" | awk '{ print $5 }' | cut -d '+' -f 1 | sed "s/T/ /")" "+%a, %d.%m.%y %H:%M")
|
||||
fi
|
||||
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mLast login for %s:\\033[0m\\n" "$(echo "$login_last" | awk '{ print $1 }')"
|
||||
printf " %s %s%s%s %s\\n" "$LOGIN_LOGIN_ICON" "$login_login" "$login_space" "$LOGIN_LOGOUT_ICON" "$login_logout"
|
||||
printf " %s %s\\n" "$LOGIN_IP_ICON" "$login_ip"
|
||||
fi
|
||||
}
|
||||
|
||||
print_include() {
|
||||
. $INCLUDE_FILE
|
||||
}
|
||||
|
||||
bash_motd() {
|
||||
for module in "$@"; do
|
||||
if [ "$module" = "--banner" ]; then
|
||||
print_banner
|
||||
elif [ "$module" = "--processor" ]; then
|
||||
print_processor
|
||||
elif [ "$module" = "--memory" ]; then
|
||||
print_memory
|
||||
elif [ "$module" = "--swap" ]; then
|
||||
print_swap
|
||||
elif [ "$module" = "--diskspace" ]; then
|
||||
print_diskspace
|
||||
elif [ "$module" = "--services" ]; then
|
||||
print_services
|
||||
elif [ "$module" = "--podman" ]; then
|
||||
print_podman
|
||||
elif [ "$module" = "--docker" ]; then
|
||||
print_docker
|
||||
elif [ "$module" = "--updates" ]; then
|
||||
print_updates
|
||||
elif [ "$module" = "--letsencrypt" ]; then
|
||||
print_letsencrypt
|
||||
elif [ "$module" = "--login" ]; then
|
||||
print_login
|
||||
elif [ "$module" = "--include" ]; then
|
||||
print_include
|
||||
fi
|
||||
done
|
||||
|
||||
printf "\\n"
|
||||
}
|
||||
30
home/files/bash_motd_ownscript.sh
Normal file
30
home/files/bash_motd_ownscript.sh
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash -
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: .bash_motd_ownscript.sh
|
||||
#
|
||||
# USAGE: ./.bash_motd_ownscript.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
#
|
||||
# OPTIONS: ---
|
||||
# REQUIREMENTS: ---
|
||||
# BUGS: ---
|
||||
# NOTES: ---
|
||||
# AUTHOR: Don Harper (dmh), duck@duckland.org
|
||||
# ORGANIZATION: duckland.org
|
||||
# CREATED: 01/28/2022 21:23
|
||||
# REVISION: ---
|
||||
#===============================================================================
|
||||
|
||||
set -o nounset # Treat unset variables as an error
|
||||
|
||||
if [ "$(pgrep -c tailscaled)" = "1" ]
|
||||
then
|
||||
printf "\\n"
|
||||
printf " \\033[1;37mTailScale:\\033[0m\\n"
|
||||
tailscale status | while read -r line
|
||||
do
|
||||
printf " %s\n" "${line}"
|
||||
done
|
||||
fi
|
||||
29
home/files/bash_profile
Normal file
29
home/files/bash_profile
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
PATH="/run/wrappers/bin:${HOME}/.nix-profile/bin:/etc/profiles/per-user/don/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:${HOME}/bin:${HOME}/go/bin"
|
||||
export PATH
|
||||
umask 006
|
||||
if [ ! -z "${PS1}" ]
|
||||
then
|
||||
if [ "$TERM" = "linux" ]; then
|
||||
echo -en "\e]P021222C" #black
|
||||
echo -en "\e]P8282a36" #darkgrey
|
||||
echo -en "\e]P1803232" #darkred
|
||||
echo -en "\e]P9ff5555" #red
|
||||
echo -en "\e]P25b762f" #darkgreen
|
||||
echo -en "\e]PA50fa7b" #green
|
||||
echo -en "\e]P3aa9943" #brown
|
||||
echo -en "\e]PBf1fa8c" #yellow
|
||||
echo -en "\e]P4324c80" #darkblue
|
||||
echo -en "\e]PCbd93f9" #blue
|
||||
echo -en "\e]P5627sa4" #darkmagenta
|
||||
echo -en "\e]PDbd93f9" #magenta
|
||||
echo -en "\e]P692b19e" #darkcyan
|
||||
echo -en "\e]PE8be9fd" #cyan
|
||||
echo -en "\e]P7ffffff" #lightgrey
|
||||
echo -en "\e]PFf8f8f2" #white
|
||||
clear #for background artifacting
|
||||
fi
|
||||
. ~/.bash_motd && bash_motd --banner --processor --memory --diskspace --podman --docker
|
||||
fi
|
||||
|
||||
cd "${HOME}"
|
||||
source "${HOME}"/.bashrc
|
||||
9
home/files/bash_ssh
Executable file
9
home/files/bash_ssh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
ARGS="-q --eval --systemd --agents ssh --nocolor --ignore-missing --quick git id_dsa id_ed25519 id_rsa 56913AD86A18257132AA9F03928BC0B78C1BF5AA"
|
||||
#SSH_ASKPASS=/usr/bin/qt4-ssh-askpass
|
||||
#export SSH_ASKPASS
|
||||
eval $(keychain ${ARGS} )
|
||||
. ~/.keychain/"${HOSTNAME_SHORT}"-sh
|
||||
|
||||
ssh-add -l | grep -q ED25519 || ssh-add
|
||||
170
home/files/bashrc
Executable file
170
home/files/bashrc
Executable file
|
|
@ -0,0 +1,170 @@
|
|||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: .bashrc
|
||||
#
|
||||
# DESCRIPTION: Main bash init file
|
||||
#
|
||||
# OPTIONS: ---
|
||||
# REQUIREMENTS: ---
|
||||
# BUGS: ---
|
||||
# NOTES: ---
|
||||
# AUTHOR: Don Harper (), duckunix@gmail.com
|
||||
# COMPANY: Don Harper
|
||||
# VERSION: 1.0
|
||||
# CREATED: 06/11/2007 11:30:25 PM CDT
|
||||
# REVISION: ---
|
||||
#===============================================================================
|
||||
|
||||
# set some global stuff first
|
||||
|
||||
# colors
|
||||
GREEN='[01;32m'
|
||||
YELLOW='[01;33m'
|
||||
RED='[01;31m'
|
||||
NONE='[01;0m'
|
||||
export NONE GREEN YELLOW RED
|
||||
PATH="/run/wrappers/bin:${HOME}/.nix-profile/bin:/etc/profiles/per-user/don/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:${HOME}/bin:${HOME}/go/bin"
|
||||
export PATH
|
||||
export GOPATH="${HOME}/go"
|
||||
|
||||
if [ -f ${HOME}/.nix-profile/etc/profile.d/hm-session-vars.sh ]
|
||||
then
|
||||
. ${HOME}/.nix-profile/etc/profile.d/hm-session-vars.sh
|
||||
fi
|
||||
|
||||
HOSTNAME_SHORT=$(hostnamectl | awk -F: '$1=/Static hostname/{print $2}' | sed 's/^ //')
|
||||
while [ "${HOSTNAME_SHORT}" == "localhost" ]
|
||||
do
|
||||
echo "${RED}@${GREEN}-,---${NONE}"
|
||||
sleep 1
|
||||
HOSTNAME_SHORT=$(hostnamectl | awk -F: '$1=/Static hostname/{print $2}' | sed 's/^ //')
|
||||
done
|
||||
export HOSTNAME_SHORT
|
||||
HISTNAME=$LOGNAME
|
||||
if [ $EUID == 0 ];then HISTNAME=root;fi
|
||||
HISTFILE="${HOME}/.bash_history.${HISTNAME}.${HOSTNAME_SHORT}.$(tty|cut -c10-)"
|
||||
export HISTFILE
|
||||
test -f "${HOME}/.bash_ssh" && source "${HOME}/.bash_ssh"
|
||||
|
||||
|
||||
# set coredump size to 0
|
||||
ulimit -c 0
|
||||
|
||||
umask 0007
|
||||
if [ "$LOGNAME" ]; then
|
||||
USER=$LOGNAME
|
||||
fi
|
||||
|
||||
OS_SYS=$(uname -s)
|
||||
OS_REL=$(uname -r)
|
||||
OS_CPU=$(uname -m)
|
||||
OS_TYPE="$OS_SYS.$OS_REL"
|
||||
export OS_SYS OS_REL OS_TYPE OS_CPU LESS
|
||||
|
||||
# Set up path
|
||||
test -f "${HOME}/.bash_functions" && source "${HOME}/.bash_functions"
|
||||
test -d "${HOME}/bin/${HOSTNAME_SHORT}" && PATH="${PATH}:${HOME}/bin/${HOSTNAME_SHORT}"
|
||||
test -d "${HOME}/bin/${OS_CPU}" && PATH="${PATH}:${HOME}/bin/${OS_CPU}"
|
||||
test -d "${HOME}/bin" && PATH="${PATH}:${HOME}/bin"
|
||||
test -d "${HOME}/.local/bin" && PATH="${PATH}:${HOME}/.local/bin"
|
||||
test -d "${HOME}/.cargo/bin" && PATH="${PATH}:${HOME}/.cargo/bin"
|
||||
test -d "${HOME}/.local/share/gem" && PATH="${PATH}:${HOME}/.local/share/gem/ruby/latest/bin"
|
||||
test -d /usr/local/sbin && PATH="${PATH}:/usr/local/sbin"
|
||||
test -d /usr/local/bin && PATH="${PATH}:/usr/local/bin"
|
||||
test -d /sbin && PATH="${PATH}:/sbin"
|
||||
test -d /usr/sbin && PATH="${PATH}:/usr/sbin"
|
||||
test -d /usr/bin && PATH="${PATH}:/usr/bin"
|
||||
test -d /bin && PATH="${PATH}:/bin"
|
||||
export PATH
|
||||
|
||||
test -f "${HOME}/.bash_ssh" && . ${HOME}/.bash_ssh
|
||||
|
||||
#interactive login ?
|
||||
|
||||
#####################################
|
||||
######### #########
|
||||
######## Interactive stuff ########
|
||||
######### #########
|
||||
#####################################
|
||||
|
||||
if [ "${PS1}" ];
|
||||
then
|
||||
unset i
|
||||
set -o noclobber
|
||||
set -o notify
|
||||
set bell-style visible
|
||||
set nobeep
|
||||
shopt -s autocd
|
||||
shopt -s cdspell
|
||||
shopt -s checkjobs
|
||||
shopt -s checkwinsize
|
||||
shopt -s dotglob
|
||||
shopt -s extglob
|
||||
shopt -s histappend
|
||||
shopt -s histreedit
|
||||
|
||||
PAGER=less
|
||||
LESS="-s"
|
||||
EXINIT="set wrapmargin=8 sh=$SHELL sw=4 report=2 tabstop=8"
|
||||
export EXINIT EDITOR PAGER
|
||||
EDITOR=vi
|
||||
if [ -x /usr/bin/vim ]
|
||||
then
|
||||
EDITOR=vim
|
||||
alias vi=/usr/bin/vim
|
||||
elif [ -x /usr/local/bin/vim ]
|
||||
then
|
||||
EDITOR=vim
|
||||
alias vi=/usr/local/bin/vim
|
||||
elif [ $(which nvim 2>&1 >> /dev/null) ]
|
||||
then
|
||||
EDITOR=nvim
|
||||
fi
|
||||
export EDITOR
|
||||
unset COMPHOSTS
|
||||
export COMPHOSTS=()
|
||||
|
||||
|
||||
unset pathmunge
|
||||
# set up man path
|
||||
MANPATH="${MANPATH}:${HOME}/man:${HOME}/share/man"
|
||||
export MANPATH
|
||||
|
||||
|
||||
test -f $(ls -1 /nix/store/*bash-completion-*/etc/profile.d/bash_completion.sh | tail -n1) && \
|
||||
source $(ls -1 /nix/store/*bash-completion-*/etc/profile.d/bash_completion.sh | tail -n1)
|
||||
|
||||
export LOCKPRG=${HOME}/bin/myLock
|
||||
export HISTCONTROL=ignoreboth
|
||||
export HISTIGNORE='pwd:exit:clear:history'
|
||||
|
||||
|
||||
[ -f /etc/profile.d/bash-completion.sh ] && source /etc/profile.d/bash-completion.sh
|
||||
[ -f /usr/local/share/bash-completion/bash_completion.sh ] && source/usr/local/share/bash-completion/bash_completion.sh
|
||||
[ -f /usr/share/bash-completion/bash_completion ] && source /usr/share/bash-completion/bash_completion
|
||||
[ ! -v ${BASH_COMPLETION_VERSINFO} -a -d ${HOME}/.bash_completion.d ] && for i in $(ls -1 ${HOME}/.bash_completion.d/*.sh); do source $i; done
|
||||
|
||||
export PROMPT_COMMAND='history -a' # Always append history files
|
||||
PS1='\u@\h:\w> '
|
||||
|
||||
test -f "${HOME}/.bash_aliases" && . ${HOME}/.bash_aliases
|
||||
test -f "${HOME}/.bash_local" && . ${HOME}/.bash_local
|
||||
test -f "${HOME}/.liquidprompt/liquidprompt" && . ${HOME}/.liquidprompt/liquidprompt
|
||||
# git completion
|
||||
if [ ! -v BASH_COMPLETION_VERSINFO -a -f /usr/local/share/git-completion/git-completion.bash ]; then
|
||||
source /usr/local/share/git-completion/git-completion.bash
|
||||
fi
|
||||
|
||||
export NVM_DIR="/usr/local/share/nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ ! -v BASH_COMPLETION_VERSINFO -a -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
export SASL_PATH=/usr/local/lib/sasl2
|
||||
#complete -C "${GOPATH}/bin/bitcomplete" bit
|
||||
test -f "${HOME}/.bash_${HOSTNAME_SHORT}" && . ${HOME}/.bash_$HOSTNAME_SHORT
|
||||
|
||||
# BEGIN_KITTY_SHELL_INTEGRATION
|
||||
if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; then source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; fi
|
||||
# END_KITTY_SHELL_INTEGRATION
|
||||
complete -o nospace -F _task t
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue