-
-
Save stevegt/cfd70b07f1ec8d78d13f4358ce5933c8 to your computer and use it in GitHub Desktop.
a script that i use to manage neovim shada files and start neovim accordingly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # if -c flag is present, then use/create shada file in the current directory | |
| if [ "$1" == "-c" ] | |
| then | |
| usecurdir=1 | |
| shift | |
| fi | |
| fn=nv.shada | |
| dir=$PWD | |
| curdir=$PWD | |
| while true | |
| do | |
| path=$dir/$fn | |
| if [ -e $path ] | |
| then | |
| # open old shada in parent directory | |
| break | |
| fi | |
| if [ "$dir" == "/" ] || [ "$dir" == "$HOME" ] || [ "$usecurdir" == 1 ] | |
| then | |
| # create new shada in current directory | |
| path=$curdir/$fn | |
| touch $path | |
| break | |
| fi | |
| # try parent directory | |
| dir=$(dirname $dir) | |
| done | |
| # resume from shada, jump to most recent cursor position | |
| exec nvim -i $path "+'0" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment