Skip to content

Commit

Permalink
Cover all bashrc in shfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jul 28, 2023
1 parent 5a820b2 commit 4c68d3b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cmd/fmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
}
fsys := os.DirFS(wd)

bashPaths, err := doublestar.Glob(fsys, "./**/*.bash")
bashPaths, err := doublestar.Glob(fsys, "./**/{*.bash,.bash*}")
if err != nil {
log.Fatalln(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
}
fsys := os.DirFS(wd)

bashPaths, err := doublestar.Glob(fsys, "./**/*.bash")
bashPaths, err := doublestar.Glob(fsys, "./**/{*.bash,.bash*}")
if err != nil {
log.Fatalln(err)
}
Expand Down
3 changes: 2 additions & 1 deletion home/.bash_logout
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# ~/.bash_logout: executed by bash(1) when login shell exits.

# when leaving the console clear the screen to increase privacy

if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
84 changes: 42 additions & 42 deletions home/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ HISTFILESIZE=4200000
# nix develop # the executed nix-shell does NOT have problems, so you can wrap as starship
# bash # this nested bash HAS problems without following ps... condition.
if [[ -n "$IN_NIX_SHELL" && "$(ps -o uid= $PPID)" -eq "$UID" ]]; then
in_nested_nix_bash="true"
in_nested_nix_bash="true"
fi

# check the window size after each command and, if necessary,
Expand All @@ -62,7 +62,7 @@ shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
Expand All @@ -76,44 +76,44 @@ esac
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

if [ "$color_prompt" = yes ] && [ -z "$in_nested_nix_bash" ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\w\$ '
PS1='${debian_chroot:+($debian_chroot)}\w\$ '
fi
unset color_prompt force_color_prompt

if [ -z "$in_nested_nix_bash" ]; then
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm* | rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)} \w\a\]$PS1"
;;
*) ;;

esac
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm* | rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)} \w\a\]$PS1"
;;
*) ;;

esac
fi

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
(test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)") || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
(test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)") || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
Expand All @@ -134,46 +134,46 @@ alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
. ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix && [ -z "$in_nested_nix_bash" ]; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi

if [ -e "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"; fi

# https://github.com/Bash-it/bash-it/blob/00062bfcb6c6a68cd2c9d2c76ed764e01e930e87/plugins/available/history-substring-search.plugin.bash
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
bind '"\e[A":history-substring-search-backward'
bind '"\e[B":history-substring-search-forward'
bind '"\e[A":history-substring-search-backward'
bind '"\e[B":history-substring-search-forward'
fi

if command -v fzf-share >/dev/null && [ -z "$in_nested_nix_bash" ]; then
source "$(fzf-share)/key-bindings.bash"
source "$(fzf-share)/completion.bash"
source "$(fzf-share)/key-bindings.bash"
source "$(fzf-share)/completion.bash"
fi

# # Delegate history search with "Up arrow key" to fzf
# bind '"\C-\e[A":"\C-r"'

if [ -n "$in_nested_nix_bash" ]; then
# readlink - https://iww.hateblo.jp/entry/20131108/dash
PS1="${IN_NIX_SHELL} - $(readlink /proc/$$/exe)\n$PS1"
# readlink - https://iww.hateblo.jp/entry/20131108/dash
PS1="${IN_NIX_SHELL} - $(readlink /proc/$$/exe)\n$PS1"
else
eval "$(starship init bash)"
eval "$(starship init bash)"
fi

# https://github.com/starship/starship/blob/0d98c4c0b7999f5a8bd6e7db68fd27b0696b3bef/docs/uk-UA/advanced-config/README.md#change-window-title
function set_win_title() {
echo -ne "\033]0; $(basename "$PWD") \007"
echo -ne "\033]0; $(basename "$PWD") \007"
}
# shellcheck disable=SC2034
starship_precmd_user_func="set_win_title"
Expand Down

0 comments on commit 4c68d3b

Please sign in to comment.