Fulfilling a reader's request for my “dot files”
rachelbythebay.com
rachelbythebay.com
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 ..
Plus, I find colors to be insanely useful when my old eyes try to read 'ip' output, so I really do prefer: alias ip='ip --color=auto'It helps me, at least.
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git...
I wasn't used to ip over ifconfig until a few years ago anyway lol
Nah, yellow on white is the worst. Authors, please stop assuming everyone uses a dark background (and consider looking up ‘astigmatic halation’).
[0]https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2...
But the one from the BusyBox suite (e.g., the default in Alpine Linux) doesn't have the color option.
The default for o+w directories having a bright green background colour with grey text is kind of annoying to me, I suppose you could argue that o+w directories should be annoying so that you are aware of their existance and risk
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
I redefine also $HISTFILE to ensure that every shell get its own temporary history: HISTFILE="${XDG_RUNTIME_DIR:-/tmp}/shell-history-$$"There's a comprehensive list of the most popular dotfile managers at https://dotfiles.github.io/utilities/.
A deployment script in bash, GNU stow, YADM, dotbot, maybe a couple more.
Chezmoi is where I landed too.
The major gap: Some files belong to external repositories (not all git), and some of these have contents that cross dot-directories. e.g. project repos A and B both contain material that should end up in ~/.local/share and material that should end up in ~/.config.
Using fzf for backwards search sounds interesting, can you elaborate?
My favorite is binding key-up and down to complete using search. That's a game changer
Might sound complex written out like that, but I promise it's worth the investment to set it up and read the manual.
# -------- History --------
#increase bash history
HISTFILESIZE=10000000
HISTTIMEFORMAT="%FT%R "
HISTSIZE=10000000
# append to .bash_history and reread after each command
export PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
# append to .bash_history instead of overwriting
shopt -s histappend
# dont allow repeated lines
export HISTCONTROL=ignoredups:erasedupsI had a friend in university that used a refurbished hp workstation with a shitload of ram as a desktop computer, and he would find | xargs -L1 cat {} > /dev/null everything in his home directory on login to warm up the filesystem cache. The kernel would then drop stuff not actually needed/accessed nicely over time.
Your HISTFILESIZE is also probably not enough: my .full_history goes back to 2012 and is 2.5x your limit.
Anyone else see this in the bash distro? Seems to be a regression.
The fix of course is to simply delete or hack a '#' into the start of the unwanted lines from the default .bashrc.
# Eternal bash history.
# ---------------------
HISTCONTROL=
HISTFILESIZE=
HISTIGNORE=
HISTSIZE=
HISTTIMEFORMAT="%Y-%m-%dT%T%t"
# read global history
HISTFILE=~/.bash_eternal_history
history -r
# IIF there's no session history directory, create one
if [ ! -d ~/.bash_history ]; then
[ -f ~/.bash_history ] && mv ~/.bash_history ~/.bash_history.0
mkdir ~/.bash_history
fi
# change history file to one for the session
HISTFILE=~/.bash_history/$$
# If it already exists, take a backup
if [ -f "$HISTFILE" ]; then
mv "$HISTFILE" "$HISTFILE"."$(stat "$HISTFILE" --format='%W')"
fi
# save the current session id + process id
{ export SESSION_ID="$(</proc/$$/sessionid)"; } 2> /dev/null
printf "#$(date '+%s')"'\n# starting session:'$SESSION_ID' process:'$$' in:'"$PWD"'\n' > "$HISTFILE" &&
history -r
# Use trap to save history, not just on logout but also EXIT
trap_exit() {
# Append session history to global history
## Append to local history session to file
cp -f "$HISTFILE" /tmp/history.$$.0
history -a
cp -f "$HISTFILE" /tmp/history.$$.1
## Append local history file to global history
printf "#$(date '+%s')"'\n# ending session:'$SESSION_ID' process:'$$' in:'"$PWD"'\n' |
cat "$HISTFILE" - >> ~/.bash_eternal_history
}
trap trap_exit EXITI'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.
This sentence is jaw dropping to me. Maybe I'm not the target audience for this sort of ultra minimalist, ultra customised environment, but the concept of requiring a workaround because my graphics drivers aren't functional is something I cannot understand. Why would you willingly work in that environment? In the last decade of being a professional programmer, my graphics drivers have _never_ failed me to that level. They're not perfect, but they _never_ fail to initialise.
It's not a workaround, it's just a perk, when I moved to "ultra customized" as you put it, you don't want to have to configure masses of stuff, i3wm is good for this, it's pretty minimal to configure... an XDM was just more work to configure, but with little utility from my perspective, also I work on the cli a lot so it doesn't feel unnatural to be welcomed by a tty.
And yeah the final perk, Linux wasn't always so compatible, and even in more recent history nVidia graphics drivers can still be problematic. About 10 years ago i think, I used Linux on a 2008 MBP, and freeBSD actually, those things had craptastic nVidia GPUs, you know the batch that came with the first gen unleaded soldier fiasco and when nVidia lied to apple about their thermal specs before they had a falling out and everyone got their GPUs underclocked in firmware to push failures out of warrantee - i digress - anyway the linux support for any nvidia stuff back then was terrible, and very flimsy on dual GPU laptops. For Apple it was more tricky still because you needed to write an Apple specific gmux switcher before even attempting to boot with the nvidia driver, and if that actually worked when you start X then you would lose visual access to your tty because it had no modsetting support... which ironically made using tty instead of an xdm a disadvantage for when the graphics driver failed once in X... I sometimes tried to bring it back to life essentially blindfolded on the tty if X died, mixed success.
Point is, on any laptop with nvidia back then, you usually had to do some level of mucking around on the tty anyway before being able to depend on anything graphical like an xdm... and pray it doesn't break on the next driver update. Frankly right now, we are living in Linux utopia, a lot of hardware "just works".
1) This sort of nonsense is why people don't use these environments
and
2) Just because something worked like that 15 years ago, doesn't mean it's a good reason to still do that now.
I cannot fathom how _anyone_ would tolerate that in a world where Windows and MacOS (and I guess to a certain extent various linux flavors) exist and "just work", for anything other than tinkering.
More is not universally better, there is no functional difference for me starting X via an xdm vs a tty, and as a bonus there is less complexity and _less_ for me to setup... so why would I bother installing one to gain nothing. That doesn't mean I would force everyone to learn how to use a cli and assume this method is appropriate for everyone.
Lol, I've seen how reliably Windows "works"; I'll stick with Linux, thanks. At least FOSS OS always let me find a fix or work around. Granted, I mostly see it these days when relatives ask for help so the sample is biased, but that seems fair considering the conversation here.
I was also graced with having an nvidia gpu which routinely caused trouble. Now I just don't have a gpu as it is too much trouble to deal with them.
It’s been almost ten years now, and i just stay away from nvidia hardware. If a laptoo has an nvidia gpu I’ll look for something else (I don’t care about noveau, if I’m spending money I might as well buy something that just works).
Had a roommate that ran arch (and wouldn’t shut up about it of course) —- he would update the system very often and very often it wouldn’t boot for some reason. One time he had to update a system that hadn’t been updated in a while and he opted for just reinstalling it.
It doesn’t really make sense to me, but I guess some people like it that way?
Linux is literally about user choice, everything but the kernel is up for grabs, and even the kernel if that's what you want.
Arch specifically attracts people who want to learn how things are put together and mess with their system, which are also the kind of people most likely to break things.
Linux distros are about choice.
It is by choice though, if you want everything updated to their latest releases you need to live with some breaking changes here and there
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:
'\u@\h:\w$ '
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.'> %d ' (yes, I use zsh)
Root has '# %d '
Am I odd? I generally find I don't need /that/ much information on the shell.
~>
although it gets progressively richer with heightened context, e.g: username if not my account
hostname if ssh'ing
basename(pwd) (not full path) if not ~
HEAD value (ref or sha) if in git or hg
literal rebase & al for stateful git operation in progress
any of ! ≠ ± (untracked, unstaged, and staged changes)
any of literal nix venv when entering specific contexts
at some point I had it as simple as > but some situations had me wish I knew context right away so I progressively added these each time I had a "fuck, I made a mistake and I would not have if I had that bit of context"I thought I'd go all the way to
;
plan9 rc-style which made sense because "select whole line then paste and run" just works. plus it looks like a wink.I do have colours in a few select areas, but very limited, so that when there are colours they are very meaningful. notably the prompt segments are colour coded by meaning since they're dynamic. my vim theme looks like e-ink, merely getting fancy with a shade of gray for comments (which at some point could be reverted so thar comments get the "focus" and code is toned down, very literal programming)
oh and please: no right prompt, ever (or $COLUMNS-wide left prompt) as it gets wild when resizing; no freaking emoji in my output (e.g I still have that HOMEBRE_NO_EMOJI env var set to an expletive of sorts even though I don't use homebrew anymore)
: ▶
The colon (normally) acts as a no-op, so if you copy and paste an entire line including the prompt and run it, it does nothing.
PS1='%U%m%u:%B%30<..<%~%b%% '
I like to know which host I'm on directly from the shell prompt, as well as the trail end of CWD. You could get close to the same with just '%30d' but then I'd lose the visual cues. And it must have been that way for at least 15 years.\[\033[01;32m\]\n[\w] \j (\u@\h)\n$ \[\033[00m\]
(As you might guess, I do not share the author's distaste for colors. Colors are great. In this one, I picked green.)
I usually have the full path, but I special case a few "well known" paths, like home home shortens to ~
I've also added inter prompt spacing.. first that was just an extra \n before the prompt, but I decided I wanted space between the prompt and the start of program output, as well as between the end of output and the next prompt.
I can't remember where I stole the idea from to give credit, and it feels a little wrong but works really well:
For bash, in PROMPT_COMMAND, set a debug trap that writes a newline, and then removes itself "trap - DEBUG".
If it's not obvious the debug trap fires right after you hit return, but before the command actually runs ( also making it a nice place to update xterm/tmux titles ). So that gets you your post prompt newline, but then because the traps removed it doesn't keep firing for every command in you for loop or whatever. But PROMPT_COMMAND adds the trap again for the next time.
I also have some weird logic in prompt_command that only adds the preprompt newline if the cursor isn't in column 0, because I found otherwise I was getting unnecessary extra spacing.
So yes, if I hit enter on a plain prompt I get two blank lines before the next one.. so?
But it makes differentiating output so much easier. Combine with colour prompts with timestamps ( and in history too ) and I get at least rough timing on how long tasks take, which is often useful.
It's actually on monochrome terminals (for whatever dumb reason that might be happening) that it helps the most, to the point where now when I see a non customised terminal my reaction is "urhg.. what's all this mess, take it away" <shooing wave of hands>
That and pspg for database/csv viewing make my daily life measurably better.
The reality if my life is that I often work with long paths, and having the full path around saves me some pwd fairly often.
I appear to have just given up and symlinked them together. Anyone have a better idea?
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.
https://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-...
It references this blog post:
https://meta.ath0.com/2007/10/23/cleaning-up-bash-customizat...
To make make bash behave in a compatible manner, you need to:
- Delete .bash_profile, so .profile gets sourced instead (works around bash ignoring .profile when .bash_profile exists)
- At the bottom of .profile, call $ENV (works around login bash ignoring bashrc)
- Make .bashrc call or be equal to $ENV
- At the head of $ENV, do an early exit for non-interactive shells (works around bash sourcing the bashrc when invoked non-interactively via SSH or socket, also works around the previous workaround)
In terms of startup logic, bash is the worst shell i've seen so far.
The most customized thing I have is my ssh config. I'm sure I'm missing out on a ton of nice features, and I sometimes regret not learning tools to a larger extend, especially when others shows neat little shortcuts or speedy functions, on the other hand, I don't want the hassle.
1) https://www.urbandictionary.com/define.php?term=riced%20up
Half of the things I do in my dot files are related to adding colours.
Including some long colour parameter string to be used with midnight commander.
Eg Docker defaults to DarkBlue on Black for some status states and it's barely visible on my setup at tge daytime. At night it's just incomprehensible, I need to turn off Night Light or ramp up brightness over 150%.
No, I can't tune my environment, it's always some client's machine.
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!
bash-5.2$ cat .nanorc
set zero
Together with UXTerm.vt100.translations: #override \n\
Ctrl Shift <Key>N: scroll-back(1, halfpage) \n\
Ctrl Shift <Key>T: scroll-forw(1, halfpage) \n\
Ctrl Shift <Key>C: copy-selection(CLIPBOARD) \n\
Ctrl Shift <Key>V: insert-selection(CLIPBOARD) \n\
Ctrl Shift <Key>H: set-altscreen(toggle)
in .Xresources. See[0] https://gist.github.com/Anon-Exploiter/4e12193df0099183d1872...
export QUOTING_STYLE=literal
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.For a longer answer, see https://www.chezmoi.io/user-guide/frequently-asked-questions....
> and often add extra system services or user accounts.
What? I'm less familiar with Puppet, but why would any of this need a service or extra account?
https://superuser.com/questions/183870/difference-between-ba...
https://superuser.com/questions/789448/choosing-between-bash...
The error code highlight and duration of last command are nice.
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)
Allow me to repeat my plea for CLI developers to take a little time to read https://no-color.org and ensure their programs honor things like NO_COLOR, npm config set color false, TERM=dumb, INSIDE_EMACS etc.
Scanning is a skill you acquire with age. As you get older, and you more and more replace word-by-word reading with full-page scanning, colour becomes less attractive.
Less attractive doesn't mean worthless. Colour just needs to carry its weight, by providing enough relevant information to compensate for breaking up scanning flow. So used sparingly, colours can be good.
It's just that no one seems to use colours sparingly. You see things like giving ".gz" (and other compressed) files a different colour. I have no need for that, .gz is just one among a thousand file extensions that I know, I can read the file extension myself thank you very much. Even if I had a great need for recognising compressed files, I couldn't rely on colours for that: Colouring is too inconsistent between applications, whereas scanning text and spotting the .gz extension carries over to almost anything.
I was looking at how my younger colleagues were organising their screens, with IDE tool windows taking up most of it, and leaving no more than about a quarter of the screen to the source code editor, and comparing it to my own workspace, where the source code takes up most of the screen. And it struck me that 25 years ago my workspace looked more like theirs today than mine today. The scanning bit is the explanation I came up with.
Wrt. colour, there's the concept of alarm colours in cognitive psychology. That, at least, should be DDG'able. It's the observation that certain colours, mainly red but also yellow, pull at your attention. This is a hardwired part of human cognition. If there are alarm colours present, then it becomes harder to read the rest of the text, because the alarm colour keeps trying to pull you in.
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?
All dot files are distributed via `vcsh` with the remote `git` repo in a personal `gitea` instance.
I also have a very tiny set of useful functions that I might occasionally use from some scripts. For example:
# 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
}
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.Yes these are silly functions, but their main purpose is to make sh snippets more readable.
Because I don't like to always display the same wallpaper over and over again my .xinitrc contains:
"${HOME}/.scripts/set-random-background" &
which is: #!/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
}
mainThis is my prompt as well, it was the default Slackware prompt, which I’ve also used since the mid 90s.