Skip to content

Commit

Permalink
python skel
Browse files Browse the repository at this point in the history
  • Loading branch information
bbkane committed May 29, 2020
1 parent 1334508 commit c2d1b85
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
5 changes: 3 additions & 2 deletions nvim/.config/nvim/init.vim
Expand Up @@ -309,6 +309,7 @@ endif

" https://stackoverflow.com/a/46348040/2958070
" Execute current file
" TODO: this should ChmodX too
command! Run :!"%:p"

" use zg to add word to word-list
Expand Down Expand Up @@ -376,15 +377,15 @@ command! DiffSaved call s:DiffWithSaved()

command! FullPath echo expand('%:p')

function! SetExecutableBit()
function! ChmodX()
let fname = expand("%:p")
checktime
execute "au FileChangedShell " . fname . " :echo"
silent !chmod a+x %
checktime
execute "au! FileChangedShell " . fname
endfunction
command! SetExecutableBit call SetExecutableBit()
command! ChmodX call ChmodX()

" The 'e' on the end of the substitute ignores errors
" -range=% means without a visual selection the whole buffer is selected
Expand Down
34 changes: 33 additions & 1 deletion nvim/.config/nvim/templates/skeleton.py
@@ -1,12 +1,44 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
import sys

__author__ = "Benjamin Kane"
__version__ = "0.1.0"
__doc__ = f"""
<description>
Examples:
{sys.argv[0]}
Help:
Please see Benjamin Kane for help.
Code at <repo>
"""


def parse_args(*args, **kwargs):
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter
)

# Use a file or stdin for an argument
# https://stackoverflow.com/a/11038508/2958070
parser.add_argument(
'infile',
nargs='?',
type=argparse.FileType('r'),
default=sys.stdin,
help='Use a file or stdin'
)

return parser.parse_args(*args, **kwargs)


def main():
pass
args = parse_args()
with args.infile:
pass


if __name__ == "__main__":
Expand Down
5 changes: 5 additions & 0 deletions nvim/README.md
Expand Up @@ -68,3 +68,8 @@ curl https://raw.githubusercontent.com/bbkane/nvim/master/init.vim > ~/.vimrc
curl --create-dirs -fLo ~/.vim/plugin/commentary.vim https://raw.githubusercontent.com/tpope/vim-commentary/master/plugin/commentary.vim
```

## Notes

TODO: move this to blog?

In normal mode: `q:`, `q/`, `q?` open up command and search history in a nice little popup window

0 comments on commit c2d1b85

Please sign in to comment.