X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/07f517faf8d0cbd8c12e35de06eac06f2348f44a..ccdacf21dc7d84e54dc22e5398d5ecb4fb2912ec:/aliases diff --git a/aliases b/aliases index 6fb1ae1..7163ca4 100644 --- a/aliases +++ b/aliases @@ -13,26 +13,26 @@ alias df='df -h' # human-readable sizes du() { /usr/bin/du -h ${@} | sort -h } alias free='free -m' # show sizes in MB -# run vim or drop file in parent vim instance if inside vim terminal -function vim { - if [[ -z "${VIM_TERMINAL}" ]]; then - # Not in VIM_TERMINAL, simply run vim with all arguments - command vim "$@" - return - fi - - for f in "$@"; do - if [[ "${f:0:1}" == "-" ]]; then - echo "Running in Vim's terminal, not accepting options!" >&2 - return 1 +if [[ -n "${VIM_TERMINAL}" ]]; then + function vim() { + if (( ${#@} == 0 )); then + echo "Running in Vim's terminal, at least one file must be given!" >&2 + return 22 fi - done - for f in "$@"; do - # drop the file onto the running vim instance - # see :h terminal-communication - echo -e "]51;[\"drop\", \"$f\"]" - done -} + for f in "$@"; do + if [[ "${f:0:1}" == "-" ]]; then + echo "Running in Vim's terminal, not accepting options!" >&2 + return 1 + fi + done + for f in "$@"; do + # drop the file onto the running vim instance + # see :h terminal-communication + local abspath=$(realpath $f) + echo -e "]51;[\"drop\", \"$abspath\"]" + done + } +fi alias vi='vim' alias svi='sudo -e' #alias vp='vim PKGBUILD' # I have a script for that in ~/bin