about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--bash/aliases.bash3
-rw-r--r--bash/bashrc1
-rw-r--r--bash/functions.bash43
-rw-r--r--bash/prompt.bash20
-rw-r--r--bash/vterm-emacs.bash23
-rw-r--r--git/config108
-rw-r--r--profile/00_functions.sh62
-rw-r--r--profile/01_path.sh6
-rw-r--r--profile/etc.sh2
-rw-r--r--profile/go.sh2
-rw-r--r--profile/infopath.sh8
-rw-r--r--profile/manpath.sh16
-rw-r--r--profile/path.sh30
-rw-r--r--profile/profile10
-rw-r--r--profile/xdg.sh7
15 files changed, 226 insertions, 115 deletions
diff --git a/bash/aliases.bash b/bash/aliases.bash index 59e76d3..7875574 100644 --- a/bash/aliases.bash +++ b/bash/aliases.bash
@@ -24,3 +24,6 @@ alias lake='make PREFIX=~/usr'
24 24
25# bash meta 25# bash meta
26alias rebash='source ~/.bash_profile' 26alias rebash='source ~/.bash_profile'
27
28# Debugging
29alias emacs_goddamnit='pushd ~/.emacs.d;emacs --debug-init;popd'
diff --git a/bash/bashrc b/bash/bashrc index e167fee..f9f17e7 100644 --- a/bash/bashrc +++ b/bash/bashrc
@@ -10,6 +10,7 @@ BASH_SOURCE_FIRST=(
10 10
11BASH_SOURCE_LAST=( 11BASH_SOURCE_LAST=(
12 blesh 12 blesh
13 vterm-emacs
13) 14)
14 15
15for f in "${BASH_SOURCE_FIRST[@]}"; do 16for f in "${BASH_SOURCE_FIRST[@]}"; do
diff --git a/bash/functions.bash b/bash/functions.bash index 5e99a82..98872f2 100644 --- a/bash/functions.bash +++ b/bash/functions.bash
@@ -1,8 +1,8 @@
1# Functions 1# Functions
2 2
3memq() { # memq ITEM ARRAY 3memq() { # memq ITEM ARRAY
4 # Test whether an ITEM is a member of ARRAY. 4 ## Test whether an ITEM is a member of ARRAY.
5 # Pass ARRAY as ${ARRAY[@]}. 5 ## Pass ARRAY as ${ARRAY[@]}.
6 local e needle="$1"; shift 6 local e needle="$1"; shift
7 for e; do 7 for e; do
8 [[ "$e" == "$needle" ]] && { 8 [[ "$e" == "$needle" ]] && {
@@ -12,15 +12,34 @@ memq() { # memq ITEM ARRAY
12 return 1 12 return 1
13} 13}
14 14
15rebashrc() { # rebashrc
16 ## Reload ~/.bashrc
17 printf "Loading ~/.bashrc..." >&2
18 if source "$HOME/.bashrc"; then
19 echo "OK." >&2
20 else
21 echo "ERROR!" >&2
22 fi
23}
24
25first_which() { # first_which COMMAND...
26 ## Return the fully-qualified path of the first COMMAND found in $PATH.
27 while :; do
28 command -v "$1" && break
29 [ -z "$1" ] && return 1
30 shift
31 done
32}
33
15please() { # please [COMMAND...] 34please() { # please [COMMAND...]
16 # if run without arguments, run the last command with 'sudo' (aka sudo !!) 35 # if run without arguments, run the last command with 'sudo' (aka sudo !!)
17 # if run WITH arguments, alias as sudo 36 # if run WITH arguments, alias as sudo
18 history -d -1 37 history -d -1
19 if [ -z "$1" ]; then 38 if [ -z "$1" ]; then
20 #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q') 39 #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q')
21 set -- $(fc -lnr | sed 1q) 40 set -- $(fc -lnr | sed 1q)
22 fi 41 fi
23 echo >&2 sudo "$@" 42 echo >&2 sudo "$@"
24 history -s sudo "$@" 43 history -s sudo "$@"
25 "${DEBUG:-false}" || sudo "$@" 44 "${DEBUG:-false}" || sudo "$@"
26} 45}
diff --git a/bash/prompt.bash b/bash/prompt.bash index 02d9c98..f1bdd69 100644 --- a/bash/prompt.bash +++ b/bash/prompt.bash
@@ -4,7 +4,7 @@ PS1=
4 4
5# user, host, and cwd 5# user, host, and cwd
6PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') 6PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...')
7PS1+='\[\e[34m\]# \u@\h \w' 7PS1+='\[\e[0;46m\]\u@\h \w'
8 8
9# git bit 9# git bit
10# see https://unix.stackexchange.com/questions/278206 10# see https://unix.stackexchange.com/questions/278206
@@ -16,13 +16,11 @@ possible_git_prompt_locations=(
16) 16)
17 17
18for file in "${possible_git_prompt_locations[@]}"; do 18for file in "${possible_git_prompt_locations[@]}"; do
19 if [[ -f "$file" ]]; then 19 if [[ -f "$file" ]]; then
20 source "$file" && 20 source "$file" &&
21 PS1+='\[\e[35m\]$(__git_ps1)' 21 PS1+='\[\e[35m\]$(__git_ps1)'
22 break 22 break
23 else 23 fi
24 true
25 fi
26done 24done
27 25
28# newline 26# newline
@@ -30,9 +28,9 @@ PS1+='\[\e[0m\]\n'
30 28
31# exit code (only if error) 29# exit code (only if error)
32__prompt_exit_code() { 30__prompt_exit_code() {
33 local ec=$? 31 local ec=$?
34 (( $ec > 0 )) && 32 (( $ec > 0 )) &&
35 printf "$ec" 33 printf "$ec"
36} 34}
37PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' 35PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]'
38 36
diff --git a/bash/vterm-emacs.bash b/bash/vterm-emacs.bash new file mode 100644 index 0000000..88d3e09 --- /dev/null +++ b/bash/vterm-emacs.bash
@@ -0,0 +1,23 @@
1# shell-side configuration for Emacs vterm module
2# https://github.com/akermu/emacs-libvterm#shell-side-configuration
3# Make sure this is the last file loaded by ~/.bashrc!
4
5# Load the requisite code from the vterm install directory
6if [[ "$INSIDE_EMACS" = 'vterm' ]] \
7 && [[ -n ${EMACS_VTERM_PATH} ]] \
8 && [[ -f ${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh ]]; then
9 source ${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh
10fi
11
12# Extra commands for `vterm-eval-cmds'
13
14find_file() {
15 vterm_cmd find-file "$(realpath "${@:-.}")"
16}
17
18say() {
19 vterm_cmd message "%s" "$*"
20}
21
22
23
diff --git a/git/config b/git/config index 4ea5ba7..dbec691 100644 --- a/git/config +++ b/git/config
@@ -1,92 +1,92 @@
1[user] 1[user]
2 email = acdw@acdw.net 2 email = acdw@acdw.net
3 name = Case Duckworth 3 name = Case Duckworth
4 4
5[init] 5[init]
6 defaultBranch = main 6 defaultBranch = main
7 7
8[push] 8[push]
9 default = simple 9 default = simple
10 10
11[pull] 11[pull]
12 rebase = false 12 rebase = false
13 13
14[core] 14[core]
15 editor = vim 15 editor = emacsclient
16 precomposeunicode = true 16 precomposeunicode = true
17 pager = less 17 pager = less
18 autocrlf = false 18 autocrlf = false
19 eol = lf 19 eol = lf
20 20
21[merge] 21[merge]
22 conflictstyle = diff3 22 conflictstyle = diff3
23 tool = vimdiff 23 tool = vimdiff
24 24
25[alias] 25[alias]
26 # Easier locations 26 # Easier locations
27 root = rev-parse --show-toplevel 27 root = rev-parse --show-toplevel
28 current-branch = rev-parse --abbrev-ref HEAD 28 current-branch = rev-parse --abbrev-ref HEAD
29 # Easier listing and info 29 # Easier listing and info
30 branches = branch -a 30 branches = branch -a
31 tags = tag -l 31 tags = tag -l
32 stashes = stash list 32 stashes = stash list
33 remotes = remote -v 33 remotes = remote -v
34 staged = diff --cached 34 staged = diff --cached
35 graph = log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset: %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order 35 graph = log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset: %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order
36 precommit = diff --cached --diff-algorithm=minimal -w 36 precommit = diff --cached --diff-algorithm=minimal -w
37 # Easier actions 37 # Easier actions
38 discard = checkout -- 38 discard = checkout --
39 uncommit = reset --soft HEAD^ 39 uncommit = reset --soft HEAD^
40 unstage = reset HEAD -- 40 unstage = reset HEAD --
41 amend = commit --amend 41 amend = commit --amend
42 pushall = !git remote | xargs -L1 git push --all 42 pushall = !git remote | xargs -L1 git push --all
43 # Shortened commonalities 43 # Shortened commonalities
44 st = status -bs 44 st = status -bs
45 ac = !git add . && git commit -m 45 ac = !git add . && git commit -m
46 46
47# diffing 47# diffing
48[diff "lisp"] 48[diff "lisp"]
49 xfuncname = "^(\\(.*)$" 49 xfuncname = "^(\\(.*)$"
50[diff "org"] 50[diff "org"]
51 xfuncname = "^(\\*+.*)$" 51 xfuncname = "^(\\*+.*)$"
52 52
53; [credential] 53; [credential]
54; helper = /home/case/.local/bin/pass-git-helper 54; helper = /home/case/.local/bin/pass-git-helper
55; useHttpPath = true 55; useHttpPath = true
56 56
57[bash] 57[bash]
58 showUntrackedFiles = true 58 showUntrackedFiles = true
59 showDirtyState = true 59 showDirtyState = true
60 60
61[sendemail] 61[sendemail]
62 smtpserver = smtp.fastmail.com 62 smtpserver = smtp.fastmail.com
63 smtpuser = acdw@fastmail.com 63 smtpuser = acdw@fastmail.com
64 smtpencryption = tls 64 smtpencryption = tls
65 smtpserverport = 465 65 smtpserverport = 465
66 66
67# Better urls 67# Better urls
68[url "https://github.com/"] 68[url "https://github.com/"]
69 insteadOf = "gh:" 69 insteadOf = "gh:"
70[url "git@github.com:"] 70[url "git@github.com:"]
71 pushInsteadOf = "gh:" 71 pushInsteadOf = "gh:"
72[github] 72[github]
73 user = duckwork 73 user = duckwork
74 74
75[url "https://gitlab.com/"] 75[url "https://gitlab.com/"]
76 insteadOf = "gl:" 76 insteadOf = "gl:"
77[url "git@gitlab.com:"] 77[url "git@gitlab.com:"]
78 pushInsteadOf = "gl:" 78 pushInsteadOf = "gl:"
79[gitlab] 79[gitlab]
80 user = acdw 80 user = acdw
81 81
82[url "https://git.sr.ht/"] 82[url "https://git.sr.ht/"]
83 insteadOf = "sr:" 83 insteadOf = "sr:"
84[url "git@git.sr.ht:"] 84[url "git@git.sr.ht:"]
85 pushInsteadOf = "sr:" 85 pushInsteadOf = "sr:"
86 86
87[url "https://tildegit.org/"] 87[url "https://tildegit.org/"]
88 insteadOf = "tg:" 88 insteadOf = "tg:"
89[url "git@tildegit.org:"] 89[url "git@tildegit.org:"]
90 pushInsteadOf = "tg:" 90 pushInsteadOf = "tg:"
91[gitea "tildegit.org/api/v1"] 91[gitea "tildegit.org/api/v1"]
92 user = acdw 92 user = acdw
diff --git a/profile/00_functions.sh b/profile/00_functions.sh new file mode 100644 index 0000000..a94eaee --- /dev/null +++ b/profile/00_functions.sh
@@ -0,0 +1,62 @@
1# utility functions for all shells
2# these should be POSIX-compatible.
3
4# add a path to PATH, but only if it's not already there
5path_add_to_PATH() { # path_add [-a] PATH...
6 # -a appends (default is prepend)
7 APPEND=false
8 if [ "x$1" = "x-a" ]; then
9 APPEND=true
10 shift
11 fi
12
13 for p; do
14 case ":$PATH:" in
15 *:"$p":*) ;;
16 *)
17 if $APPEND; then
18 PATH="$PATH:$p"
19 else
20 PATH="$p:$PATH"
21 fi
22 ;;
23 esac
24 done
25
26 unset APPEND
27}
28
29# Generalization of `path_add_to_PATH' for any variable.
30path_add_unsafe() { #path_add_unsafe [-a] [-d DELIM] VAR PATH...
31 ## Add PATH... to VAR, delimiting with DELIM (default :).
32 # By default, the VAR will be prepended to; passing -a will append the
33 # variable. -d DELIM defines the delimiter.
34 #
35 # This function has the _unsafe suffix because it uses `eval' to set
36 # variables.
37 APPEND=false; DELIM=:
38 while getopts ad: opt; do
39 case "$opt" in
40 a) APPEND=true ;;
41 d) DELIM="$OPTARG" ;;
42 *) return 1 ;;
43 esac
44 done
45 shift $(expr $OPTIND - 1)
46
47 var="$1"; shift
48
49 for path; do
50 case ":$(eval "echo \$$var"):" in
51 *:"$path":*) ;;
52 *)
53 if $APPEND; then
54 eval "$var=\$$var${var:+$DELIM}$path"
55 else
56 eval "$var=$path${var:+$DELIM}\$$var"
57 fi
58 ;;
59 esac
60 done
61 unset -v APPEND DELIM var
62}
diff --git a/profile/01_path.sh b/profile/01_path.sh new file mode 100644 index 0000000..8082cc6 --- /dev/null +++ b/profile/01_path.sh
@@ -0,0 +1,6 @@
1# PATH
2
3# see 00_functions.sh for `path_add'
4path_add_to_PATH "$HOME/bin" "$HOME/usr/bin"
5
6command -v luarocks >/dev/null 2>&1 && path_add "$HOME/.luarocks/bin"
diff --git a/profile/etc.sh b/profile/etc.sh index b91c4c8..0546fe2 100644 --- a/profile/etc.sh +++ b/profile/etc.sh
@@ -2,7 +2,7 @@
2 2
3export GUILE_INSTALL_LOCALE=0 3export GUILE_INSTALL_LOCALE=0
4export TZ=America/Chicago 4export TZ=America/Chicago
5export QT_STYLE_OVERRIDE=adwaita-qt 5#export QT_STYLE_OVERRIDE=adwaita-qt
6export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/keyring/ssh" 6export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/keyring/ssh"
7 7
8export CDPATH=:~ # thanks june :) 8export CDPATH=:~ # thanks june :)
diff --git a/profile/go.sh b/profile/go.sh new file mode 100644 index 0000000..077833e --- /dev/null +++ b/profile/go.sh
@@ -0,0 +1,2 @@
1export GOPATH="${XDG_DATA_HOME:=$HOME/.local/share}/go"
2command -v go >/dev/null 2>&1 && path_add_to_PATH "$(go env GOPATH)/bin"
diff --git a/profile/infopath.sh b/profile/infopath.sh index ad1ec3f..80080b8 100644 --- a/profile/infopath.sh +++ b/profile/infopath.sh
@@ -1 +1,7 @@
1export INFOPATH="/usr/share/info:${XDG_DATA_HOME:-$HOME/.local/share}/info" 1# See 00_functions.sh for `path_add_unsafe'.
2
3path_add_unsafe INFOPATH \
4 /usr/share/info \
5 "${XDG_DATA_HOME:-$HOME/.local/share}/info"
6
7export INFOPATH
diff --git a/profile/manpath.sh b/profile/manpath.sh index def1963..944059c 100644 --- a/profile/manpath.sh +++ b/profile/manpath.sh
@@ -1,9 +1,15 @@
1# $MANPATH shouldn't be too extra complicated (as opposed to $PATH), 1# See 00_functions.sh for `path_add_unsafe'.
2# so I'm not going to include a whole other function. AT SOME POINT, 2
3# I suppose I should generalize that function to set /any/ path-type 3path_add_unsafe MANPATH \
4# variable, not just $PATH. 4 "${XDG_DATA_HOME:-$HOME/.local/share}/man" \
5 "$HOME/.local/local/man" \
6 "$HOME/usr/local/man"
7
5# $MANPATH ends with `:' so that manpath(1) will prepend it to its 8# $MANPATH ends with `:' so that manpath(1) will prepend it to its
6# special thing. 9# special thing.
10case "$MANPATH" in
11 *:) ;;
12 *) MANPATH="$MANPATH:" ;;
13esac
7 14
8MANPATH="${XDG_DATA_HOME:-$HOME/.local/share}/man:"
9export MANPATH 15export MANPATH
diff --git a/profile/path.sh b/profile/path.sh deleted file mode 100644 index 56bdc39..0000000 --- a/profile/path.sh +++ /dev/null
@@ -1,30 +0,0 @@
1# PATH
2
3# add a path to PATH, but only if it's not already there
4path_add() { # path_add [-a] PATH...
5 # -a appends (default is prepend)
6 APPEND=false
7 if [ "x$1" = "x-a" ]; then
8 APPEND=true
9 shift
10 fi
11
12 for p; do
13 case ":$PATH:" in
14 *:"$p":*) ;;
15 *)
16 if $APPEND; then
17 PATH="$PATH:$p"
18 else
19 PATH="$p:$PATH"
20 fi
21 ;;
22 esac
23 done
24
25 unset APPEND
26}
27
28path_add "$HOME/bin" "$HOME/usr/bin"
29
30command -v luarocks >/dev/null 2>&1 && path_add "$HOME/.luarocks/bin"
diff --git a/profile/profile b/profile/profile index 121615f..a531e8e 100644 --- a/profile/profile +++ b/profile/profile
@@ -18,3 +18,13 @@ if [ -d "$XDG_CONFIG_HOME/profile" ]; then
18 [ -r "$file" ] && . "$file" 18 [ -r "$file" ] && . "$file"
19 done 19 done
20fi 20fi
21
22# refresh profile
23reprofile() {
24 printf "Loading ~/.profile..." >&2
25 if . "$HOME/.profile"; then
26 echo "OK." >&2
27 else
28 echo "ERROR!" >&2
29 fi
30}
diff --git a/profile/xdg.sh b/profile/xdg.sh index 7d0ed61..71ab6bb 100644 --- a/profile/xdg.sh +++ b/profile/xdg.sh
@@ -13,7 +13,7 @@ export LESSHISTFILE="$XDG_CACHE_HOME"/less/history
13mkdir -p "$XDG_CACHE_HOME"/less 13mkdir -p "$XDG_CACHE_HOME"/less
14 14
15# Vim 15# Vim
16export VIMINIT="let \$MYVIMRC=\"$XDG_CONFIG_HOME/vim/vimrc\" | source \$MYVIMRC" 16export VIMINIT="source ${XDG_CONFIG_HOME:=$HOME/.config}/vim/vimrc"
17 17
18# Weechat 18# Weechat
19export WEECHAT_HOME="$XDG_CONFIG_HOME/weechat" 19export WEECHAT_HOME="$XDG_CONFIG_HOME/weechat"
@@ -23,3 +23,8 @@ export LYNX_CFG="$XDG_CONFIG_HOME/lynx/lynx.cfg"
23 23
24# Xorg 24# Xorg
25export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$HOME}" 25export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$HOME}"
26export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc"
27export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc"
28
29# Notmuch
30export NOTMUCH_CONFIG="${XDG_CONFIG_HOME:=$HOME/.config}/notmuch/config"