Skip to content

Instantly share code, notes, and snippets.

🍎

Junegunn Choi junegunn

🍎
Block or report user

Report or block junegunn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@junegunn
junegunn / only-dir
Last active Oct 14, 2017
only-dir and with-dir
View only-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 / ag-change
Last active Jul 18, 2017
Restarting source command
View ag-change
#!/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"
View tmux-map.vim
" ----------------------------------------------------------------------------
" 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()
View fzf.vim
" 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
View job_start.vim
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'})
View keys.go
package main
import (
"fmt"
"os"
"syscall"
)
func GetBytes() []byte {
_in, _ := os.OpenFile("/dev/tty", syscall.O_RDONLY, 0)
@junegunn
junegunn / notes.sh
Last active Oct 20, 2019
Managing notes with fzf
View notes.sh
#!/usr/bin/env bash
#
# Managing notes with fzf (https://github.com/junegunn/fzf)
# - CTRL-L: List note files in descending order by their modified time
# - CTRL-F: Search file contents
#
# Configuration:
# - $NOTE_DIR: Directory where note files are located
# - $NOTE_EXT: Note file extension (default: txt)
View gstash.sh
gstash() {
local out k reflog
out=(
$(git stash list --pretty='%C(yellow)%gd %>(14)%Cgreen%cr %C(blue)%gs' |
fzf --ansi --no-sort --header='enter:show, ctrl-d:diff, ctrl-o:pop, ctrl-y:apply, ctrl-x:drop' \
--preview='git stash show --color=always -p $(cut -d" " -f1 <<< {}) | head -'$LINES \
--preview-window=down:50% --reverse \
--bind='enter:execute(git stash show --color=always -p $(cut -d" " -f1 <<< {}) | less -r > /dev/tty)' \
--bind='ctrl-d:execute(git diff --color=always $(cut -d" " -f1 <<< {}) | less -r > /dev/tty)' \
--expect=ctrl-o,ctrl-y,ctrl-x))
View fzf_history_dir.patch
diff --git a/README.md b/README.md
index a36a60a..65804e6 100644
--- a/README.md
+++ b/README.md
@@ -122,6 +122,12 @@ let g:fzf_colors =
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
+
+" Enable per-command history.
View functions.sh
# GIT heart FZF
# -------------
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fzf-down() {
fzf --height 50% "$@" --border
}
You can’t perform that action at this time.