zsh-users
 help / color / mirror / code / Atom feed
* save a command in history from within the widget
@ 2020-10-24 19:00 Ahmad Ismail
  2020-10-25 20:24 ` Daniel Shahaf
  2020-10-29 11:07 ` Lewis Butler
  0 siblings, 2 replies; 10+ messages in thread
From: Ahmad Ismail @ 2020-10-24 19:00 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]

Hi All,

I am currently working on a widget. It is used so that I can use my git
alias also for my dotfiles.

The widget is given bellow:

function _check-if-dotfile-command {

if [[ $BUFFER =~ ^"g d untrack-all" ]]
then
zle .kill-whole-line
BUFFER="g d rm --cached -r ~"
zle .accept-line
elif [[ $BUFFER =~ ^"g d add-and-commit" ]]
then
BUFFERz=$(echo $BUFFER | cut -d '"' -f2)
zle .kill-whole-line
BUFFER="git d add ~ && g d commit -am \"${BUFFERz}\""
zle .accept-line
elif [[ $BUFFER =~ ^"g d sb" ]]
then
zle .kill-whole-line
BUFFER="git d branch | rofi -dmenu | xargs git checkout"
zle .accept-line
elif [[ $BUFFER =~ ^"g d stash-and-reset" ]]
then
zle .kill-whole-line
BUFFER="git d stash && git d reset --hard HEAD"
zle .accept-line
elif [[ $BUFFER =~ ^"g d last" ]]
then
zle .kill-whole-line
BUFFER="git d --no-pager log -1 --oneline"
zle .accept-line
else
zle .accept-line
fi
}

zle -N accept-line _check-if-dotfile-command

Now, the problem is, the commands I am invoking are not being saved in the
history file.
For example, if I use:

% g d add-and-commit "Few Modifications"

it saves:

: 1603565685:0;git d add ~ && g d commit -am "Few Modifications"

I know the command below is the command I actually ran. But I want to save
the command I used as well. Is there any way I can save a command in
history from within the widget?

*Thanks and Best Regards,Ahmad Ismail*

[-- Attachment #2: Type: text/html, Size: 9022 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-29 23:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-24 19:00 save a command in history from within the widget Ahmad Ismail
2020-10-25 20:24 ` Daniel Shahaf
2020-10-25 21:13   ` Ahmad Ismail
2020-10-26 22:04     ` Daniel Shahaf
2020-10-27 19:01       ` Ahmad Ismail
2020-10-26  7:11   ` Roman Perepelitsa
2020-10-26 11:15     ` Ahmad Ismail
2020-10-26 14:19       ` Ahmad Ismail
2020-10-29 11:07 ` Lewis Butler
2020-10-29 23:54   ` Ahmad Ismail

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).