commit 88df4378e71b8b63e25083bb16a2144474f43bb9 parent 7a37ddf92162d02d1bcaece8ca1d1bede1b4a7f0 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Wed, 30 May 2018 15:11:18 -0400 Add e and eg commands to open files with fuzzy find Diffstat:
M | links/.commands.sh | | | 24 | +++++++++++++++++------- |
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/links/.commands.sh b/links/.commands.sh @@ -1,5 +1,6 @@ #!/bin/bash + #### FUNCTIONS AND ALIASES @@ -26,7 +27,6 @@ else fi alias l='ls -alFh' alias la='ls -A' -alias lla='ls -lA' ## Open files @@ -39,15 +39,25 @@ fi ## editor e() { - if [ ! "$(pgrep emacs --daemon)" ]; then - echo starting emacs daemon - emacsdaemonlog=~/.emacs-daemon.log - [ -f ~/.emacs-daemon.log ] && rm $emacsdaemonlog # delete old logfile - emacs --daemon > $emacsdaemonlog 2>&1 + if [ $# -eq 0 ]; then + # open file under PWD + local file + file=$(find . -type f | grep -v '/\.' | fzf) + [ -n "$file" ] && $EDITOR "$file" + else + $EDITOR "$@" fi - emacsclient -t } +# edit file anywhere in git repository +eg() { + # open file under PWD + local file + file=$(find "$(git rev-parse --show-toplevel)" -type f | grep -v '/\.' | fzf) + [ -n "$file" ] && $EDITOR "$file" +} + + alias vi='vim -u NONE'