Skip to content

Commit

Permalink
ensure $XDG_CONFIG_HOME exists (#92)
Browse files Browse the repository at this point in the history
* ensure xdg_config_dir exists and chown homedir contents in case contents are owned by root

* define default HISTFILE path
  • Loading branch information
trxcllnt authored Jul 11, 2023
1 parent 6c9c41f commit ce66f7c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions features/src/utils/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ if test -z "${XDG_CACHE_HOME:-}"; then
export XDG_CACHE_HOME="${HOME}/.cache";
fi

# Define XDG_CONFIG_HOME
if test -z "${XDG_CONFIG_HOME:-}"; then
export XDG_CONFIG_HOME="${HOME}/.config";
fi

# Define XDG_STATE_HOME
if test -z "${XDG_STATE_HOME:-}"; then
export XDG_STATE_HOME="${HOME}/.local/state";
fi

# Define HISTFILE
if test -z "${HISTFILE:-}"; then
export HISTFILE="${XDG_STATE_HOME}/._bash_history";
fi

# Default python history to ~/.local/state/.python_history
if test -z "${PYTHONHISTFILE:-}"; then
export PYTHONHISTFILE="${XDG_STATE_HOME}/.python_history";
Expand Down
5 changes: 3 additions & 2 deletions features/src/utils/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ for dir in $(for_each_user_bashrc 'echo "$(dirname "$(realpath -m "$0")")"'); do
cp .gitconfig "${dir}"/.gitconfig;
# Create ~/.cache, i.e. $XDG_CACHE_HOME
mkdir -p -m 0755 "${dir}"/.cache;
# Create ~/.cache, i.e. $XDG_CONFIG_HOME
mkdir -p -m 0755 "${dir}"/.config/{clangd,pip};
# Create ~/.local/state, i.e. $XDG_STATE_HOME
mkdir -p -m 0755 "${dir}"/.local/bin;
mkdir -p -m 0755 "${dir}"/.local/state;
mkdir -p -m 0755 "${dir}"/.local/{bin,state};
# Create or update ~/.ssh/known_hosts
mkdir -p -m 0700 "${dir}"/.ssh;
touch "${dir}"/.ssh/known_hosts;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#! /usr/bin/env bash

find ~/ -maxdepth 1 -exec bash -c '\
[ $(stat --format "%U:%G" "{}") != "$(id -u):$(id -g)" ] \
&& sudo chown -R $(id -u):$(id -g) {}' \;

. devcontainer-utils-init-git;
. devcontainer-utils-vault-s3-init;

0 comments on commit ce66f7c

Please sign in to comment.