m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 16:45:38 -05:00

Enable syntax highlighting for snippets.

Okan Esen
2018-07-22 00:43:09 +02:00
parent 3cea908617
commit e7a944950a

@@ -3,7 +3,7 @@ Examples for fish shell
### Navigation ### Navigation
``` ```fish
function fzf-bcd-widget -d 'cd backwards' function fzf-bcd-widget -d 'cd backwards'
pwd | awk -v RS=/ '/\n/ {exit} {p=p $0 "/"; print p}' | tac | eval (__fzfcmd) +m --select-1 --exit-0 $FZF_BCD_OPTS | read -l result pwd | awk -v RS=/ '/\n/ {exit} {p=p $0 "/"; print p}' | tac | eval (__fzfcmd) +m --select-1 --exit-0 $FZF_BCD_OPTS | read -l result
[ "$result" ]; and cd $result [ "$result" ]; and cd $result
@@ -11,7 +11,7 @@ function fzf-bcd-widget -d 'cd backwards'
end end
``` ```
``` ```fish
function fzf-cdhist-widget -d 'cd to one of the previously visited locations' function fzf-cdhist-widget -d 'cd to one of the previously visited locations'
# Clear non-existent folders from cdhist. # Clear non-existent folders from cdhist.
set -l buf set -l buf
@@ -31,7 +31,7 @@ end
### Commandline ### Commandline
The following is useful to manipulate the commandline from the result of jobs. For instance, calling `fzf-select` over `pacman -Qlq fzf` will allow you to select files in the `fzf` package and print them bck to commandline for further manipulation. The following is useful to manipulate the commandline from the result of jobs. For instance, calling `fzf-select` over `pacman -Qlq fzf` will allow you to select files in the `fzf` package and print them bck to commandline for further manipulation.
``` ```fish
function fzf-select -d 'fzf commandline job and print unescaped selection back to commandline' function fzf-select -d 'fzf commandline job and print unescaped selection back to commandline'
set -l cmd (commandline -j) set -l cmd (commandline -j)
[ "$cmd" ]; or return [ "$cmd" ]; or return
@@ -45,7 +45,7 @@ end
The following can replace fish completion menu with fzf. Because of a [fish bug](https://github.com/fish-shell/fish-shell/issues/3469) this will fail on variables and other elements that need escaping (or not). The following can replace fish completion menu with fzf. Because of a [fish bug](https://github.com/fish-shell/fish-shell/issues/3469) this will fail on variables and other elements that need escaping (or not).
``` ```fish
function fzf-complete -d 'fzf completion and print selection back to commandline' function fzf-complete -d 'fzf completion and print selection back to commandline'
# As of 2.6, fish's "complete" function does not understand # As of 2.6, fish's "complete" function does not understand
# subcommands. Instead, we use the same hack as __fish_complete_subcommand and # subcommands. Instead, we use the same hack as __fish_complete_subcommand and
@@ -95,7 +95,7 @@ end
### Git ### Git
``` ```fish
function fco -d "Fuzzy-find and checkout a branch" function fco -d "Fuzzy-find and checkout a branch"
git branch --all | grep -v HEAD | string trim | fzf | xargs git checkout git branch --all | grep -v HEAD | string trim | fzf | xargs git checkout
end end
@@ -106,21 +106,21 @@ end
``` ```
### SSH ### SSH
``` ```fish
function fssh -d "Fuzzy-find ssh host and ssh into it" function fssh -d "Fuzzy-find ssh host and ssh into it"
ag '^host [^*]' ~/.ssh/config | cut -d ' ' -f 2 | fzf | xargs -o ssh ag '^host [^*]' ~/.ssh/config | cut -d ' ' -f 2 | fzf | xargs -o ssh
end end
``` ```
### Tmux ### Tmux
``` ```fish
function fs -d "Switch tmux session" function fs -d "Switch tmux session"
tmux list-sessions -F "#{session_name}" | fzf | xargs tmux switch-client -t tmux list-sessions -F "#{session_name}" | fzf | xargs tmux switch-client -t
end end
``` ```
### LastPass CLI ### LastPass CLI
``` ```fish
function fpass -d "Fuzzy-find a Lastpass entry and copy the password" function fpass -d "Fuzzy-find a Lastpass entry and copy the password"
if not lpass status -q if not lpass status -q
lpass login $EMAIL lpass login $EMAIL