Skip to content

Commit

Permalink
Breaking: Change default config dir to ~/.config/shell
Browse files Browse the repository at this point in the history
Sorry, breaking change.
  • Loading branch information
sgleizes committed Jul 1, 2022
1 parent 98915cb commit d239e04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ and **runcoms**.

Shells are the first class citizens of xsh. Configuration for specific shells
resides in a directory under `$XSH_CONFIG_DIR` matching that shell's name.
The default value of `XSH_CONFIG_DIR` is `$XSH_DIR`, which must point to the
location of the xsh repository. The default location is `~/.config/xsh`.
The default value of `XSH_CONFIG_DIR` is `~/.config/shell`.
This document uses `<shell>` to refer to shell directories.

Each shell directory must contain an initialization file named `init.<ext>`.
Expand Down Expand Up @@ -236,14 +235,15 @@ for that shell.
git clone https://github.com/sgleizes/xsh ~/.config/xsh
```

The default location of the `xsh` directory is
The default location of the `xsh` repository is
`${XDG_CONFIG_HOME:-$HOME/.config}/xsh`. If you wish to use a different location,
the `XSH_DIR` environment variable must be set to that location before your
user's login shell is started, for instance in `~/.pam_environment`.

Also if you want to store your shell configuration at a different location than
in the xsh repository (the default), you can set the `XSH_CONFIG_DIR` environment
variable. This must also be set before your user's login shell is started.
The default location of your shell configuration is
`${XDG_CONFIG_HOME:-$HOME/.config}/shell`. If you want to store it at a
different location, you can set the `XSH_CONFIG_DIR` environment variable. This
must also be set before your user's login shell is started.

### Bootstrap the desired shell(s)

Expand Down Expand Up @@ -287,7 +287,7 @@ bootstrap operation. For simple cases it can be quickly migrated into the
default module by using commands from the following snippet:

```sh
XSH_CONFIG_DIR="${XSH_CONFIG_DIR:-${XSH_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/xsh}}"
XSH_CONFIG_DIR="${XSH_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/shell}"

# For POSIX shells
cp "$HOME/.profile.~1~" "$XSH_CONFIG_DIR/posix/core/@login.sh"
Expand Down Expand Up @@ -591,18 +591,22 @@ for little benefit.

#### Using a different directory for user configuration

If you use `git` to version your shell configuration, keeping it inside the xsh
repository would be problematic. Or maybe you just want a separation of
concerns.

You can specify the location of your shell configuration using the
`XSH_CONFIG_DIR` environment variable. Note that this must be set before your
user's login shell is started (e.g. in `~/.pam_environment`).

Setting it to `$HOME/.config` or `$HOME/.config/shell` will result in a
If you prefer to have it all in one place, you can store shell configuration in
the same directory than the xsh repository (in fact this used to be the
default).

However, if you use `git` to version your shell configuration, keeping it inside
the xsh repository would be problematic.

Setting it to `$HOME/.config` or `$HOME/.config/shell` (the default) will result
in a
[XDG-compliant](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
configuration structure, with the configuration for each shell residing in
`~/.config/<shell>` or `~/.config/shell/<shell>`.
structure, with the configuration for each shell residing in `~/.config/<shell>`
or `~/.config/shell/<shell>`.

#### Using custom runcom types for additional configuration layers

Expand Down
4 changes: 2 additions & 2 deletions xsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ XSHELL="${XSHELL#-}" # remove leading '-' for login shells
# global value, if any. This would prevent processes started from xsh units to
# properly inherit the global value.
XSH_DIR="${XSH_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/xsh}"
XSH_CONFIG_DIR="${XSH_CONFIG_DIR:-$XSH_DIR}"
XSH_CONFIG_DIR="${XSH_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/shell}"
XSH_RUNCOM_PREFIX="${XSH_RUNCOM_PREFIX:-@}"

# A simple framework for shell configuration management.
Expand All @@ -61,7 +61,7 @@ XSH_RUNCOM_PREFIX="${XSH_RUNCOM_PREFIX:-@}"
# -v, --verbose Set XSH_VERBOSE, see below.
# Globals:
# XSH_DIR Base xsh repository directory (default: ~/.config/xsh).
# XSH_CONFIG_DIR Base xsh configuration directory (default: $XSH_DIR).
# XSH_CONFIG_DIR Base xsh configuration directory (default: ~/.config/shell).
# XSH_RUNCOM_PREFIX Prefix for module runcom files (default: @).
# XSH_SHELLS Colon-separated list of shell candidates to lookup for units.
# XSH_BENCHMARK Enable benchmarking the loading time of runcoms and units.
Expand Down

0 comments on commit d239e04

Please sign in to comment.