Skip to content

Instantly share code, notes, and snippets.

@samueldr
Last active February 19, 2018 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueldr/911401d1005c581599cec4e32dabf7b2 to your computer and use it in GitHub Desktop.
Save samueldr/911401d1005c581599cec4e32dabf7b2 to your computer and use it in GitHub Desktop.
Home profile / bashrc / bash_profile setup
#!/bin/bash
# Description:
# This script is executed for login shells.
#From man bash:
# When bash is invoked as an interactive login shell, or as a non-inter‐
# active shell with the --login option, it first reads and executes com‐
# mands from the file /etc/profile, if that file exists. After reading
# that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
# in that order, and reads and executes commands from the first one that
# exists and is readable. The --noprofile option may be used when the
# shell is started to inhibit this behavior.
# Sources the user's personal profile, bash will not source it as this
# script already exists.
[ -e ~/.profile ] && source ~/.profile
# When an interactive shell that is not a login shell is started, bash
# reads and executes commands from ~/.bashrc, if that file exists. This
# may be inhibited by using the --norc option. The `--rcfile file` option
# will force bash to read and execute commands from `file` instead of
# ~/.bashrc.
#Sources the rc script
[[ $- == *i* ]] && [ -e ~/.bashrc ] && source ~/.bashrc
#!/usr/bin/env bash
# Just to be safe, if not running interactively, don't do anything
[[ $- != *i* ]] && return
# Note:
# My personal .dotfiles package will source the bashrc script from bash_profile
# for interactive login shells. Login and non-login shells will then be equals.
# Fix for missing .profile sourcing
# shellcheck disable=SC1091
[[ -z "${XDG_DATA_HOME:-}" ]] && . ~/.profile
# ... HERE, ADD ANYTHING FOR THE BASH SHELL
# DON'T do environment manipulations, do those in ~/.profile
#!/bin/bash
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# The files are located in the bash-doc package.
# This file should not have any ill-advised effect when not used with bash.
# This file should be sourced by your .bash_profile otherwise bash will not read it.
# These files are for setting the USER-WIDE environment.
#!/bin/bash
# This file is not *as* standard as the others.
#
# The Debian reference manual describes how the defaults work:
# 1. If the user has a ~/.xsessionrc file, read it.
# 2. If a specific session was selected in gdm3, run it.
# 3. Otherwise, if the user has a ~/.xsession or ~/.Xsession file, run it.
# ...
#
# Sources
# - https://wiki.debian.org/Xsession
# - https://github.com/sddm/sddm/blob/0ef0df7e7140d182b4df6087692498486de7a094/data/scripts/Xsession#L65
source ~/.profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment