diff options
Diffstat (limited to 'dotfiles')
| -rw-r--r-- | dotfiles/system/.profile | 89 | ||||
| -rw-r--r-- | dotfiles/system/.profile.d/chronographic.sh | 116 | ||||
| -rw-r--r-- | dotfiles/system/.profile.d/dd.sh | 19 | ||||
| -rw-r--r-- | dotfiles/system/.profile.d/display.sh | 9 | ||||
| -rw-r--r-- | dotfiles/system/.profile.d/emacs.sh | 23 | ||||
| -rw-r--r-- | dotfiles/system/.profile.d/fzf.sh | 49 | ||||
| -rw-r--r-- | dotfiles/system/.profile.d/git.sh | 2 |
7 files changed, 83 insertions, 224 deletions
diff --git a/dotfiles/system/.profile b/dotfiles/system/.profile index 861ec48..fe3b583 100644 --- a/dotfiles/system/.profile +++ b/dotfiles/system/.profile @@ -1,44 +1,73 @@ # .profile - Bourne Shell startup script for login shells -# -# see also sh(1), environ(7). -# +# Craig Jennings <c@cjennings.net> -# These are normally set through /etc/login.conf. You may override them here -# if wanted. -# PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$HOME/bin; export PATH +# The path is normally set through /etc/login.conf. Override it here if wanted. +# export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$HOME/bin -# Setting TERM is normally done through /etc/ttys. Do only override -# if you're sure that you'll never log in via telnet or xterm or a -# serial line. -# TERM=xterm; export TERM +# Let sh(1) know it's at home, despite /home being a symlink. +if [ "$PWD" != "$HOME" ] && [ "$PWD" -ef "$HOME" ] ; then cd ; fi -EDITOR=vim; export EDITOR -PAGER=less; export PAGER -TERM=foot; export TERM +# Terminal +export TERMINAL="$(which foot)" +#export TERM="vt100" +export TERM="xterm-256color" +export COLORTERM=truecolor +if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi # query terminal size; useful for serial lines. -STOW_DIR=~/code/bsdsetup/dotfiles; export STOW_DIR +# Text Editor +export ALTERNATE_EDITOR="" +export EDITOR="$(which emacs)" +export VISUAL="$(which emacs)" +export SUDO_EDITOR="$(which vi)" +# Browser +export BROWSER="$(which firefox)" -# set ENV to a file invoked each time sh is started for interactive use. -ENV=$HOME/.shrc; export ENV +# XDG +# export XDG_RUNTIME_DIR=/tmp +export XDG_CONFIG_HOME="$HOME/.config/" +export XDG_SESSION_TYPE=wayland +export XDG_CURRENT_DESKTOP=sway +export XDG_DATA_DIRS="$XDG_DATA_DIRS:/usr/share" + # setting up XDG_RUNTIME_DIR is a requirement for sway/wayland +if [ -z "$XDG_RUNTIME_DIR" ]; then + export XDG_RUNTIME_DIR="$HOME/.local/xdg/runtime" + if [ ! -d "$XDG_RUNTIME_DIR" ]; then + mkdir -p "$XDG_RUNTIME_DIR" + chmod 0700 "$XDG_RUNTIME_DIR" + fi +fi -# Let sh(1) know it's at home, despite /home being a symlink. -if [ "$PWD" != "$HOME" ] && [ "$PWD" -ef "$HOME" ] ; then cd ; fi +# misc +export STOW_DIR=~/code/bsdsetup/dotfiles +export PAGER=less +export ENV=$HOME/.shrc # set ENV to a file invoked each time sh is started for interactive use. -# Query terminal size; useful for serial lines. -if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi +##### ALIASES -# Display a random cookie on each login. -# if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune freebsd-tips ; fi +# cd to common directories +alias cdb="cd ~/code/bsdsetup/" +alias cdot="cd ~/code/bsdsetup/dotfiles" +alias cdr='. ranger' # ranger leaves you in destination directory -# must be here for sway/wayland -# export XDG_RUNTIME_DIR=/var/run/user/`id -u` -export XDG_RUNTIME_DIR=/tmp +# sorting aliases for ls +alias lt="ls -lthAF" +alias ll="ls -lhAF" -##### ALIASES +# ranger +alias r='. ranger' -alias cdb="cd ~/code/bsdsetup/" -alias cdd="cd ~/code/bsdsetup/dotfiles" +# miscellaneous +alias myip='curl -4 https://chroot-me.in/ip/ 2> /dev/null || w3m -4 -dump https://chroot-me.in/ip' +alias weather="curl -s wttr.in" +alias ducks='du -cksh * | sort -rh | head -n11' +alias open="xdg-open" +alias stow="stow --target=/home/cjennings" # required as dotfiles in non-standard location -# allows stow to work from dotfile directories in non-standard locations -alias stow="stow --target=/home/cjennings" +# source sh files in .profile.d +PROFILE_D="$HOME/.profile.d/" +if [ -d "$PROFILE_D" ]; then + for file in $(find "$PROFILE_D" -name "*.sh"); do + source "$file" + done +fi diff --git a/dotfiles/system/.profile.d/chronographic.sh b/dotfiles/system/.profile.d/chronographic.sh deleted file mode 100644 index d53fe2b..0000000 --- a/dotfiles/system/.profile.d/chronographic.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/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 deleted file mode 100644 index 5390a65..0000000 --- a/dotfiles/system/.profile.d/dd.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/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 deleted file mode 100644 index ce5016e..0000000 --- a/dotfiles/system/.profile.d/display.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/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 index c70d928..a54a056 100644 --- a/dotfiles/system/.profile.d/emacs.sh +++ b/dotfiles/system/.profile.d/emacs.sh @@ -1,33 +1,10 @@ #!/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/fzf.sh b/dotfiles/system/.profile.d/fzf.sh index 5a13dd4..ea5d3dc 100644 --- a/dotfiles/system/.profile.d/fzf.sh +++ b/dotfiles/system/.profile.d/fzf.sh @@ -1,6 +1,4 @@ #!/bin/sh - -# fzf.sh # Craig Jennings <c@cjennings.net> # fuzzy find settings and utilities, sourced by .profile @@ -11,66 +9,65 @@ export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_DEFAULT_COMMAND='rg --files --no-ignore-vcs --hidden' -### NAVIGATION +### 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 + 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" + 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}') + 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 + 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 + 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 + 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 + 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' {}" + 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 +### 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 + bkfile=$(find ~/sync/books/ \( -iname "*.pdf" -o -iname "*.epub" -o -iname "*.djvu" \) -print | fzf) + if [ -n "$bkfile" ]; then + xdg-open "$bkfile" & + fi } - diff --git a/dotfiles/system/.profile.d/git.sh b/dotfiles/system/.profile.d/git.sh index 7332ba1..42c252d 100644 --- a/dotfiles/system/.profile.d/git.sh +++ b/dotfiles/system/.profile.d/git.sh @@ -15,7 +15,7 @@ gitsp() { } gitck() { - git checkout "$(git branch --all | fzf| tr -d '[:space:]')" + git checkout "$(git branch --all | fzf | tr -d '[:space:]')" } gitdiff() { |
