feat: show relative date in git log helper and use the preview script in

fedit and search_file
pull/17/head
kevin zhuang 4 years ago
parent 983e89ee14
commit 20cccb1f8d

@ -4,6 +4,7 @@
#######################################
# let user select a commit interactively
# credit to forgit for the git log format
# Arguments:
# $1: the helper message to display in the fzf header
# $2: files to show diff against HEAD
@ -19,7 +20,7 @@ function get_commit() {
local files=("${@:2}")
if [[ "${#files[@]}" -eq 0 ]]; then
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
log --oneline --color=always --decorate=short \
log --color=always --format='%C(auto)%h%d %s %C(black)%C(bold)%cr' \
| fzf --no-multi --header="${header}" \
--preview "echo {} \
| awk '{print \$1}' \
@ -86,13 +87,14 @@ function get_branch() {
# e.g.$HOME/.config/nvim/init.vim
#######################################
function get_git_file() {
local mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
local header="${1:-select tracked file}"
local print_opt="${2:-full}"
set_fzf_multi "$3"
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
ls-files --full-name --directory "${DOTBARE_TREE}" \
| fzf --header="${header}" \
--preview "cat ${DOTBARE_TREE}/{}" \
--preview "${mydir}/../helper/preview.sh ${DOTBARE_TREE}/{}" \
| awk -v home="${DOTBARE_TREE}" -v print_opt="${print_opt}" '{
if (print_opt == "full") {
print home "/" $0

@ -11,8 +11,9 @@
#######################################
function search_file() {
local search_type="$1"
local mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ "${search_type}" == "f" ]]; then
find . -maxdepth 1 -type f | sed "s|\./||g" | fzf --multi --preview "cat {}"
find . -maxdepth 1 -type f | sed "s|\./||g" | fzf --multi --preview "${mydir}/preview.sh {}"
elif [[ "${search_type}" == "d" ]]; then
if tree --version &>/dev/null; then
find . -maxdepth 1 -type d | awk '{if ($0 != "." && $0 != "./.git"){gsub(/^\.\//, "", $0);print $0}}' | fzf --multi --preview "tree -L 1 -C --dirsfirst {}"

Loading…
Cancel
Save