Skip to content

Commit 693fe97

Browse files
committed
reorg shell config files
1 parent 0a4a8f6 commit 693fe97

11 files changed

+172
-154
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Dotfiles managed by [chezmoi](https://www.chezmoi.io/).
55
```shell
66
$ sh -c "$(curl -fsLS 'get.chezmoi.io')" -- -b '.' \
77
&& ./chezmoi init --apply 'rvenutolo'
8-
&& source '~/.bash_profile'
8+
&& source '~/.bashrc'
99
```

dot_config/bash/alias_completion.bash

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
22

3+
## NOTE TO SELF
4+
## This is not being used. Instead I am using: https://github.com/cykerway/complete-alias
5+
36
# based on:
47
# http://superuser.com/questions/436314/how-can-i-get-bash-to-perform-tab-completion-for-my-aliases
58

dot_config/bash/aliases.bash

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env bash
22

3-
## sudo
3+
# sudo
44
alias sudo='sudo '
55
alias sued='sudo --edit'
66
alias please='sudo $(fc -ln -1)'
77
alias plz='please'
88

9-
## cd
9+
# cd
1010
alias cd..='cd ..'
1111
alias ..='cd ..'
1212
alias ...='cd ../..'
@@ -27,7 +27,7 @@ alias s='cl ${SCRIPTS_DIR}'
2727
alias d='cl ${CODE_DIR}/Personal/dotfiles'
2828
alias bd='cd "$OLDPWD"'
2929

30-
## ls
30+
# ls
3131
if __executable_exists 'exa'; then
3232
alias exa='exa --classify --group-directories-first --icons --header --time-style=long-iso --color-scale --git'
3333
alias ls='exa'
@@ -64,7 +64,7 @@ else
6464
alias la1='ls --almost-all -1'
6565
fi
6666

67-
## cp, mv, rm, mkdir, trash
67+
# cp, mv, rm, mkdir, trash
6868
alias mkdir='mkdir --parents --verbose'
6969
alias cp='cp --verbose'
7070
alias mv='mv --verbose'
@@ -75,7 +75,7 @@ else
7575
alias rm='rm --verbose'
7676
fi
7777

78-
## chown, chmod, chgrp
78+
# chown, chmod, chgrp
7979
alias chown='chown --preserve-root'
8080
alias chmod='chmod --preserve-root'
8181
alias chax='chmod a+x'
@@ -90,35 +90,35 @@ alias 755='chmod --recursive 755'
9090
alias 775='chmod --recursive 775'
9191
alias chgrp='chgrp --preserve-root'
9292

93-
## grep
93+
# grep
9494
alias grep="grep --exclude-dir='.*' --colour=auto"
9595
alias egrep='grep --extended-regexp'
9696
alias fgrep='grep --fixed-strings'
9797

98-
## tar
98+
# tar
9999
alias mktar='tar --create --verbose --file'
100100
alias mkbz2='tar --create --verbose --bzip2 --file'
101101
alias mkgz='tar --create --verbose --gzip --file'
102102
alias untar='tar --extract --verbose --file'
103103
alias unbz2='tar --extract --verbose --bzip2 --file'
104104
alias ungz='tar --extract --verbose --gzip --file'
105105

106-
## ps
106+
# ps
107107
alias psa='ps aux'
108108
alias psaf='ps auxf'
109109

110-
## journalctl, systemctl
110+
# journalctl, systemctl
111111
alias jc='journalctl'
112112
alias jce='jounralctl --priority=3'
113113
alias sc='systemctl'
114114
alias scu='systemctl --user'
115115

116-
## editors
116+
# editors
117117
alias k='kate'
118118
alias m='micro'
119119
alias n='nano'
120120

121-
## misc - shorter alias
121+
# misc - shorter alias
122122
alias g='git'
123123
alias o='xdg-open'
124124
alias q='exit'
@@ -129,10 +129,10 @@ alias hh='hstr'
129129
alias ms='manswitch'
130130
alias cls='clear'
131131

132-
## misc - replace commands
132+
# misc - replace commands
133133
alias which='type'
134134

135-
## misc - adds flags
135+
# misc - adds flags
136136
alias type='type -a'
137137
alias du='du --total --human-readable --block-size=1K'
138138
alias df='df --block-size=1K --print-type --human-readable --exclude-type squashfs'
@@ -144,7 +144,7 @@ alias tree='tree -Cph --si'
144144
alias shfmt='shfmt --list --indent 2 --case-indent --binary-next-line --space-redirects --write'
145145
alias xdg-ninja='xdg-ninja --skip-unsupported'
146146

147-
## misc - other
147+
# misc - other
148148
alias cm='chezmoi'
149149
alias du1='du --max-depth=1'
150150
alias bs='br --sizes'

dot_config/bash/exports.bash.tmpl

-108
This file was deleted.

dot_config/bash/profile.bash

-11
This file was deleted.

dot_config/bash/rc.bash

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env bash
22

3+
if [[ -z "${PROFILE_SOURCED-}" ]]; then
4+
source "${HOME}/.profile"
5+
fi
6+
37
# if not running interactively, don't do anything
48
[[ "$-" != *i* ]] && return
59

@@ -65,6 +69,17 @@ shopt -u shift_verbose
6569
shopt -s sourcepath
6670
shopt -u xpg_echo
6771

72+
# history
73+
export HISTCONTROL='ignorespace:ignoredups'
74+
export HISTIGNORE='ls:ll:lla:pwd:bg:fg:history:h:exit:q:pwd:clear:cls:update:brc:dl:home:c'
75+
export HISTSIZE='100000'
76+
export HISTFILESIZE="${HISTSIZE}"
77+
export HISTTIMEFORMAT='%F %T%t'
78+
export HISTFILE="${XDG_STATE_HOME}/bash/history"
79+
if [[ ! -d "$(dirname "${HISTFILE}")" ]]; then
80+
mkdir --parents "$(dirname "${HISTFILE}")"
81+
fi
82+
6883
# functions used in my bash config files
6984
function __executable_exists() {
7085
type -aPf "$1" > /dev/null 2>&1
@@ -85,13 +100,13 @@ function __path_prepend() {
85100
# my files to source
86101
for file in \
87102
"${XDG_CONFIG_HOME}/bash/functions.bash" \
88-
"${XDG_CONFIG_HOME}/bash/exports.bash" \
89103
"${XDG_CONFIG_HOME}/bash/aliases.bash" \
90104
"${XDG_CONFIG_HOME}/bash/local.bash"; do
91105
if __is_readable_file "${file}"; then
92106
source "${file}"
93107
fi
94108
done
109+
unset -v file
95110

96111
# app files to source
97112
for file in \
@@ -103,6 +118,7 @@ for file in \
103118
source "${file}"
104119
fi
105120
done
121+
unset -v file
106122

107123
# completions to source
108124
for file in \
@@ -118,22 +134,7 @@ for file in \
118134
source "${file}"
119135
fi
120136
done
121-
122-
# dirs to put on path
123-
for dir in \
124-
"$(if __executable_exists 'ruby'; then echo "$(ruby -e 'puts Gem.user_dir')/bin"; else echo ''; fi)" \
125-
"$(if __executable_exists 'go'; then echo "$(go env GOPATH)/bin"; else echo ''; fi)" \
126-
"$(if [[ -n "${CARGO_HOME}" ]]; then echo "${CARGO_HOME}/bin"; else echo ''; fi)" \
127-
"${HOME}/.local/bin" \
128-
"${SCRIPTS_DIR}/other" \
129-
"${SCRIPTS_DIR}/main"; do
130-
if [[ -n "${dir}" && -d "${dir}" ]]; then
131-
__path_prepend "${dir}"
132-
fi
133-
done
134-
135-
# create dirs that may not exist (need to use `command` because `mkdir` is aliased)
136-
command mkdir --parents "$(dirname "${HISTFILE}")"
137+
unset -v file
137138

138139
# misc init stuff
139140
__is_readable_file "${XDG_CONFIG_HOME}/dircolors" && eval "$(dircolors "${XDG_CONFIG_HOME}/dircolors")"
@@ -148,6 +149,8 @@ if __is_readable_file "${XDG_CONFIG_HOME}/bash/complete_alias.bash"; then
148149
complete -F _complete_alias "${!BASH_ALIASES[@]}"
149150
fi
150151

152+
## TODO deal with this
153+
#export PROMPT_COMMAND='history -a; history -n'
151154
## TODO submit PR to address unbound variables?
152155
## TODO re-enable starship
153156
#STARSHIP_PREEXEC_READY=false
@@ -158,6 +161,5 @@ if __is_readable_file "${XDG_CONFIG_HOME}/bash/prompt.bash"; then
158161
source "${XDG_CONFIG_HOME}/bash/prompt.bash"
159162
fi
160163

161-
# clean up vars & functions
162-
unset -v file dir shell_option initial_shell_options initial_pipefail_option
164+
# clean up functions
163165
unset -f __executable_exists __is_readable_file __path_append __path_prepend __path_remove

0 commit comments

Comments
 (0)