dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit b2c567676f1cfbd25ae1f7a02f0c93e753b495ae
parent 2e2b7c75b7433bf23339862f835f4e3710b0bd4c
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Wed, 27 Dec 2017 16:47:09 -0500

Add my-open command

Diffstat:
A.local/bin/my-open | 27+++++++++++++++++++++++++++
M.vim/vimrc | 7++-----
2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/.local/bin/my-open b/.local/bin/my-open @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# +# ~/.local/bin/my-open +# +# Every OS seems to use it's own uniquely-named binary to open +# files using the correct handler for the file's MIME type. This is my +# attempt to resolve the different handlers into a platform-independent +# one. +# + +# Find handler, if one is available +if command -v cygstart > /dev/null 2>&1 +then + handler=cygstart +elif command -v open > /dev/null 2>&1 +then + handler=open +elif command -v exo-open > /dev/null 2>&1 +then + handler=exo-open +else + echo "my-open: No suitable handler found" > /dev/stderr + exit -1 +fi + +exec $handler $@ diff --git a/.vim/vimrc b/.vim/vimrc @@ -306,11 +306,8 @@ if exists('$TMUX') endif if has('win32') || has('win64') nnoremap <Leader>o :execute 'silent ! start '.expand('<cWORD>')<CR> -elseif $PATH =~ 'cygdrive' - nnoremap <Leader>o :execute 'silent !cygstart ' - \ .expand(shellescape('<cWORD>')) \| redraw!<CR> -elseif has('mac') - nnoremap <Leader>o :execute 'silent !open ' +else + nnoremap <Leader>o :execute 'silent !my-start ' \ .expand(shellescape('<cWORD>')) \| redraw!<CR> endif nnoremap <Leader>c :silent! execute 'cclose' \|