Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 0.3-rc
Browse files Browse the repository at this point in the history
  • Loading branch information
pseyfert committed Nov 23, 2018
2 parents 9bbbb3d + cb89e84 commit 004d7ea
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 27 deletions.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,27 @@ Resource | Values | Default | Description
shellex.pos | pointer|focus | focus | If pointer, shellex shows the window on the window, the mousepointer is on, else it uses the output, where most of the currently focused window is (falling back to the pointer-method, if the root-window is focused).
shellex.edge | bottom|top | top | On what screenedge to show shellex

The other source of configuration are small shell-script-snippets. When
starting, `shellex` will look into `$HOME/.shellex` and into `/etc/shellex`. It
will then source all the snippets in either location. If there is an
identically named file in both directories, the one in your home will be
preferred.

This makes for a pretty flexible configuration process: Usually there will be a
lot of snippets in `/usr/lib/shellex/conf`, which should be self-contained and
without a lot of side-effects. In `/etc/shellex` there then are some symlinks
to those snippets, making up the default-configuration on this system, together
with administrator-provided additional defaults. Whenever you don't want a
snippet form `/etc/shellex` to be used, just create a symlink of the same name
to `/dev/null` in `$HOME/.shellex`. If you want to create your own snippets,
just put them in `$HOME/.shellex` under a name not used yet and it will be
automatically sourced.

On start, `shellex` assembles a list of snippet basenames by looking at all of
the paths listed below. For each snippet basename, `shellex` loads the first
file it finds when looking through the paths in order:

1. `$XDG_CONFIG_HOME/.shellex`. Typically unset, defaulting to `$HOME/.config/shellex`.
2. `$HOME/.shellex`
3. `/etc/shellex` (shellex defaults, symlinks to `/usr/shellex/conf/`)

To customize shellex, you can do the following things in
`$XDG_CONFIG_HOME/.shellex` or `$HOME/.shellex/`:

1. Overwrite a default by creating a new snippet of the same name
2. Not include a default by creating a symlink to `/dev/null` of the same same
3. Include an example-snippet not used by default, by creating a symlink to `/usr/shellex/snippet`
4. Write you own snippets with a currently unused name

To avoid naming-conflicts in the future, you should add a common suffix to all
your own snippets. Snippets are run in ascending order. By choosing a number
which sorts between/after the existing snippet(s) you can ensure it runs at the
desired time. E.g. if your snippet beeps on errors, name it 15-errorbeep so that
it sorts before 20-nobeep.

Command-line
============
Expand Down
2 changes: 1 addition & 1 deletion conf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ INSTALL_TARGETS += install-conf install-rc
CLEAN_TARGETS += clean-shellexrc
ALL_TARGETS += conf/shellexrc

default_confs := 10-autoexec 20-nobeep 40-escape 40-home_end 40-setprompt 40-sigint 90-hist 99-clear
default_confs := 10-autoexec 20-completion 20-nobeep 40-escape 40-home_end 40-setprompt 40-sigint 40-recent 90-hist 99-clear

install-conf:
echo "[INSTALL] $@"
Expand Down
4 changes: 4 additions & 0 deletions conf/20-completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# enable tab completion system
# © 2016 Paul Seyfert and contributors (see also: LICENSE)
autoload -U compinit
compinit -C
15 changes: 15 additions & 0 deletions conf/40-recent
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 'ctrl-x r' will complete the 12 last modified (mtime) files/directories
# © 2018 Michael Stapelberg and contributors (see also: LICENSE)

# only add this completion if compinit has been called
if [[ -v _comps ]]
then
# 'ctrl-x r' will complete the 12 last modified (mtime) files/directories
zle -C newest-files complete-word _generic
bindkey '^Xr' newest-files
zstyle ':completion:newest-files:*' completer _files
zstyle ':completion:newest-files:*' file-patterns '*~.*(omN[1,12])'
zstyle ':completion:newest-files:*' menu select yes
zstyle ':completion:newest-files:*' sort false
zstyle ':completion:newest-files:*' matcher-list 'b:=*' # important
fi
18 changes: 14 additions & 4 deletions conf/shellexrc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@
# . means "only regular files"
# -. means "regular files and symlinks pointing to regular files"
# N means "empty list in case of no matches"
thefiles=(@SYSCONFDIR@/shellex/* $HOME/.shellex/*(-.N))
thefiles=(
@SYSCONFDIR@/shellex/*
${XDG_CONFIG_HOME:-$HOME/.config}/shellex/*(-.N)
$HOME/.shellex/*(-.N)
)

# get the basenames of all files and make unique list
# http://stackoverflow.com/a/9516801
uniquified=( $( for f in "${thefiles[@]}" ; do basename $f ; done | sort -u ) )

# source each file from $HOME/.shellex if it exists there, otherwise from /etc
# source each file from the first of:
# 1. $XDG_CONFIG_HOME/.shellex (typically $HOME/.config/shellex)
# 2. $HOME/.shellex
# 3. @SYSCONFDIR@/shellex
for f in $uniquified
do
# -r checks if file exists and is readable
if [[ -r $HOME/.shellex/$f ]]
# -r checks if file exists and is readable
if [[ -r ${XDG_CONFIG_HOME:-$HOME/.config}/shellex/$f ]]
then
source $HOME/.config/shellex/$f
elif [[ -r $HOME/.shellex/$f ]]
then
source $HOME/.shellex/$f
else
Expand Down
19 changes: 13 additions & 6 deletions doc/man/shellex.man.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,27 @@ terminal window.

*shellex* configuration snippets can be found in *@PREFIX@@LIBDIR@/shellex/*.

On start, *shellex* looks into @SYSCONFDIR@/shellex for default-snippets to
source (usually this will be symlinks to *@PREFIX@@LIBDIR@/shellex/*) as well
as into *$HOME/.shellex/* for any user-configuration. If a file of the same
name exists in both locations, it will only use the one in *$HOME/.shellex/*.
On start, *shellex* assembles a list of snippet basenames by looking at all of
the paths listed below. For each snippet basename, *shellex* loads the first
file it finds when looking through the paths in order:

To customize shellex, you can do the following things in *$HOME/.shellex/*:
1. $XDG_CONFIG_HOME/.shellex. Typically unset, defaulting to $HOME/.config/shellex.
2. $HOME/.shellex
3. @SYSCONFDIR@/shellex (shellex defaults, symlinks to *@PREFIX@@LIBDIR@/shellex/conf/*)

To customize shellex, you can do the following things in
*$XDG_CONFIG_HOME/.shellex* or *$HOME/.shellex/*:

1. Overwrite a default by creating a new snippet of the same name
2. Not include a default by creating a symlink to */dev/null* of the same same
3. Include an example-snippet not used by default, by creating a symlink to *@PREFIX@@LIBDIR@/shellex/snippet*
4. Write you own snippets with a currently unused name

To avoid naming-conflicts in the future, you should add a common suffix to all
your own snippets.
your own snippets. Snippets are run in ascending order. By choosing a number
which sorts between/after the existing snippet(s) you can ensure it runs at the
desired time. E.g. if your snippet beeps on errors, name it 15-errorbeep so that
it sorts before 20-nobeep.

== AUTHORS

Expand Down

0 comments on commit 004d7ea

Please sign in to comment.