From 387a25fdf0336c4b53195f9beee87456f446ece8 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Wed, 1 Feb 2023 09:21:51 +0100 Subject: [PATCH] Create e command for easy file editing --- bin/find-edit | 23 +++++++++++++++++++++++ shell/alias | 1 + 2 files changed, 24 insertions(+) create mode 100755 bin/find-edit diff --git a/bin/find-edit b/bin/find-edit new file mode 100755 index 0000000..eae38c0 --- /dev/null +++ b/bin/find-edit @@ -0,0 +1,23 @@ +#!/bin/sh + +if [ -f "$1" ] +then + $EDITOR $1 +else + if which fzf > /dev/null + then + file=$(fzf -q "$1") + found=$? + elif which dmenu > /dev/null + then + file=$(find . -type f -name '*'"$1"'*' | sed -e 's/^\.\///' | dmenu -l 20) + found=$? + else + echo "Found neither fzf nor dmenu" + fi +fi + +if [ "$found" -eq 0 ] +then + echo "$file" | xargs -d '\n' $EDITOR +fi diff --git a/shell/alias b/shell/alias index ba16b25..f9ed058 100644 --- a/shell/alias +++ b/shell/alias @@ -1,3 +1,4 @@ +alias e="find-edit" alias ls="ls --color=auto" alias ll="ls -lAh" alias hello='echo "Hello :)"'