mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
Enable syntax highlighting for snippets.
@@ -3,7 +3,7 @@ Examples for fish shell
|
||||
|
||||
### Navigation
|
||||
|
||||
```
|
||||
```fish
|
||||
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
|
||||
[ "$result" ]; and cd $result
|
||||
@@ -11,7 +11,7 @@ function fzf-bcd-widget -d 'cd backwards'
|
||||
end
|
||||
```
|
||||
|
||||
```
|
||||
```fish
|
||||
function fzf-cdhist-widget -d 'cd to one of the previously visited locations'
|
||||
# Clear non-existent folders from cdhist.
|
||||
set -l buf
|
||||
@@ -31,7 +31,7 @@ end
|
||||
### 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.
|
||||
```
|
||||
```fish
|
||||
function fzf-select -d 'fzf commandline job and print unescaped selection back to commandline'
|
||||
set -l cmd (commandline -j)
|
||||
[ "$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).
|
||||
|
||||
```
|
||||
```fish
|
||||
function fzf-complete -d 'fzf completion and print selection back to commandline'
|
||||
# As of 2.6, fish's "complete" function does not understand
|
||||
# subcommands. Instead, we use the same hack as __fish_complete_subcommand and
|
||||
@@ -95,7 +95,7 @@ end
|
||||
|
||||
### Git
|
||||
|
||||
```
|
||||
```fish
|
||||
function fco -d "Fuzzy-find and checkout a branch"
|
||||
git branch --all | grep -v HEAD | string trim | fzf | xargs git checkout
|
||||
end
|
||||
@@ -106,21 +106,21 @@ end
|
||||
```
|
||||
|
||||
### SSH
|
||||
```
|
||||
```fish
|
||||
function fssh -d "Fuzzy-find ssh host and ssh into it"
|
||||
ag '^host [^*]' ~/.ssh/config | cut -d ' ' -f 2 | fzf | xargs -o ssh
|
||||
end
|
||||
```
|
||||
|
||||
### Tmux
|
||||
```
|
||||
```fish
|
||||
function fs -d "Switch tmux session"
|
||||
tmux list-sessions -F "#{session_name}" | fzf | xargs tmux switch-client -t
|
||||
end
|
||||
```
|
||||
|
||||
### LastPass CLI
|
||||
```
|
||||
```fish
|
||||
function fpass -d "Fuzzy-find a Lastpass entry and copy the password"
|
||||
if not lpass status -q
|
||||
lpass login $EMAIL
|
||||
|
||||
Reference in New Issue
Block a user