A macOS command-line script to set up a split layout of a terminal emulator and a web browser.
,-------------------. ,-----------.,-----------.
|-------------------| |-----------||-----------|
| | | || |
| $ x5050 right |--. ,-.( ).-, | || |
| |--| ,-( )-. | $ x5050 || Google |
| | | +~~( *MAGIC* )~~> | $ || |
| | | `-( ),-' | || [_______] |
`------+------------' | `-.( ).-' | || == == |
| | | || |
`---------------' | || |
`-----------'`-----------'
make
And put x5050
in a directory in $PATH
.
x5050
takes four optional arguments. The order of arguments doesn't matter.
- Position:
right
(default),left
,up
,down
- Percent size: 1 ~ 100 (default 50)
- Browser: Tested with
Chrome
(default) andSafari
- URL to open
x5050
x5050 left
x5050 down 40
x5050 https://github.com/junegunn
x5050 up Safari https://google.com
A few years ago, I wrote vim-xmark, a minimal Markdown preview plugin for Vim. It does two things:
- Set up a split layout, Vim and a web browser, using AppleScript
- Convert Markdown document using pandoc and display it in the browser window
The implementation is simple and it still works fine, but lately I've been trying out markdown-preview.nvim which provides better preview functionality (e.g. immediate update, synchronized scroll, etc). So I extracted the split layout code from vim-xmark into x5050 so I can use it with the new plugin.
if has('mac') && executable('x5050')
function! MKDPSplit(url)
call system('x5050 '.shellescape(a:url))
endfunction
let g:mkdp_browserfunc = 'MKDPSplit'
endif
You can do the same thing pretty easily with Hammerspoon like so:
local screen = hs.window.focusedWindow():screen()
hs.layout.apply({
{ hs.window.focusedWindow(), nil, screen, hs.layout.left50 },
{ "Chrome", nil, screen, hs.layout.right50 }
})
MIT