Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I mostly use it to open files in vim [0]. The good thing about these aliases is that they keep the command in the shell history. So you open a file with the alias and it will leave a full 'vim path-to-file' in the history.

  # Open any file under current dir
  vf() {
    files="$(fzf --query="$1" --multi --select-1 --exit-0)"
    if test -n "$files"; then
        echo "${EDITOR:-vim} \"$files\""
        print -s "${EDITOR:-vim} \"$files\""
        ${EDITOR:-vim} "$files"
    fi
  }
  
  # Open from current modified files in git repository
  vfc() {
    files="$(git ls-files -m | fzf --multi --select-1 --exit-0)"
    if test -n "$files"; then
        echo "${EDITOR:-vim} \"$files\""
        print -s "${EDITOR:-vim} \"$files\""
        ${EDITOR:-vim} "$files"
    fi
  }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: