From 843b8510acd58fa9c1d1df6d8837d0406392e1b2 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Sat, 22 Jan 2022 21:11:52 +0800 Subject: Add fzf config The fzf config is splited into .env and .functions before. It will be hard to remove the config of fzf when I want to replace fzf with other finder (e.g. skim). I place all config related to .fzfrc now. Besides, I add the config to load fzf completion and key bindings. --- .functions | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to '.functions') diff --git a/.functions b/.functions index 33d3e0e..9390af8 100644 --- a/.functions +++ b/.functions @@ -1,37 +1,5 @@ #!/usr/bin/env bash -fco () { - local tags branches target - branches=$( - git --no-pager branch --all \ - --format="%(if)%(HEAD)%(then)%(else)%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%1B[0;34;1mbranch%09%1B[m%(refname:short)%(end)%(end)" \ - | sed '/^$/d' - ) || return - tags=$( - git --no-pager tag | awk '{print "\x1b[35;1mtag\x1b[m\t" $1}' - ) || return - target=$( - (echo $branches; echo $tags) \ - | fzf --no-hscroll --no-multi -n 2 --ansi - ) || return - git checkout $(awk '{print $2}' <<<$target) -} - -fs () { - local session - session=$(tmux list-sessions -F "#{session_name}" \ - | fzf --query=$1 --select-1 --exit-0) \ - && tmux switch-client -t $session -} - -tm() { - [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" - if [ $1 ]; then - tmux $change -t "$1" 2>/dev/null || (tmux new-session -d -s $1 && tmux $change -t "$1"); return - fi - session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0) && tmux $change -t "$session" || echo "No sessions found." -} - open () { if [ -f /usr/bin/xdg-open ]; then nohup xdg-open "$*" > /dev/null 2>&1 & -- cgit v1.2.3