mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-16 15:23:48 -05:00
add flatpak toc
114
Examples.md
114
Examples.md
@@ -23,6 +23,7 @@ Table of Contents
|
|||||||
* [Homebrew](#homebrew)
|
* [Homebrew](#homebrew)
|
||||||
* [Homebrew Cask](#homebrew-cask)
|
* [Homebrew Cask](#homebrew-cask)
|
||||||
* [DNF](#dnf)
|
* [DNF](#dnf)
|
||||||
|
* [Flatpak](#flatpak)
|
||||||
* Filesystem navigation
|
* Filesystem navigation
|
||||||
* [Opening files](#opening-files)
|
* [Opening files](#opening-files)
|
||||||
* [Changing directory](#changing-directory)
|
* [Changing directory](#changing-directory)
|
||||||
@@ -1470,6 +1471,76 @@ else
|
|||||||
fi
|
fi
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Flatpak
|
||||||
|
#### flatpak-widget (for zsh)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# CLR=$(for i in {0..7}; do echo "tput setaf $i"; done)
|
||||||
|
BLK=\$(tput setaf 0); RED=\$(tput setaf 1); GRN=\$(tput setaf 2); YLW=\$(tput setaf 3); BLU=\$(tput setaf 4);
|
||||||
|
MGN=\$(tput setaf 5); CYN=\$(tput setaf 6); WHT=\$(tput setaf 7); BLD=\$(tput bold); RST=\$(tput sgr0);
|
||||||
|
|
||||||
|
AWK_VAR="awk -v BLK=${BLK} -v RED=${RED} -v GRN=${GRN} -v YLW=${YLW} -v BLU=${BLU} -v MGN=${MGN} -v CYN=${CYN} -v WHT=${WHT} -v BLD=${BLD} -v RST=${RST}"
|
||||||
|
|
||||||
|
# Searches only from flathub repository
|
||||||
|
fzf-flatpak-install-widget() {
|
||||||
|
flatpak remote-ls flathub --cached --columns=app,name,description \
|
||||||
|
| awk -v cyn=$(tput setaf 6) -v blu=$(tput setaf 4) -v bld=$(tput bold) -v res=$(tput sgr0) \
|
||||||
|
'{
|
||||||
|
app_info="";
|
||||||
|
for(i=2;i<=NF;i++){
|
||||||
|
app_info=cyn app_info" "$i
|
||||||
|
};
|
||||||
|
print blu bld $2" -" res app_info "|" $1
|
||||||
|
}' \
|
||||||
|
| column -t -s "|" -R 3 \
|
||||||
|
| fzf \
|
||||||
|
--ansi \
|
||||||
|
--with-nth=1.. \
|
||||||
|
--prompt="Install > " \
|
||||||
|
--preview-window "nohidden,40%,<50(down,50%,border-rounded)" \
|
||||||
|
--preview "flatpak --system remote-info flathub {-1} | $AWK_VAR -F\":\" '{print YLW BLD \$1 RST WHT \$2}'" \
|
||||||
|
--bind "enter:execute(flatpak install flathub {-1})" # when pressed enter it doesn't showing the key pressed but it is reading the input
|
||||||
|
zle reset-prompt
|
||||||
|
}
|
||||||
|
bindkey '^[f^[i' fzf-flatpak-install-widget #alt-f + alt-i
|
||||||
|
zle -N fzf-flatpak-install-widget
|
||||||
|
|
||||||
|
fzf-flatpak-uninstall-widget() {
|
||||||
|
touch /tmp/uns
|
||||||
|
flatpak list --columns=application,name \
|
||||||
|
| awk -v cyn=$(tput setaf 6) -v blu=$(tput setaf 4) -v bld=$(tput bold) -v res=$(tput sgr0) \
|
||||||
|
'{
|
||||||
|
app_id="";
|
||||||
|
for(i=2;i<=NF;i++){
|
||||||
|
app_id" "$i
|
||||||
|
};
|
||||||
|
print bld cyn $2 " - " res blu $1
|
||||||
|
}' \
|
||||||
|
| column -t \
|
||||||
|
| fzf \
|
||||||
|
--ansi \
|
||||||
|
--with-nth=1.. \
|
||||||
|
--prompt=" Uninstall > " \
|
||||||
|
--header="M-u: Uninstall | M-r: Run" \
|
||||||
|
--header-first \
|
||||||
|
--preview-window "nohidden,50%,<50(up,50%,border-rounded)" \
|
||||||
|
--preview "flatpak info {3} | $AWK_VAR -F\":\" '{print RED BLD \$1 RST \$2}'" \
|
||||||
|
--bind "alt-r:change-prompt(Run > )+execute-silent(touch /tmp/run && rm -r /tmp/uns)" \
|
||||||
|
--bind "alt-u:change-prompt(Uninstall > )+execute-silent(touch /tmp/uns && rm -r /tmp/run)" \
|
||||||
|
--bind "enter:execute(
|
||||||
|
if [ -f /tmp/uns ]; then
|
||||||
|
flatpak uninstall {3};
|
||||||
|
elif [ -f /tmp/run ]; then
|
||||||
|
flatpak run {3};
|
||||||
|
fi
|
||||||
|
)" # same as the install one but when pressed entered the message is something like this
|
||||||
|
# "Proceed with these changes to the system installation? [Y/n]:" but it will uninstall the selected app weird but idk y
|
||||||
|
rm -f /tmp/{uns,run} &> /dev/null
|
||||||
|
zle reset-prompt
|
||||||
|
}
|
||||||
|
bindkey '^[f^[u' fzf-flatpak-uninstall-widget #alt-f + alt-u
|
||||||
|
zle -N fzf-flatpak-uninstall-widget
|
||||||
|
```
|
||||||
|
|
||||||
### v
|
### v
|
||||||
|
|
||||||
@@ -2088,37 +2159,36 @@ fman() {
|
|||||||
# Get the colors in the opened man page itself
|
# Get the colors in the opened man page itself
|
||||||
export MANPAGER="sh -c 'col -bx | bat -l man -p --paging always'"
|
export MANPAGER="sh -c 'col -bx | bat -l man -p --paging always'"
|
||||||
```
|
```
|
||||||
### fzf-man-pages widget (for zsh)
|
#### fzf-man-pages widget (for zsh)
|
||||||
Same functionality as above but better
|
Same functionality as above
|
||||||
- with colored and syntax higlighting
|
- with colored and syntax higlighting
|
||||||
- doesn't exit fzf when pressed enter
|
- doesn't exit or close fzf when pressed enter
|
||||||
- `--tiebreak=begin` for improved search experience (prefers the line with matched substring closer to the beginning)
|
|
||||||
- additional keybinds for changing preview (optional)
|
|
||||||
<kbd>Alt-C</kbd> for [cheat sheet](https://github.com/chubin/cheat.sh)
|
|
||||||
<kbd>Alt-T</kbd> for [tldr](https://github.com/tldr-pages/tldr) (I've used [tealdeer](https://github.com/dbrgn/tealdeer) to customize the colors)
|
|
||||||
- `Ctrl-H` keybinding to launch the widget (works only on zsh, don't know how to do it on bash and fish (additionaly pressing`ctrl-backspace` will trigger the widget to launch too because both share the same keycode)
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
||||||
fzf-man-widget() {
|
fzf-man-widget() {
|
||||||
batman="man {1} | col -bx | bat -l man -p --color always --theme=\"Monokai Extended\""
|
batman="man {1} | col -bx | bat --language=man --plain --color always --theme=\"Monokai Extended\""
|
||||||
man -k . | awk -v cyan=$(tput setaf 6) -v blue=$(tput setaf 4) '{$1=cyan $1; $2= blue;} 1' | \
|
man -k . | sort \
|
||||||
fzf +i +x \
|
| awk -v cyan=$(tput setaf 6) -v blue=$(tput setaf 4) -v res=$(tput sgr0) -v bld=$(tput bold) '{ $1=cyan bld $1; $2=res blue;} 1' \
|
||||||
-q "$1" \
|
| fzf \
|
||||||
--ansi \
|
-q "$1" \
|
||||||
--tiebreak=begin \
|
--ansi \
|
||||||
--prompt=' Man > ' \
|
--tiebreak=begin \
|
||||||
--preview-window='up,85%,border-bottom' \
|
--prompt=' Man > ' \
|
||||||
--preview "${batman}" \
|
--preview-window '50%,rounded,<50(up,85%,border-bottom)' \
|
||||||
--bind "enter:execute(man {1})" \
|
--preview "${batman}" \
|
||||||
--bind "alt-c:+change-preview(cht.sh {1})+change-prompt(ﯽ Cheat > )" \
|
--bind "enter:execute(man {1})" \
|
||||||
--bind "alt-m:+change-preview(${batman})+change-prompt( Man > )" \
|
--bind "alt-c:+change-preview(cht.sh {1})+change-prompt(ﯽ Cheat > )" \
|
||||||
--bind "alt-t:+change-preview(tldr --color=always {1})+change-prompt(ﳁ TLDR > )"
|
--bind "alt-m:+change-preview(${batman})+change-prompt( Man > )" \
|
||||||
|
--bind "alt-t:+change-preview(tldr --color=always {1})+change-prompt(ﳁ TLDR > )"
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
|
# `Ctrl-H` keybinding to launch the widget (this widget works only on zsh, don't know how to do it on bash and fish (additionaly pressing`ctrl-backspace` will trigger the widget to be executed too because both share the same keycode)
|
||||||
bindkey '^h' fzf-man-widget
|
bindkey '^h' fzf-man-widget
|
||||||
zle -N fzf-man-widget
|
zle -N fzf-man-widget
|
||||||
|
# Icon used is nerdfont
|
||||||
```
|
```
|
||||||
|
|
||||||
### Python Behave BDD
|
### Python Behave BDD
|
||||||
|
|||||||
Reference in New Issue
Block a user