[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Pimp your shell - Debian developer tips?

On Jo, 04 iun 20, 10:13:06, Michael Shuler wrote:
> For many years, I have taken a different approach; use the default and add
> only a few minor changes. Each stable update, I use /etc/skel/.bashrc and
> edit/add in my little bits.

    for config in ~/.config/bash/*; do source "$config"; done

That is the entirety of my ~/.bashrc due to [WONTFIX], which allows you
to drop in symlinks, organise overrides and specify ordering. I'm
definitely bookmarking this thread to steal some useful snippets.

00_skel         -> /etc/skel/.bashrc
10_xdg          # alias dig="HOME=~/.config dig"
arguments       # alias ls='ls --almost-all --color=auto --human-readable'
bash            # see below
git-sh-prompt   -> /usr/lib/git-core/git-sh-prompt
shortcuts       # alias serve='nohup python3 -m http.server &>/dev/null &'
ssh             # see below
ZZ_run          # PROMPT_COMMAND='__git_ps1 "'"${PS1%\\*}"'" "\\\$ "'

## ~/.config/bash/bash
# allow sudo to use local aliases
alias sudo='sudo '
export EDITOR=vim
# infinite bash history (currently c. 1MiB)
export HISTFILE="$HOME/.local/share/bash_history"
export HISTSIZE=
export HISTTIMEFORMAT='[%F %T] '
# more filetypes like .log.1.gz
export LESSCLOSE='/usr/bin/lesspipe %s %s'
export LESSOPEN='| /usr/bin/lesspipe %s'
export PATH="$HOME/bin:$PATH"
shopt -s globstar

## ~/.config/bash/ssh
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"

ensure_known_host() {
	local hostname=$1
	local known_hosts=${2:-~/.ssh/known_hosts}

	ssh-keygen -F "$hostname" -f "$known_hosts" &>/dev/null \
		|| ssh-keyscan -H -t ecdsa "$hostname" \
		| tee --append "$known_hosts"

# hook in a custom git style subcommand
ssh() {
  case $1 in
    tunnel )
      while true; do
        date '+%FT%T'
        command ssh -R 2222:localhost:22 user@server "$@"
    * ) command ssh "$@" ;;

[WONTFIX]: https://savannah.gnu.org/support/?108134

Attachment: signature.asc
Description: PGP signature

Reply to: