2024-03-31 20:12:05 +02:00
|
|
|
#!/usr/bin/env bash
|
2024-04-01 11:04:47 +02:00
|
|
|
set -eo pipefail
|
2024-03-31 20:12:05 +02:00
|
|
|
|
|
|
|
eval "$(direnv export bash 2>/dev/null)"
|
|
|
|
|
|
|
|
PATH="$HOME/bin:$PATH"
|
|
|
|
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
_file=$(readlink -f "$@")
|
|
|
|
else
|
2024-04-01 13:07:30 +02:00
|
|
|
FZF=${FZF:-"fzf-tmux -p 90%,90% -y 0"}
|
2024-03-31 20:12:05 +02:00
|
|
|
_root=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
|
|
|
|
_store=$(echo "$_root" | sha1sum | cut -d ' ' -f 1)
|
2024-04-01 13:07:30 +02:00
|
|
|
_file=$( ( (fre --store_name "$_store" --sorted | xargs -n 100 ls -d 2>/dev/null || true) && fd --type f --hidden --follow --exclude .git --ignore-file "${_root}/.gitignore" . "$_root") | cat -n | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- | sed -e "s#^${_root}/##" | $FZF --no-sort --preview "bat {}" --preview-window=bottom,70%,border-top --color=bg+:16,fg+:49,pointer:49 --layout=reverse "--bind=alt-e:become(tmux-edit-history)")
|
2024-03-31 20:12:05 +02:00
|
|
|
_file="${_root}/${_file}"
|
|
|
|
fre --store_name "$_store" --add "$_file"
|
|
|
|
fi
|
|
|
|
|
2024-04-01 11:04:47 +02:00
|
|
|
fre --store_name "edit-history" --add "$_file"
|
|
|
|
|
2024-03-31 20:12:05 +02:00
|
|
|
(tmux select-window -t helix &&
|
|
|
|
tmux send-keys -t helix Escape &&
|
2024-04-01 23:36:31 +02:00
|
|
|
tmux send-keys -t helix ":open ${_file}" Enter) || tmux new-window -t 42 -n helix \
|
|
|
|
-e "AR=$AR" \
|
|
|
|
-e "AS=$AS" \
|
|
|
|
-e "BUILD_COMMAND=$BUILD_COMMAND" \
|
|
|
|
-e "CC=$CC" \
|
|
|
|
-e "CXX=$CXX" \
|
|
|
|
-e "GOFLAGS=$GOFLAGS" \
|
|
|
|
-e "GOPACKAGESDRIVER=$GOPACKAGESDRIVER" \
|
|
|
|
-e "LC_ALL=$LC_ALL" \
|
|
|
|
-e "LD=$LD" \
|
|
|
|
-e "NM=$NM" \
|
|
|
|
-e "NM=$NM" \
|
|
|
|
-e "OBJCOPY=$OBJCOPY" \
|
|
|
|
-e "OBJDUMP=$OBJDUMP" \
|
|
|
|
-e "PATH=$PATH" \
|
|
|
|
-e "RANLIB=$RANLIB" \
|
|
|
|
-e "READELF=$READELF" \
|
|
|
|
-e "RUST_SRC_PATH=$RUST_SRC_PATH" \
|
|
|
|
-e "SIZE=$SIZE" \
|
|
|
|
-e "STRIP=$STRIP" \
|
|
|
|
helix "${_file}"
|