dotfiles/.bin/OLD/c

45 lines
1.2 KiB
Plaintext
Raw Normal View History

2022-12-07 14:39:35 +01:00
#!/bin/sh
if [ -f ~/.c.query ]
then
echo -n "Open $(< ~/.c.query) again (Y/n)? "
read
case $REPLY in
[Nn]) rm -f ~/.c.query; ;;
esac
fi
[ -f ~/.c.query ] \
&& EXTRA="--query $(<~/.c.query)"
2023-01-21 12:25:49 +01:00
[ ! -z "$@" ] \
&& EXTRA="--query $@"
2022-12-07 18:56:50 +01:00
2023-01-21 12:30:01 +01:00
FZF_DEFAULT_COMMAND='find \
$HOME/.config/* \
$HOME/.* \
-maxdepth 1 \
-type f \
\( -name "*.cfg" \
-o -name "*.conf" \
-o -name "*.lua" \
-o -name "*.sh" \
2023-02-16 10:12:03 +01:00
-o -name "*.toml" \
2023-01-21 12:30:01 +01:00
-o -name "*.xsession*" \
-o -name "*rc" \
-o -name ".Xresources" \
-o -name ".Xdefaults" \
-o -name ".ini" \
-o -name "config" \
\)'
2022-12-07 14:39:35 +01:00
2023-01-21 12:30:01 +01:00
export FZF_DEFAULT_COMMAND
2023-01-21 12:33:39 +01:00
F=$(fzf -1 -e +s $EXTRA --preview='cat {}')
2023-01-21 12:30:01 +01:00
[ -z "$F" ] \
|| vim "$F" && echo "$F" > ~/.c.query;
[ -z "$F" ] \
&& rm -f ~/.c.query