30 lines
1.2 KiB
Bash
Executable file
30 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -fe -o pipefail
|
|
|
|
eval "$(direnv export bash)"
|
|
|
|
if [ -n "$1" ]; then
|
|
_file=$(readlink -f "$@")
|
|
else
|
|
FZF=${FZF:-"fzf-tmux -p 90%,50% -y 0"}
|
|
_root=$(git rev-parse --show-toplevel 2>/dev/null || sl root 2>/dev/null || pwd)
|
|
_store=$(echo "$_root" | sha1sum | cut -d ' ' -f 1)
|
|
_file=$( ( (fre --store_name "$_store" --sorted | xargs -n 100 ls -d 2>/dev/null || true) && fd --type f --hidden --follow --exclude .git --exclude .sl --ignore-file "${_root}/.gitignore" . "$_root") | cat -n | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- | sed -e "s#^${_root}/##" | $FZF --no-sort)
|
|
_file="${_root}/${_file}"
|
|
fre --store_name "$_store" --add "$_file"
|
|
fi
|
|
|
|
function _nvim_setenv() {
|
|
nvim --server "$XDG_RUNTIME_DIR/nvim.sock" --remote-expr "execute(\"let \$${1} = \\\"${2}\\\"\")"
|
|
}
|
|
|
|
nvim --server "$XDG_RUNTIME_DIR/nvim.sock" --remote-expr "42" 2>/dev/null ||
|
|
(wezterm cli spawn --cwd "${PWD}" nvim --listen "$XDG_RUNTIME_DIR/nvim.sock" && sleep 0.5)
|
|
|
|
_nvim_setenv BUILD_COMMAND "$BUILD_COMMAND"
|
|
_nvim_setenv GOPACKAGESDRIVER "$GOPACKAGESDRIVER"
|
|
_nvim_setenv GOFLAGS "$GOFLAGS"
|
|
|
|
nvim --server "$XDG_RUNTIME_DIR/nvim.sock" --remote "$_file"
|
|
|
|
printf "\033]1337;SetUserVar=%s=%s\007" nvim_activate $(date +%s | base64)
|