summaryrefslogtreecommitdiff
path: root/dotfiles/system/.profile.d
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-05-08 18:49:34 -0500
committerCraig Jennings <c@cjennings.net>2025-05-08 18:51:59 -0500
commit000e00871830cd15de032c80e2b62946cf19445c (patch)
tree794a7922750472bbe0e024042d6ba84f411fc3e0 /dotfiles/system/.profile.d
parentfe302606931e4bad91c4ed6df81a4403523ba780 (diff)
adding missing dotfiles and folders
- profile.d/ - bashrc - authinfo.gpg - .zsh/
Diffstat (limited to 'dotfiles/system/.profile.d')
-rw-r--r--dotfiles/system/.profile.d/auto-tmux-session.sh12
-rw-r--r--dotfiles/system/.profile.d/chronographic.sh116
-rw-r--r--dotfiles/system/.profile.d/dd.sh19
-rw-r--r--dotfiles/system/.profile.d/display.sh9
-rw-r--r--dotfiles/system/.profile.d/emacs.sh33
-rw-r--r--dotfiles/system/.profile.d/extract.sh27
-rw-r--r--dotfiles/system/.profile.d/framework.sh10
-rw-r--r--dotfiles/system/.profile.d/freebsd.sh10
-rw-r--r--dotfiles/system/.profile.d/fzf.sh76
-rw-r--r--dotfiles/system/.profile.d/git.sh24
-rw-r--r--dotfiles/system/.profile.d/media.sh41
11 files changed, 377 insertions, 0 deletions
diff --git a/dotfiles/system/.profile.d/auto-tmux-session.sh b/dotfiles/system/.profile.d/auto-tmux-session.sh
new file mode 100644
index 0000000..2f17085
--- /dev/null
+++ b/dotfiles/system/.profile.d/auto-tmux-session.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# auto-tmux-session.sh
+# Craig Jennings <c@cjennings.net>
+# if TRAMP (ssh dumb terminal), simplify prompt, and start tmux.
+
+# start tmux when logging in via ssh
+if [[ -z "$TMUX" ]] && [ "$SSH_CONNECTION" != "" ]; then
+ export TERM="xterm-mono"
+ # if dumb terminal (i.e., tramp), then set a simple prompt, otherwise set monochrome TERM and start tmux
+ tmux attach-session -t "$USER" || tmux new-session -s "$USER"
+fi
diff --git a/dotfiles/system/.profile.d/chronographic.sh b/dotfiles/system/.profile.d/chronographic.sh
new file mode 100644
index 0000000..d53fe2b
--- /dev/null
+++ b/dotfiles/system/.profile.d/chronographic.sh
@@ -0,0 +1,116 @@
+#!/bin/sh
+
+# chronographic.sh
+# Craig Jennings <c@cjennings.net>
+# quick and dirty terminal clock, timer, alarm and stopwatch functions
+
+alias beep='paplay $BEEP'
+export BEEP="/usr/share/sounds/freedesktop/stereo/bell.oga"
+
+##
+## CLOCK
+##
+
+clock() {
+ while true; do tput clear; echo ""; date +" %l : %M %p" | figlet -f roman -w 200 ; sleep 1; done
+}
+
+##
+## TIMER
+##
+
+timer() {
+ # Ensure we have at least two arguments
+ if [ "$#" -lt 2 ]; then
+ echo "Pass the time and a notification. Example: timer 1h30m Parking expiring"
+ return 1
+ fi
+ message="${@:2}"
+ start_time=$(date +"%H:%M:%S %p")
+ printf "\nStarting %s timer at $start_time\n" "$1"
+ snore "$1" && paplay "$BEEP" && notify-send "Timer" "$message" && echo ""
+}
+
+##
+## ALARM
+##
+
+alarm() {
+ # Ensure we have two or more arguments
+ if [ "$#" -lt 2 ]; then
+ echo "Pass both the time and a message. Example: alarm 1:45pm Time to eat!"
+ return 1
+ fi
+
+ # Validate the first argument is a valid time
+ ! date -d "$1" >/dev/null 2>&1 && echo "Invalid time: $1" && return 1
+
+ # silently schedule the command using 'at' command
+ echo "paplay \$BEEP && notify-send \"Alarm\" \"$@\"" | at "$1" >> /dev/null
+ echo "Alarm '${@:2}' is queued for $1." && echo "To see all alarms, issue the command: atq" && echo ""
+}
+
+##
+## STOPWATCH FUNCTIONS
+##
+
+sw_start_time=0
+sw_started=0
+
+swreset() {
+ sw_start_time=0
+ sw_started=0
+ echo "Stopwatch reset"
+}
+
+swshow() {
+ if [ "$sw_started" = 0 ] ; then
+ echo "Error: Stopwatch not started" >&2 && return 1
+ fi
+
+ current_time=$(date +%s)
+ elapsed_time=$((current_time - sw_start_time))
+
+ if (( elapsed_time < 60 )); then
+ # Display elapsed time in seconds
+ echo "Elapsed time: $elapsed_time seconds"
+ elif (( elapsed_time < 3600 )); then
+ # Display elapsed time in minutes and seconds
+ minutes=$((elapsed_time / 60))
+ seconds=$((elapsed_time % 60))
+ echo "Elapsed time: $minutes minutes, $seconds seconds"
+ else
+ # Display elapsed time in hours, minutes, and seconds
+ hours=$((elapsed_time / 3600))
+ minutes=$(((elapsed_time / 60) % 60))
+ seconds=$((elapsed_time % 60))
+ echo "Elapsed time: $hours hours, $minutes minutes, and $seconds seconds"
+ fi
+}
+
+swstop() {
+ swshow
+ swreset
+}
+
+swstart() {
+ if [ "$sw_started" = 1 ] ; then
+ printf "Stopwatch is already started. Reset? (y/n): "
+ read -r answer
+ if [ "$answer" = "y" -o "$answer" = "Y" ]; then
+ swreset
+ # continue on to start the new timer
+ elif [ "$answer" = "n" -o "$answer" = "N" ]; then
+ echo "Stopwatch not reset."
+ swshow
+ # return to avoid restarting the timer
+ return
+ else
+ echo "Error: Invalid input. Exiting." >&2 && return 1
+ fi
+ fi
+
+ sw_started=1
+ sw_start_time=$(date +%s)
+ printf "Stopwatch started at %s\n\n" "$(date +"%H:%M:%S %p")"
+}
diff --git a/dotfiles/system/.profile.d/dd.sh b/dotfiles/system/.profile.d/dd.sh
new file mode 100644
index 0000000..5390a65
--- /dev/null
+++ b/dotfiles/system/.profile.d/dd.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# dd.sh
+# Craig Jennings <c@cjennings.net>
+# takes input and output files as arguments
+# prints parameters needed for dd
+
+
+dd_with_bs() {
+ OUT_DIR=$(dirname "$2")
+ if [ ! -e "$1" -o ! -e "$OUT_DIR" ]; then
+ echo "$1 or $OUT_DIR doesn't exist"
+ return 1
+ fi
+ IN_BS=$(stat -c "%o" "$1")
+ OUT_BS=$(stat -c "%o" "$OUT_DIR")
+
+ echo dd \"if=$1\" \"of=$2\" \"ibs=$IN_BS\" \"obs=$OUT_BS\"
+}
diff --git a/dotfiles/system/.profile.d/display.sh b/dotfiles/system/.profile.d/display.sh
new file mode 100644
index 0000000..ce5016e
--- /dev/null
+++ b/dotfiles/system/.profile.d/display.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# display.sh
+# Craig Jennings <c@cjennings.net>
+# UI Appearance settings, sourced by .profile
+
+# Theme
+export GTK_THEME=Adwaita:dark
+export QT_QPA_PLATFORMTHEME=qt5ct
diff --git a/dotfiles/system/.profile.d/emacs.sh b/dotfiles/system/.profile.d/emacs.sh
new file mode 100644
index 0000000..c70d928
--- /dev/null
+++ b/dotfiles/system/.profile.d/emacs.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# emacs.sh
+# Craig Jennings <c@cjennings.net>
+# Emacs specific settings, sourced by .profile
+
+### INFO FILES
+export INFOPATH="$HOME/.config/emacs/info:/usr/share/info:/usr/local/share/info"
+
+### WORKAROUND
+# https://unix.stackexchange.com/questions/230238/x-applications-warn-couldnt-connect-to-accessibility-bus-on-stderr
+# emacs/gtk interaction bug workaround
+export NO_AT_BRIDGE=1
+
+# WAKE UTILITY
+# useful when emacs or elisp doesn't timeout.
+alias emacswake='for i in `seq 1 500`; do killall -s USR2 emacs; done' # wake emacs from a freeze
+
+### VTERM
+# Vterm uses some features (e.g., directory-tracking and prompt-tracking or message passing) that require shell-side configurations.
+# This functions enables the shell to send information to vterm via properly escaped sequences.
+
+vterm_printf(){
+ if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ] ); then
+ # Tell tmux to pass the escape sequences through
+ printf "\ePtmux;\e\e]%s\007\e\\" "$1"
+ elif [ "${TERM%%-*}" = "screen" ]; then
+ # GNU screen (screen, screen-256color, screen-256color-bce)
+ printf "\eP\e]%s\007\e\\" "$1"
+ else
+ printf "\e]%s\e\\" "$1"
+ fi
+}
diff --git a/dotfiles/system/.profile.d/extract.sh b/dotfiles/system/.profile.d/extract.sh
new file mode 100644
index 0000000..5fce587
--- /dev/null
+++ b/dotfiles/system/.profile.d/extract.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# extract.sh
+# Craig Jennings <c@cjennings.net>
+# convenience extraction function
+
+## EXTRACT
+
+extract () {
+ if [ -f "$1" ] ; then
+ case "$1" in
+ *.tar.bz2) tar xjf "$1" ;;
+ *.tar.gz) tar xzf "$1" ;;
+ *.bz2) bunzip2 "$1" ;;
+ *.rar) rar x "$1" ;;
+ *.gz) gunzip "$1" ;;
+ *.tar) tar xf "$1" ;;
+ *.tbz2) tar xjf "$1" ;;
+ *.tgz) tar xzf "$1" ;;
+ *.zip) unzip "$1" ;;
+ *.Z) uncompress "$1" ;;
+ *) echo "$1 cannot be extracted via extract()" ;;
+ esac
+ else
+ echo "$1 is not a valid file"
+ fi
+}
diff --git a/dotfiles/system/.profile.d/framework.sh b/dotfiles/system/.profile.d/framework.sh
new file mode 100644
index 0000000..2b8895e
--- /dev/null
+++ b/dotfiles/system/.profile.d/framework.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# framework.sh
+# Craig Jennings <c@cjennings.net>
+# settings for Framework 13 specific issues
+
+# HiDPI scale settings for Framework 13 Laptop
+export GDK_DPI_SCALE=1 # text scaling only.
+export GDK_SCALE=1 # this is an integer, 1 or 2 etc
+export QT_AUTO_SCREEN_SCALE_FACTOR=1
diff --git a/dotfiles/system/.profile.d/freebsd.sh b/dotfiles/system/.profile.d/freebsd.sh
new file mode 100644
index 0000000..8d12031
--- /dev/null
+++ b/dotfiles/system/.profile.d/freebsd.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# freebsd.sh
+# Craig Jennings <c@cjennings.net>
+# Settings FreeBSD specific, sourced by .profile
+
+# make delete do the right thing for freebsd
+if echo "$(uname)" | grep -q "FreeBSD"; then
+ bindkey "\e[3~" delete-char
+fi
diff --git a/dotfiles/system/.profile.d/fzf.sh b/dotfiles/system/.profile.d/fzf.sh
new file mode 100644
index 0000000..5a13dd4
--- /dev/null
+++ b/dotfiles/system/.profile.d/fzf.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+# fzf.sh
+# Craig Jennings <c@cjennings.net>
+# fuzzy find settings and utilities, sourced by .profile
+
+### SETTINGS
+export FZF_DEFAULT_OPTS='--height=70%'
+export FZF_DEFAULT_COMMAND='rg --files'
+export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
+export FZF_DEFAULT_COMMAND='rg --files --no-ignore-vcs --hidden'
+
+
+### NAVIGATION
+
+# cdff - change directory find file
+# change to the directory where the file resides.
+cdff() {
+
+ file=$(fzf +m -q "$1")
+ dir=$(dirname "$file")
+ cd "$dir" || exit
+}
+
+# CD to a directory with fzf
+cdd () {
+ destdir=$(find "${1:-.}" -path '*/\.*' -prune \
+ -o -type d -print 2> /dev/null | fzf +m) &&
+ cd "$destdir"
+}
+
+### SYSTEM ADMIN
+
+# Kill a process with fzf
+kp () {
+ pid=$(ps -ef | sed 1d | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[kill:process]'" | awk '{print $2}')
+
+ if [ "x$pid" != "x" ]
+ then
+ echo "$pid" | xargs kill -${1:-9}
+ kp
+ fi
+}
+
+# list available packages, show info in preview, and install selection
+yinstall() {
+ yay -Slq | fzf --multi --preview 'yay -Si {1}' | xargs -ro yay -S --noconfirm
+}
+
+
+yinstall-skipverify() {
+ yay -Slq | fzf --multi --preview 'yay -Si {1}' | xargs -ro yay -S --noconfirm --mflags --skipinteg
+}
+
+# list installed packages, show info in preview, and remove selection
+yrm() {
+ yay -Qq | fzf --multi --preview 'yay -Qi {1}' | xargs -ro yay -Rns
+}
+
+# find-in-file - usage: fif <searchTerm>
+fif() {
+ if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi
+ rg --files-with-matches --no-messages "$1" | fzf --preview "highlight -O ansi -l {} 2> /dev/null | rg --colors 'match:bg:yellow' --ignore-case --pretty --context 10 '$1' || rg --ignore-case --pretty --context 10 '$1' {}"
+}
+
+### CONVENIENCE
+
+# Find a book in the calibre library and open it in emacs client.
+# previously: find ~/books \( -iname \*.epub -o -iname \*.pdf -o -iname \*.djvu \) | fzf | xargs emacs
+bk() {
+ bkfile=$(find ~/sync/books/ \( -iname "*.pdf" -o -iname "*.epub" -o -iname "*.djvu" \) -print | fzf)
+ if [ -n "$bkfile" ]; then
+ emacsclient -c -a '' "$bkfile" &
+ fi
+}
+
diff --git a/dotfiles/system/.profile.d/git.sh b/dotfiles/system/.profile.d/git.sh
new file mode 100644
index 0000000..7332ba1
--- /dev/null
+++ b/dotfiles/system/.profile.d/git.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# git.sh
+# Craig Jennings <c@cjennings.net>
+# git settings and convenience aliases, sourced by .profile
+
+alias gitlog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
+alias gitstatus='git status -sb '
+alias gitcom='git commit -m '
+alias gitpp='git pull --prune ' # clean up any orphaned git objects
+alias gittagbydate="git for-each-ref --sort=creatordate --format '%(refname) %(creatordate)' refs/tags"
+
+gitsp() {
+ git stash && git pull && git stash pop
+}
+
+gitck() {
+ git checkout "$(git branch --all | fzf| tr -d '[:space:]')"
+}
+
+gitdiff() {
+ preview="git diff $@ --color=always -- {-1}"
+ git diff "$@" --name-only | fzf -m --ansi --preview "$preview"
+}
diff --git a/dotfiles/system/.profile.d/media.sh b/dotfiles/system/.profile.d/media.sh
new file mode 100644
index 0000000..3add213
--- /dev/null
+++ b/dotfiles/system/.profile.d/media.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# media.sh
+# Craig Jennings <c@cjennings.net>
+# utilities for working with media (music, video, books, etc.)
+
+
+### TERMINAL MPV ALIASES
+alias play='mpv --no-video'
+alias shuffle='mpv --no-video --shuffle '
+
+
+### YOUTUBE AND TIDAL
+# Leverage task spooler to download url targets serially in the background.
+# example : % stdl "https://youtu.be/gv-3Y7CcUUo"
+# note that zshell urls must be quoted; not so for bash.
+
+# tidal-dl
+alias tdl="tidal-dl -l"
+alias ttdl="tsp tidal-dl -l"
+
+# youtube-dl
+alias yt="yt-dlp --ignore-config --no-playlist --add-metadata -i -o '%(channel)s-%(title)s.%(ext)s'"
+alias tyt="tsp yt-dlp --ignore-config --no-playlist --add-metadata -i -o '%(channel)s-%(title)s.%(ext)s'"
+
+alias ytp="yt-dlp --ignore-config --yes-playlist --add-metadata -i -o '%(channel)s-%(playlist_title)s-%(playlist_index)s-%(title)s.%(ext)s'"
+alias tytp="tsp yt-dlp --ignore-config --yes-playlist --add-metadata -i -o '%(channel)s-%(playlist_title)s-%(playlist_index)s-%(title)s.%(ext)s'"
+
+alias yta="yt-dlp --ignore-config --no-playlist -x -f bestaudio/best -o '%(artist)s-%(title)s.%(ext)s'"
+alias tyta="tsp yt-dlp --ignore-config --no-playlist -x -f bestaudio/best -o '%(artist)s-%(title)s.%(ext)s'"
+
+alias ytap="yt-dlp --ignore-config --yes-playlist -x -f bestaudio/best -o '%(playlist_index)s-%(artist)s-%(title)s.%(ext)s'"
+alias tytap="tsp yt-dlp --ignore-config --yes-playlist -x -f bestaudio/best -o '%(playlist_index)s-%(artist)s-%(title)s.%(ext)s'"
+
+
+### SOUND FILE CONVERSION
+# converts audible aax to other formats. Requires AAXtoMP3 script in dotfiles.
+
+alias aax2flac='AAXtoMP3 -f '
+alias aax2mp3='AAXtoMP3 -c -e:mp3 '
+alias aax2opus='AAXtoMP3 --opus -t . -c '