You can customize LS_COLORS if you want, but I've never been mad at the defaults. Also, I prefer c-style escapes, which allows you to copy and paste the filename and use it in other commands:<p><pre><code> alias ls='ls --color=auto -F -b -T 0 -A'
-F classify entries with (*/=>@|)
-b use c-style escapes instead of quoting
-T 0 do not use tabs for alignment
-A show all dotfiles except . and ..
</code></pre>
Plus, I find colors to be insanely useful when my old eyes try to read 'ip' output, so I really do prefer:<p><pre><code> alias ip='ip --color=auto'</code></pre>
My main aliases are: a more human-friendly ls and an alias of rm which attempts to detect mistakes:<p><pre><code> alias l='command ls -Av1h --color=always --time-style=long-iso --group-directories-first'
# -A: show all, including dotfiles, except . and ..
# -v: natural sort of number
# -1 (one): list (use -l for long version)
# -h: human-readable sizes
alias rm='command rm -Iv'
# -I: prompt once before removing more than three files or recursively
# -v: verbose
</code></pre>
I redefine also $HISTFILE to ensure that every shell get its own temporary history:<p><pre><code> HISTFILE="${XDG_RUNTIME_DIR:-/tmp}/shell-history-$$"</code></pre>
<a href="https://chezmoi.io" rel="nofollow">https://chezmoi.io</a> is a dotfile manager that is runs on multiple OSes (including Windows) while handling differences from machine to machine, allows you to store your secrets in your password manager (so you don't have to store secrets in your dotfile repo), and it even supports the NO_COLOR environment variable. Check it out! Disclaimer: I'm the author.<p>There's a comprehensive list of the most popular dotfile managers at <a href="https://dotfiles.github.io/utilities/" rel="nofollow">https://dotfiles.github.io/utilities/</a>.
One tip for your .bashrc I only recently found out and can't do without anymore is one I picked up here (log all shell commands directly to a file): <a href="https://www.jefftk.com/p/you-should-be-logging-shell-history" rel="nofollow">https://www.jefftk.com/p/you-should-be-logging-shell-history</a>
The mention of .plan and .project brings back memories. You used to be able to do things like finger dhosek@ymir.claremont.edu and see if I was logged on and what I had to share with the world (which was a long series of quotes that ran several screens). I remember learning that the AMS had shorter hours on Fridays thanks to Barbara Beeton’s .plan file.
> Then I have a .xsessionrc which needs to exist because I now log in through xdm, and the window manager (fluxbox) ends up inheriting <i>that</i> environment. Yep, it doesn't get a .bashrc type thing applied to it. (Not gonna lie - this took a while to figure out.<p>I've grown fond of just logging in via the tty and invoking startx... it's always there, even when your graphics drivers fail. I tried messing with xdms a long time ago when transitioning to i3wm, but it was just extra configuration, noise and inconsistency to sort out, without really gain anything useful for what is a single person machine. Simple is good.
<i>The stock PS1 bugged me a bit, so I mangled it down to this</i><p>That's not too far from this one which I use and have seen quite a few others use too --- really hate a lot of the newer defaults that hide the full path for some reason, and managed to convince a coworker who accidentally edited the file of the same name in the same directory with a different path to use it too:<p><pre><code> '\u@\h:\w$ '
</code></pre>
Also I should mention that in this era of constant telemetry^Wspyware and tracking, everything you say can and will be used to identify or correlate you, and that does include using non-default configuration. Of course, how much this matters depends on the context in which you say it.
> Quick, which of .bashrc, .bash_profile, .profile et al get run for any given type of login you do to a box?<p>I appear to have just given up and symlinked them together. Anyone have a better idea?<p>Edit: Actually, my profile apparently has a conditional to detect what shell it's loaded by (which I did remember), and for at least bash a conditional to detect interactive mode (which I did not). So I'm still dealing with this, just not at the file level.
No colours? Any non-coloured terminal feels dead to me.<p>Half of the things I do in my dot files are related to adding colours.<p>Including some long colour parameter string to be used with midnight commander.
I wrote a gist about a year ago that discusses installing various tools into MacOS -- powerlevel10k prompt, fzf, ripgrep, difftastic, some git aliases, asdf and more: <a href="https://gist.github.com/aclarknexient/0ffcb98aa262c585c49d4b3f3ae24019" rel="nofollow">https://gist.github.com/aclarknexient/0ffcb98aa262c585c49d4b...</a><p>Wow, it has 40 stars! I'm kind of shocked, I think it was way under 20 last time I looked. :) Feeling pretty good about that, if I've helped just that many people, then I feel like writing that was more than worth it!
I learned a lot from Kali Linux's zshrc [0]. But then I'm certainly no expert in customizing my shell environment, as I usually mostly stick with the distro's defaults. Still, now mine is a bit nicer. It also includes the `ip --color=auto` thing, which is mentioned in other comments and which I hadn't known about either.<p>[0] <a href="https://gist.github.com/Anon-Exploiter/4e12193df0099183d18720c6471d571a" rel="nofollow">https://gist.github.com/Anon-Exploiter/4e12193df0099183d1872...</a>
I share the same annoyance with quoting but avoid it differently by setting<p><pre><code> export QUOTING_STYLE=literal
</code></pre>
This means I don't have to be clever about thinking if I need to pass -N to ls depending which OS I'm on.
Anyone else here managing his "dot files" with an Ansible playbook? In my environments files like .bashrc only contain a few statements that source other scripts where I inject / template my actual configuration.
Put your PATH into .profile when you want it to apply to your whole session.<p><a href="https://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile/183980#183980" rel="nofollow">https://superuser.com/questions/183870/difference-between-ba...</a><p><a href="https://superuser.com/questions/789448/choosing-between-bashrc-profile-bash-profile-etc/789705#789705" rel="nofollow">https://superuser.com/questions/789448/choosing-between-bash...</a>
Haha wow. I have a full color prompt with oh my zsh and starship. Overall, I like it though I don't really need a lot of it.<p>The error code highlight and duration of last command are nice.
I'm on so many different machines (mostly some embedded stuff/RasPis that need linux) that I ignore all these bad defaults.<p>The only thing I find unbearable is vimdiff colors, that have the SAME or very similar foreground and background so it's impossible to read. (I don't remember, but believe it's just on some distros)
How do people manage their custom bash profile across machines.<p>Currently I just add a small if statement that checks if my custom file with all my little aliases I have put together over the years is there it sources it. Is there a better way?
I group different kind of settings under particular files. My .bashrc has `source ~/.rc.d/pyenvrc`, `source ~/.rc.d/gitrc` and so on which can help to organize yourself if you have too many custom settings.<p>I also have a very tiny set of useful functions that I might occasionally use from some scripts. For example:<p><pre><code> # Changes the current working directory to the running script.
cd_running_script_dir() {
cd "$(dirname "$(readlink -f "$0")")"
}
# Display an error message and abort the running script.
#
# Arguments:
# $1: A string with error to be displayed before aborting.
abort() {
ERROR=$1
>&2 echo "${ERROR}"
kill $$
}
# Return a program's full path if exists or display an error
# message and abort script execution.
#
# Arguments:
# $1: A string with the program's name to be looked up.
get_program() {
PROGRAM_NAME=$1
PROGRAM_PATH=$(which "${PROGRAM_NAME}")
if [ -z "${PROGRAM_PATH}" ]; then
abort "Error - ${PROGRAM_NAME} is not installed."
fi
echo "${PROGRAM_PATH}"
unset PROGRAM_PATH
unset PROGRAM_NAME
}
</code></pre>
Given the sort of subtle nature of sh that for example misplacing a whitespace or a character can render a whole script wrong, from time to time I add these snippets so I can entirely forget how to do some regular things by sourcing `~/.scripts/lib.sh`. It's also a great way to extend your sh knowledge and learn about customizing your environment.<p>Yes these are silly functions, but their main purpose is to make sh snippets more readable.<p>Because I don't like to always display the same wallpaper over and over again my .xinitrc contains:<p><pre><code> "${HOME}/.scripts/set-random-background" &
</code></pre>
which is:<p><pre><code> #!/usr/bin/env sh
# Randomly sets a wallpaper from a directory containing images.
#
# Usage:
# ./set-random-background
# Adjust global settings accordingly.
WALLPAPERS_PATH="${HOME}/.scripts/assets/wallpapers"
set_random_background() {
FEH=$(get_program "feh")
if [ -d "${WALLPAPERS_PATH}" ]; then
WALLPAPER=$(ls "${WALLPAPERS_PATH}"/* | sort --random-sort | head -n1)
if [ -n "${WALLPAPER}" ]; then
${FEH} --no-fehbg --bg-center --bg-scale "${WALLPAPER}"
fi
fi
}
main() {
if [ -n "${BASH_LIB}" ]; then
. "${BASH_LIB}"
set_random_background
fi
}
main</code></pre>