Giter Club home page Giter Club logo

realiaser's People

Contributors

paulmars avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lujaw

realiaser's Issues

Partial aliases not found

I have an alias:

alias g='grep --color'

But realiaser does not find it in this command

$ g fred ~/.bashrc

Just to be sure that's not because of the problems I mentioned in issue 1

$ echo "g fred ~/.bashrc" | realiaser
1

I have an alias

alias dev='c /Users/jab/jab/alto/dev'

Which realiser finds when looking directly at the command

$ echo "c /Users/jab/jab/alto/dev" | realiaser
alias dev (0)

But not when actually used as a command - I wonder if that might be because "c" is also an alias

How it tells if my last command should have used an alias?

I'm testing with some git aliases and it isn't telling which alias I should use and it isn't removing 50 points also.

I'm using ZSH 4.3.11 and iTerm2

My prompt it's like this:
PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})$(last_command)%{$reset_color%}%B$%b '

I'm using the ZSH theme gallois, so I've just added the last commands to my prompt.

Prompt function does not allow for history format

On my machine the given method to extract the last command does not work:

$ echo $0
-bash
$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)
Copyright (C) 2007 Free Software Foundation, Inc.
$ history -1 | cut -d ' ' -f 3-20 | realiaser
-bash: history: -1: invalid option
history: usage: history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
1

Even if I were to work around that, the cut command is too simplistic, because it does not consider $HISTTIMEFORMAT:

$ echo $HISTTIMEFORMAT
%h/%d - %H:%M:%S
$ history | tail -n 2 | head -n 1 | cut -d ' ' -f 3-20
 Dec/03 - 23:47:13echo $HISTTIMEFORMAT

OK, let's turn that off

$ unset HISTTIMEFORMAT

Now I wonder about the cut command starting at field 3:

$ history | tail -n 2 | head -n 1 | cut -d ' ' -f 3-20
   981  unset HISTTIMEFORMAT

Those extra spaces before the command number (981) do seem to make the third field less than helpful. I need the 5th instead:

$ cd ..
$ history | tail -n 2 | head -n 1 | cut -d ' ' -f 5-20
cd ..

And that leaves the whole function as

function last_command() {
  local old_format=$HISTTIMEFORMAT
  unset HISTTIMEFORMAT
  echo $(history | head -n 2 | tail -n 1 | cut -d ' ' -f 5-20 | realiaser)
  export HISTTIMEFORMAT=$old_format
}

Which works for me, but YMMV as you may be on Linux or Solaris or ... some other variety of Unix

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.