Skip to content

guidelines

gcil pre-commit-crocodile guidelines

Guidelines shared for all RadianDevCore projects and for applicable projects.


~/.bashrc

The following guidelines are provided for ~/.bashrc:

  • Limiting changes to ~/.bashrc is recommended to ease updates / system migration
  • Creating ~/.bash_user.rc and including it in ~/.bashrc is recommended
Bind ~/.bash_user.rc
# As user
{
  cat >>~/.bashrc <<EOF

# User bash additions
if [ -f ~/.bash_user.rc ]; then
    . ~/.bash_user.rc
fi
EOF
}

~/.bash_user.rc

The following guidelines are provided for ~/.bash_user.rc:

Prepare ~/.bash_user.rc
# As user
{
  cat >>~/.bash_user.rc <<EOF
# ~/.bash_user.rc
#
# Description: Import user additions from ~/.bashrc with the following lines
#
# # User bash additions
# if [ -f ~/.bash_user.rc ]; then
#     . ~/.bash_user.rc
# fi
EOF
}

Load SSH keychain in terminals

⚠ / This section is optional, use if needed

# As user
{
  # Load SSH keychain
  cat >>~/.bash_user.rc <<EOF

# SSH keychain
if [[ \$- == *i* ]] && [ -x /usr/bin/keychain ]; then
  eval \$(keychain --eval --nogui -q ~/.ssh/id_rsa)
fi
EOF
}

Disable DBus access over SSH

⚠ / This section is optional, use if needed

# As user
{
  # Disable DBus over SSH
  cat >>~/.bash_user.rc <<EOF

# DBus over SSH
if [ ! -z "\${SSH_CLIENT}" ] || [ ! -z "\${SSH_TTY}" ]; then
  export DBUS_SESSION_BUS_ADDRESS=''
fi
EOF
}

Show Git status in prompt

⚠ / This section is optional, use if needed

# As user
{
  # Prepare Git prompt status
  TMP_PS1="${PS1}"
  if echo "${PS1}" | grep -q '__git_ps1'; then
    true
  elif echo "${PS1}" | grep -q '\\w'; then
    TMP_PS1="${TMP_PS1//\w/\w\\[\\033[00m\\]\\[\$(__git_ps1 \" (%s)\") \\]}"
  fi

  # Configure Git prompt status
  cat >>~/.bash_user.rc <<EOF

# Configure Git prompt status
source /etc/bash_completion.d/git-prompt
export GIT_PS1_SHOWCOLORHINTS=1
export GIT_PS1_SHOWCONFLICTSTATE=1
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM=1
export PS1='${TMP_PS1}'
EOF
}

Use nano as default editor

⚠ / This section is optional, use if needed

# As user
{
  # Configure default editor
  cat >>~/.bash_user.rc <<EOF

# Default editor
export EDITOR='nano'
EOF
}