From bc1e8a4191fbdfc65e493d65a9c4f0fdaa2b1d19 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Tue, 21 Sep 2021 09:07:31 +0800 Subject: Add more fzf related functions --- .functions | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to '.functions') diff --git a/.functions b/.functions index 07f9afe..b34c848 100644 --- a/.functions +++ b/.functions @@ -14,3 +14,23 @@ fco () { ) || return git checkout $(awk '{print $2}' <<<$target) } + +fjrnl () { + title=$(jrnl --short | fzf --tac --no-sort) \ + && jrnl -on $(echo $title | cut -c 1-16) $1 +} + +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." +} -- cgit v1.2.3