2020-10-30 22:02:38 +02:00
|
|
|
#! /bin/sh
|
|
|
|
last_selection="$(cat "/tmp/fzf-open-conf-last" 2>"/dev/null")"
|
2020-06-21 12:41:26 +02:00
|
|
|
|
2020-10-30 22:02:38 +02:00
|
|
|
config_files_path="$HOME/scripts/bookmarks/config_files"
|
|
|
|
config_file_count="$((2+$(cat "$config_files_path" | wc -l)))"
|
2020-06-21 12:41:26 +02:00
|
|
|
|
2020-10-30 22:02:38 +02:00
|
|
|
options="$(awk '{print $1}' "$config_files_path")"
|
|
|
|
[ -n "$last_selection" ] && \
|
2020-06-21 12:41:26 +02:00
|
|
|
options="$last_selection\n$(echo "$options" | grep -v "$last_selection")"
|
|
|
|
|
2020-10-30 22:02:38 +02:00
|
|
|
selected="$(echo -e "$options" | fzf --history=/tmp/conf-open-history --cycle --reverse --height "$config_file_count")"
|
2020-06-21 12:41:26 +02:00
|
|
|
test "$selected" = "" && exit 1
|
2020-10-30 22:02:38 +02:00
|
|
|
echo "$selected" > "/tmp/fzf-open-conf-last"
|
|
|
|
file="$(grep "$selected" "$config_files_path" | sed -r 's/^\w*\s+(.*)$/\1/g')"
|
|
|
|
echo "$EDITOR $file"
|