diff options
author | Case Duckworth | 2022-09-13 18:06:16 -0500 |
---|---|---|
committer | Case Duckworth | 2022-09-13 18:06:16 -0500 |
commit | d2dad3460399150447f8ede875a469cdf7cd5f31 (patch) | |
tree | 0e4d6775270ac06c3920daea9c3a6ae1a04f361c /bash | |
parent | bleh (diff) | |
download | etc-d2dad3460399150447f8ede875a469cdf7cd5f31.tar.gz etc-d2dad3460399150447f8ede875a469cdf7cd5f31.zip |
meh.
Diffstat (limited to 'bash')
-rw-r--r-- | bash/aliases.bash | 19 | ||||
-rw-r--r-- | bash/bashrc | 1 | ||||
-rw-r--r-- | bash/functions.bash | 33 | ||||
-rw-r--r-- | bash/prompt.bash | 80 |
4 files changed, 84 insertions, 49 deletions
diff --git a/bash/aliases.bash b/bash/aliases.bash index 7b5ed55..e29f62a 100644 --- a/bash/aliases.bash +++ b/bash/aliases.bash | |||
@@ -2,15 +2,15 @@ | |||
2 | 2 | ||
3 | # sudo | 3 | # sudo |
4 | sudo_cmds=( | 4 | sudo_cmds=( |
5 | shutdown | 5 | shutdown |
6 | reboot | 6 | reboot |
7 | halt | 7 | halt |
8 | mount | 8 | mount |
9 | umount | 9 | umount |
10 | visudo | 10 | visudo |
11 | ) | 11 | ) |
12 | for cmd in "${sudo_cmds[@]}"; do | 12 | for cmd in "${sudo_cmds[@]}"; do |
13 | alias $cmd="sudo $cmd" | 13 | alias $cmd="sudo $cmd" |
14 | done | 14 | done |
15 | 15 | ||
16 | # LS | 16 | # LS |
@@ -20,7 +20,7 @@ alias ll='ls -l' | |||
20 | alias tree='tree -F' | 20 | alias tree='tree -F' |
21 | 21 | ||
22 | # make locally | 22 | # make locally |
23 | alias lake='make PREFIX=~/usr' | 23 | alias lake='make PREFIX=$HOME/usr ' |
24 | 24 | ||
25 | # bash meta | 25 | # bash meta |
26 | alias rebash='source ~/.bash_profile' | 26 | alias rebash='source ~/.bash_profile' |
@@ -31,5 +31,6 @@ alias emacs_goddamnit='pushd ~/.emacs.d;emacs --debug-init;popd' | |||
31 | # other | 31 | # other |
32 | alias radio=radish | 32 | alias radio=radish |
33 | if ! command -v fd >/dev/null 2>&1; then | 33 | if ! command -v fd >/dev/null 2>&1; then |
34 | alias fd=fdfind | 34 | alias fd=fdfind |
35 | fi | 35 | fi |
36 | |||
diff --git a/bash/bashrc b/bash/bashrc index f9f17e7..63e56d4 100644 --- a/bash/bashrc +++ b/bash/bashrc | |||
@@ -52,4 +52,5 @@ for f in "${BASH_SOURCE_LAST[@]}"; do | |||
52 | fi | 52 | fi |
53 | done | 53 | done |
54 | 54 | ||
55 | #ddate '+%{%A, %d %B%}, %Y%N (%H)' | ||
55 | true | 56 | true |
diff --git a/bash/functions.bash b/bash/functions.bash index c5bcddb..64e8001 100644 --- a/bash/functions.bash +++ b/bash/functions.bash | |||
@@ -48,15 +48,42 @@ please() { # please [COMMAND...] | |||
48 | mkcd() { | 48 | mkcd() { |
49 | if [ $# -lt 1 ]; then | 49 | if [ $# -lt 1 ]; then |
50 | command cd | 50 | command cd |
51 | return | 51 | return "$?" |
52 | fi | ||
53 | if [ "x$1" = x- ]; then | ||
54 | command cd - | ||
55 | return "$?" | ||
52 | fi | 56 | fi |
53 | if ! [ -d "$1" ]; then | 57 | if ! [ -d "$1" ]; then |
54 | read -p "$1 doesn't exist. Create (Y/n)? " yn | 58 | read -p "$1 doesn't exist. Create (y/N)? " yn |
55 | case "$yn" in | 59 | case "$yn" in |
56 | n* | N*) return 1 ;; | 60 | n* | N*) return 1 ;; |
57 | *) mkdir -p "$1" ;; | 61 | y* | Y*) mkdir -p "$1" ;; |
62 | *) return 1 ;; | ||
58 | esac | 63 | esac |
59 | fi | 64 | fi |
60 | command cd "$1" | 65 | command cd "$1" |
61 | } | 66 | } |
62 | alias cd='mkcd ' | 67 | alias cd='mkcd ' |
68 | |||
69 | # from tomasino | ||
70 | # alias julian='echo "x = $(date +%s); scale=5; x / 86400 + 2440587.5" | bc' | ||
71 | julian() { | ||
72 | echo "x = $(date ${1:+-d "$*"} +%s); scale=5; x / 86400 + 2440587.5" | bc | ||
73 | } | ||
74 | |||
75 | # find files for pipelines | ||
76 | f() { | ||
77 | find "${1:-$PWD}" -depth | | ||
78 | while read -r file; do | ||
79 | printf '%q\n' "$file" | ||
80 | done | ||
81 | } | ||
82 | |||
83 | words() { | ||
84 | grep "$1" /usr/share/dict/words | ||
85 | } | ||
86 | |||
87 | dict() { | ||
88 | curl "dict://dict.org/d:$1" | less | ||
89 | } | ||
diff --git a/bash/prompt.bash b/bash/prompt.bash index 15fdb41..06ca638 100644 --- a/bash/prompt.bash +++ b/bash/prompt.bash | |||
@@ -1,42 +1,48 @@ | |||
1 | # bash prompt | 1 | # bash prompt |
2 | 2 | ||
3 | if [[ -n "$INSIDE_EMACS" ]]; then | 3 | if [[ -n "$INSIDE_EMACS" ]]; then |
4 | PS1="\n\[\e[34m\]\$ \[\e[0m\]" | 4 | PS1="\n\[\e[34m\]\$ \[\e[0m\]" |
5 | else | 5 | else |
6 | PS1= | 6 | PS1= |
7 | 7 | ||
8 | # user, host, and cwd | 8 | # user, host, and cwd |
9 | PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') | 9 | PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') |
10 | PS1+='\[\e[0;46m\]\u@\h \w' | 10 | PS1+='\[\e[0;46m\]\u@\h \w' |
11 | 11 | ||
12 | # git bit | 12 | # git bit |
13 | # see https://unix.stackexchange.com/questions/278206 | 13 | # see https://unix.stackexchange.com/questions/278206 |
14 | possible_git_prompt_locations=( | 14 | possible_git_prompt_locations=( |
15 | /usr/share/git/git-prompt.sh # Arch, etc. (default?) | 15 | /usr/share/git/git-prompt.sh # Arch, etc. (default?) |
16 | /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... | 16 | /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... |
17 | /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? | 17 | /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? |
18 | # I have yet to find Alpine's git prompt location. | 18 | # I have yet to find Alpine's git prompt location. |
19 | ) | 19 | ) |
20 | 20 | ||
21 | for file in "${possible_git_prompt_locations[@]}"; do | 21 | for file in "${possible_git_prompt_locations[@]}"; do |
22 | if [[ -f "$file" ]]; then | 22 | if [[ -f "$file" ]]; then |
23 | source "$file" && | 23 | source "$file" && |
24 | PS1+='\[\e[35m\]$(__git_ps1)' | 24 | PS1+='\[\e[35m\]$(__git_ps1)' |
25 | break | 25 | break |
26 | fi | 26 | fi |
27 | done | 27 | done |
28 | 28 | ||
29 | # newline | 29 | # newline |
30 | PS1+='\[\e[0m\]\n' | 30 | PS1+='\[\e[0m\]\n' |
31 | 31 | ||
32 | # exit code (only if error) | 32 | # exit code (only if error) |
33 | __prompt_exit_code() { | 33 | __prompt_exit_code() { |
34 | local ec=$? | 34 | local ec=$? |
35 | (( $ec > 0 )) && | 35 | (($ec > 0)) && |
36 | printf "$ec" | 36 | printf "$ec" |
37 | } | 37 | } |
38 | PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' | 38 | PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' |
39 | 39 | ||
40 | # delimiter | 40 | # terminal title (current directory) |
41 | PS1+='; ' | 41 | __prompt_term_title() { |
42 | printf '\033]0;%s\007\n' "$*" | ||
43 | } | ||
44 | PS1+='\[$(__prompt_term_title "$USER@$(hostname): $PWD")\]' | ||
45 | |||
46 | # delimiter | ||
47 | PS1+='; ' | ||
42 | fi | 48 | fi |