summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorAhmed ElSamhaa <ahmed.elsamha@vaimo.com>2023-06-25 09:23:49 +0300
committerAhmed ElSamhaa <ahmed.elsamha@vaimo.com>2023-06-25 09:37:23 +0300
commitf3204670922e626135ec34b2a5e46c4239a0a0a2 (patch)
tree5af84000d3bf89e65e114ac8fefa24a0a42944ea /README.md
parent3cf45b536e6bcd8460a2583059e4ab2389f072db (diff)
Better shell integration for Linux and Darwin
- Now `fx` shell function passes its arguments through to the fx binary - Now `fx` shell function returns errors correctly - Better handling of the difference between BSD and GNU find - Optimized shell integration for better performance of the `fx` shell function
Diffstat (limited to 'README.md')
-rw-r--r--README.md55
1 files changed, 39 insertions, 16 deletions
diff --git a/README.md b/README.md
index 2ec4e73..d9e3eba 100644
--- a/README.md
+++ b/README.md
@@ -102,23 +102,44 @@ cargo install --path .
In order for the shortcut `ZZ` to work, you need to add the following to your `.bashrc` or `.zshrc`
or an equivalent depending on your (POSIX) shell:
+
```sh
+# begin felix
+eval "$(
+ if [ -n "$XDG_RUNTIME_DIR" ]; then
+ runtime_dir="$XDG_RUNTIME_DIR/felix"
+ elif [ -n "$TMPDIR" ]; then
+ runtime_dir="$TMPDIR/felix"
+ else
+ runtime_dir=/tmp/felix
+ fi
+ mkdir -p "$runtime_dir"
+
+ case "$(uname)" in
+ Linux)
+ cleanup_lwd='find "$RUNTIME_DIR" -type f -and \( -mmin +$(echo 1/60 | bc -l) -or -name $$ \) -delete'
+ ;;
+ Darwin)
+ cleanup_lwd='find "$RUNTIME_DIR" -type f -and \( -mtime +1s -or -name $$ \) -delete'
+ ;;
+ *) ;;
+ esac
+
+ cat << EOF
fx() {
- SHELL_PID=$$ command fx
- cd "$(
- set -e
- if [ -n "$XDG_RUNTIME_DIR" ]; then
- local runtime_dir="$XDG_RUNTIME_DIR/felix"
- elif [ -n "$TMPDIR" ]; then
- local runtime_dir="$TMPDIR/felix"
- else
- local runtime_dir=/tmp/felix
- fi
- cat "$runtime_dir/$$"
- # Clean up the current and any leftover lwd files
- find "$runtime_dir" -type f -and \( -mtime +1s -or -name $$ \) -delete
- )"
+ local RUNTIME_DIR="$runtime_dir"
+ SHELL_PID=\$\$ command fx "\$@"
+
+ if [ -f "\$RUNTIME_DIR/\$\$" ]; then
+ cd "\$(cat "\$RUNTIME_DIR/\$\$")"
+ fi
+
+ # Finally, clean up current and leftover lwd files
+ $cleanup_lwd
}
+EOF
+)"
+# end felix
```
In addition, you can use felix more conveniently by installing these two apps:
@@ -216,11 +237,13 @@ Install `chafa` and you can preview images without any configuration.
## Configuration
### Config file
-If any config file is not found, or found one is broken, felix launches with the default configuration, without creating new one.
-Note that the default editor is `$EDITOR`, so if you've not set it, opening a file will fail.
+
+If any config file is not found, or found one is broken, felix launches with the default configuration, without creating new one.
+Note that the default editor is `$EDITOR`, so if you've not set it, opening a file will fail.
You can find default config file (`config.yaml`) in this repository.
### Trash directory and log file
+
Contrary to the config file, these directory and file will be automatically created.
### Linux