Last active
June 1, 2021 17:05
-
-
Save cosi1/8412e81452867729d8d75210f763a144 to your computer and use it in GitHub Desktop.
`find_file` function for Emacs' vterm and fish shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function find_file | |
| set -q argv[1]; or set argv[1] "." | |
| vterm_cmd find-file (realpath "$argv") | |
| end | |
| function vterm_cmd --description 'Run an Emacs command among the ones been defined in vterm-eval-cmds.' | |
| set -l vterm_elisp () | |
| for arg in $argv | |
| set -a vterm_elisp (printf '"%s" ' (string replace -a -r '([\\\\"])' '\\\\\\\\$1' $arg)) | |
| end | |
| vterm_printf '51;E'(string join '' $vterm_elisp) | |
| end | |
| function vterm_printf | |
| if begin; [ -n "$TMUX" ] ; and string match -q -r "screen|tmux" "$TERM"; end | |
| # tell tmux to pass the escape sequences through | |
| printf "\ePtmux;\e\e]%s\007\e\\" "$argv" | |
| else if string match -q -- "screen*" "$TERM" | |
| # GNU screen (screen, screen-256color, screen-256color-bce) | |
| printf "\eP\e]%s\007\e\\" "$argv" | |
| else | |
| printf "\e]%s\e\\" "$argv" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment