Skip to content

Instantly share code, notes, and snippets.

@turanegaku
Forked from dedeibel/push-line.fish
Last active August 7, 2021 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save turanegaku/9ac0a75ea08dd353b5d8d0f21149666d to your computer and use it in GitHub Desktop.
Save turanegaku/9ac0a75ea08dd353b5d8d0f21149666d to your computer and use it in GitHub Desktop.
fish shell function to emulate zsh's push-line feature := store the current command and run one in between - restore the last command afterwards
# Save this file to ~/.config/fish/functions/push-line.fish
# Bind the function by using this in ~/.config/fish/functions/fish_user_key_bindings.fish
# function fish_user_key_bindings
# # For example alt+q
# bind \eq push-line
# end
function push-line
set cl (commandline)
commandline -f repaint
if test -n (string join $cl)
set -g fish_buffer_stack $cl
commandline ''
commandline -f repaint
function restore_line -e fish_postexec
commandline $fish_buffer_stack
functions -e restore_line
set -e fish_buffer_stack
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment