dotfiles/bin/tmux-edit-helper

20 lines
836 B
Text
Raw Normal View History

2022-07-27 16:19:21 +02:00
#!/usr/bin/env bash
set -xfe -o pipefail
2022-07-27 16:19:21 +02:00
if [ -n "$1" ]; then
2022-11-22 09:56:09 +01:00
_file=$(readlink -f "$@")
2022-07-27 16:19:21 +02:00
else
2022-11-22 09:56:09 +01:00
FZF=${FZF:-"fzf-tmux -p 90%,50% -y 0"}
_git_root=$(git rev-parse --show-toplevel 2>/dev/null || sl root 2>/dev/null || pwd)
2022-11-22 09:56:09 +01:00
_store=$(echo "$_git_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 "${_git_root}/.gitignore" . "$_git_root") | cat -n | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- | $FZF --no-sort)
2022-11-22 09:56:09 +01:00
fre --store_name "$_store" --add "$_file"
2022-07-27 16:19:21 +02:00
fi
2022-12-14 10:06:42 +01:00
tmux select-window -t nvim 2>/dev/null ||
tmux new-window -S -n nvim \
-e "GOPACKAGESDRIVER=$GOPACKAGESDRIVER" \
nvim --listen "$XDG_RUNTIME_DIR/nvim.sock"
2022-12-03 14:06:37 +01:00
nvim --server "$XDG_RUNTIME_DIR/nvim.sock" --remote "$_file"