commit f66713ce3edc35b36cb5dcc70ac1f683afdb1600 parent a4499d9c7fba80b472a384e0e8408adc0ebe3a6b Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Mon, 14 Jan 2019 17:50:31 +0100 Improve o function with flexible opening mode Diffstat:
M | links/.commands.sh | | | 7 | ++++++- |
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/links/.commands.sh b/links/.commands.sh @@ -33,7 +33,12 @@ alias la='ls -A' ## Open files o() { - xdg-open "$(fzf)" + IFS=$'\n' out=($(fzf-tmux --query="$1" --exit-0 --expect=ctrl-o,ctrl-e)) + key=$(head -1 <<< "$out") + file=$(head -2 <<< "$out" | tail -1) + if [ -n "$file" ]; then + [ "$key" = ctrl-e ] && ${EDITOR:-vim} "$file" || xdg-open "$file" + fi } if [ "$(uname)" != 'Darwin' ]; then