Git Product home page Git Product logo

Comments (5)

rcaloras avatar rcaloras commented on July 4, 2024 1

I've considered this before. @jombooth What about the case where we have duplicate commands and ignoredups set? e.g. You enter the same command twice. History will not change (no increment in number) but we should invoke preexec.

from bash-preexec.

rcaloras avatar rcaloras commented on July 4, 2024

@davefx thanks for reporting! Giving it a look.

from bash-preexec.

jombooth avatar jombooth commented on July 4, 2024

I have an idea for fixing this; the output of fc -l (a replacement for history, see #53) gives a number for each command, like this:
1048 set +x
1049 ls
1050 ld
1051 fc -l 0

if we store the last processed command number, then we can skip preexec in the case it hasn't changed.

from bash-preexec.

dimo414 avatar dimo414 commented on July 4, 2024

Would it make sense to replace the existing short-circuit checks in __bp_preexec_invoke_exec with this check? Put another way is it the case that preexec should fire if-and-only-if the command number has changed?

from bash-preexec.

JeffFaer avatar JeffFaer commented on July 4, 2024

What about comparing this_command to BASH_COMMAND in __bp_preexec_invoke_exec?

$ tmux
tmux $ foo() {
> if [[ -z $i ]]; then
> i=0
> else
> ((i++))
> fi
> (set -o posix; set) > ~/env.$i
> }
tmux $ preexec_functions+=(foo)
tmux $ echo 1 2 3
tmux $ <CTRL + D>
$ grep 'this_command' ~/env.0 ~/env.1
~/env.0:this_command='echo 1 2 3'
~/env.1:this_command='echo 1 2 3'
$ diff ~/env.0 ~/env.1
4,5c4,5
< BASH_ARGC=()
< BASH_ARGV=()
---
> BASH_ARGC=([0]="1")
> BASH_ARGV=([0]="/home/jeffrey/.bash_logout")
7c7
< BASH_COMMAND='echo 1 2 3'
---
> BASH_COMMAND='[ "$SHLVL" = 1 ]'
9,10c9,10
< BASH_LINENO=([0]="67" [1]="10")
< BASH_SOURCE=([0]="main" [1]="/home/jeffrey/src/bash-preexec/bash-preexec.sh")
---
> BASH_LINENO=([0]="213" [1]="5" [2]="11")
> BASH_SOURCE=([0]="main" [1]="/home/jeffrey/src/bash-preexec/bash-preexec.sh" [2]="/home/jeffrey/.bash_logout")
26c26
< FUNCNAME=([0]="foo" [1]="__bp_preexec_invoke_exec")
---
> FUNCNAME=([0]="foo" [1]="__bp_preexec_invoke_exec" [2]="source")
103c103
< __bp_last_argument_prev_command=
---
> __bp_last_argument_prev_command=3
723c723
< i=0
---
> i=1

from bash-preexec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.