Added fzf functions.
This commit is contained in:
parent
2c9ff2a6a6
commit
3bffa00e0a
30
.config/scripts/functions/fzf
Normal file
30
.config/scripts/functions/fzf
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# These are functions related to fzf used to go to locations, edit
|
||||||
|
# configurations, or start a tmux session in common directories.
|
||||||
|
|
||||||
|
# Finds within current directory and cd into the location of the file or
|
||||||
|
# directory.
|
||||||
|
goto()
|
||||||
|
{
|
||||||
|
path=$(find $1 | fzf)
|
||||||
|
[ -f "$path" ] && path=$(dirname "$path")
|
||||||
|
cd "$path"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Quickly find and edit a file within ~/.config or ~/Documents
|
||||||
|
cfg()
|
||||||
|
{
|
||||||
|
file=$(find $HOME/.config $HOME/Documents -type f | fzf)
|
||||||
|
[ -z "$file" ] && return
|
||||||
|
$EDITOR "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Quickly find a directory within ~/.config or ~/Documents and start a tmux
|
||||||
|
# session there with the name of the directory.
|
||||||
|
ts()
|
||||||
|
{
|
||||||
|
dir=$(find $HOME/.config $HOME/Documents -type d | fzf)
|
||||||
|
[ -z "$dir" ] && return
|
||||||
|
tmux new -s $(basename "$dir") -c "$dir"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user