Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,32 @@ Reopen your most recent file:
$ vim $( ls /tmp/vim-anywhere | sort -r | head -n 1 )
```

To clean up your history (for systems that do not reboot often) you can run the `bin/prune` command (possibly from `cron`).

Remove history older than seven days (default):

```bash
$ ~/.vim-anywhere/bin/prune
```

Remove history older then *one* day:

```bash
$ ~/.vim-anywhere/bin/prune -m +1
```

Remove **all** history:

```bash
$ ~/.vim-anywhere/bin/prune -a
```

To run this every day (at 2 AM) you can add this to your crontab:

```crontab
0 2 * * * $HOME/.vim-anywhere/bin/prune
```

## Why?

I use Vim for _almost_ everything. I wish I didn't have to say _almost_. My
Expand Down
39 changes: 39 additions & 0 deletions bin/prune
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
#
# vim-anywhere-prune - Prune unused temprary files
# Author: Chris Knadler
# Homepage: https://www.github.com/cknadler/vim-anywhere
#
# Removes old temprary files

###
# defs
###

ALL=1
mtime="+7"

###
# opts
###

while getopts ":am:v" opt; do
case "$opt" in
a) ALL=0 ;;
m) mtime="$OPTARG" ;;
v) set -x ;;
\?) echo "Invalid option: -$OPTARG" >&2 ;;
esac
done

###
# run
###

TMPFILE_DIR=/tmp/vim-anywhere

if [[ $ALL == 0 ]]; then
find $TMPFILE_DIR -type f -exec rm -f {} \;
else
find $TMPFILE_DIR -type f -mtime "$mtime" -exec rm -f {} \;
fi