feat(shell): nvim-alt.bash VIMRC [DIR] [NVIM ARGS]
Start nvim with an alternative configuration and runtime data directory Signed-off-by: hsv2 <soratobuneko@disroot.org>
This commit is contained in:
parent
7d5834b5d4
commit
3370b6f3c5
18
README.md
18
README.md
|
@ -1,16 +1,10 @@
|
|||
# Give Up GitHub
|
||||
# Random scripts
|
||||
|
||||
This project has given up GitHub.
|
||||
([See Software Freedom Conservancy's *Give Up GitHub* site for details](https://GiveUpGitHub.org).)
|
||||
## Weechat
|
||||
|
||||
You can now find this project at
|
||||
[disroot](https://git.disroot.org/soratobuneko/weechat-scripts) or
|
||||
[codeberg](https://codeberg.org/hsv2/weechat-scripts) instead.
|
||||
- [urltitel](weechat/urltitel.py): a shitty script to autosend web page title of
|
||||
URLs.
|
||||
|
||||
Any use of this project's code by GitHub Copilot, past or present, is done
|
||||
without our permission. We do not consent to GitHub's use of this project's
|
||||
code in Copilot.
|
||||
## Shell
|
||||
|
||||
Join us; you can [give up GitHub](https://GiveUpGitHub.org) too!
|
||||
|
||||
![Logo of the GiveUpGitHub campaign](https://sfconservancy.org/img/GiveUpGitHub.png)
|
||||
- [nvim-alt](shell/nvim-alt.bash): run nvim with an alternative configuration.
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
# vi: et sw=4 ts=4:
|
||||
|
||||
if [[ -z "$(LC_ALL=C type -t realpath)" ]]
|
||||
then
|
||||
realpath() (
|
||||
OURPWD=$PWD
|
||||
cd "$(dirname "$1")"
|
||||
LINK=$(readlink "$(basename "$1")")
|
||||
while [ "$LINK" ]; do
|
||||
cd "$(dirname "$LINK")"
|
||||
LINK=$(readlink "$(basename "$1")")
|
||||
done
|
||||
REALPATH="$PWD/$(basename "$1")"
|
||||
cd "$OURPWD"
|
||||
echo "$REALPATH"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ $TERMUX_VERSION ]];
|
||||
then
|
||||
TMPDIR="$TMUX_TMPDIR"
|
||||
else
|
||||
TMPDIR="${TMPDIR:-/tmp}"
|
||||
fi
|
||||
|
||||
if [[ ! -f "$(realpath $1)" ]]
|
||||
then
|
||||
echo "Invalid argument"
|
||||
echo "syntax: $0 VIMRC [DIR] [NVIM ARGS]"
|
||||
echo "VIMRC is the configuration file to use"
|
||||
echo "DIR is where runtime and configuration will be stored."
|
||||
echo "if not specified a temporary one will be used."
|
||||
fi
|
||||
|
||||
if [[ -z "$2" ]]
|
||||
then
|
||||
NVIM_DIR="$(mktemp --directory hsv2.nvim-test.XXXXXXXX)"
|
||||
else
|
||||
if [[ ! -d "$(realpath $2)" ]]
|
||||
then
|
||||
mkdir "$2"
|
||||
fi
|
||||
NVIM_DIR="$2"
|
||||
fi
|
||||
|
||||
export XDG_DATA_HOME="$NVIM_DIR/data"
|
||||
export XDG_CONFIG_HOME="$NVIM_DIR/conf"
|
||||
export MYVIMRC="$1"
|
||||
|
||||
echo data stored in $NVIM_DIR
|
||||
nvim -u "$MYVIMRC" ${@:3}
|
Loading…
Reference in New Issue