Skip to content

Instantly share code, notes, and snippets.

View junegunn's full-sized avatar
🐷
Please be kind to animals

Junegunn Choi junegunn

🐷
Please be kind to animals
View GitHub Profile
function! JobCallback(self, data) abort
echom string([a:self, a:data])
endfunction
let command = printf('git clone "https://github.com/junegunn/seoul256.vim.git" "%s\vimfiles\plugged yolo\seoul256.vim" 2>&1', $HOME)
let j = job_start(command, {'out_cb': 'JobCallback', 'exit_cb': 'JobCallback'})
" Copyright (c) 2017 Junegunn Choi
"
" MIT License
"
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" ----------------------------------------------------------------------------
" tmux
" ----------------------------------------------------------------------------
" Recommended
let mapleader = ' '
function! s:tmux_send(content, dest) range
let dest = empty(a:dest) ? input('To which pane? ') : a:dest
let tempfile = tempname()
@junegunn
junegunn / only-dir
Last active October 14, 2017 07:04
only-dir and with-dir
#!/usr/bin/env ruby
require 'set'
base = ARGV.first || '.'
dirs = Set.new
$stdin.each_line do |line|
dir = File.dirname(line)
anc = []
while dirs.add?(dir)
anc << dir
@junegunn
junegunn / array-of-hashes.rb
Created December 18, 2019 10:05
Ruby: Array of Hashes
data = [{ a: 1, b: 9 }, { a: 1, b: 8 },
{ a: 2, b: 7 }, { a: 2, b: 6 }]
data.group_by { |h| h[:a] }.transform_values { |xs| xs.max_by { |x| x[:b] } }
def key(k)
proc { |hash| hash[k] }
end
diff --git a/README.md b/README.md
index 6abc213..c02896a 100644
--- a/README.md
+++ b/README.md
@@ -69,6 +69,12 @@ Given [filetype] [(comment)]:
[input text]
```
+Alternatively, you can pass a file path to `Given` label as follows:
+
@junegunn
junegunn / ag-change
Last active May 28, 2021 02:13
Restarting source command
#!/usr/bin/env bash
ag_source() {
local query
[ -z "$1" ] && query="^(?=.)" || query="$1"
ag --nogroup --column --color "$query" 2> /dev/null
}
filter() {
local query="$1"
@junegunn
junegunn / vimrc
Last active October 10, 2021 07:54
set nocompatible hidden laststatus=2
if !filereadable('/tmp/plug.vim')
silent !curl --insecure -fLo /tmp/plug.vim
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif
source /tmp/plug.vim
call plug#begin('/tmp/plugged')
Plug 'junegunn/fzf', { 'do': './install --bin' }
@junegunn
junegunn / README.md
Last active February 23, 2022 10:08 — forked from steve-jansen/README.md
Stop and start Symantec Endpoint Protection on OS X

This script enables you stop and start Symantec Endpoint Protection on OS X

Installation

sudo curl https://gist.githubusercontent.com/steve-jansen/61a189b6ab961a517f68/raw/sep -o /usr/local/bin/sep
sudo chmod 755 /usr/local/bin/sep
sudo chown root:staff /usr/local/bin/sep
@junegunn
junegunn / b.rb
Last active January 26, 2023 14:34
b - browse Chrome bookmarks with fzf
#!/usr/bin/env bash
# vim: set filetype=ruby:
# b - browse Chrome bookmarks with fzf
[ $(uname) = Darwin ] || exit 1
which fzf > /dev/null 2>&1 || brew reinstall --HEAD fzf || exit 1
/usr/bin/ruby -x "$0" |
fzf-tmux -u 30% --ansi --multi --no-hscroll --tiebreak=begin |
awk 'BEGIN { FS = "\t" } { print $2 }' |