paulmars / realiaser Goto Github PK
View Code? Open in Web Editor NEWRealiaser is a game which helps you memorize your shell aliases.
License: MIT License
Realiaser is a game which helps you memorize your shell aliases.
License: MIT License
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
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.