Date command with zsh - date

I'm trying to use the date command to output today's date in the format %d.%m.%y-%H:%M:%S. Obviously I just do that like this:
date +%d.%m.%y-%H:%M:%S
This works fine in bash and I get the output I'd expect, but when I do this in zsh I get what I'd expect prefixed by '7m', for example
7m07.09.12-16:49:37
instead of
07.09.12-16:49:37
I also get an alert from my terminal. This is caused by the %S for seconds, because when I take that off the end of the command I don't get the '7m' (but obviously I'm missing the seconds off the end of the date).
Can anyone explain why this happens?
EDIT: extra information: I'm on OS X 10.8 and with zsh 4.3.11, oh-my-zsh installed

One workaround is to wrap the code around echo $(...). It produces the right output and was acceptable for me. Your original command would look like:
echo $(date +%d.%m.%y-%H:%M:%S)

I had the same issue, and could solve it by commenting out line 12 of .oh-my-zsh/lib/termsupport.zsh as suggested at https://github.com/robbyrussell/oh-my-zsh/issues/521

I am sure that you have copied CTRL chars somewhere.
7m is a control code to reset.
Look for ^[[7m when you are editing.
If you just want the time then ZSH has a nice %*
if you want date and time then try
RPS1='%W %*'
If you like it, then put it in PS1 or wherever you like.

Related

Nothing happens when I try to generate a key

I'm trying to generate a key for my computer, but I notice that when I try running the command that I see on GitHub.com, nothing happens, and I only get a prompt. I'm wondering what could be happening? Advice is appreciated, thanks!
I tried searching up how to generate an SSH key, and it seems that I'm supposed to be getting a different output. I tried going into different directories but got the same issue.
Edit: Adding text output, since I can't seem to produce an image.
[username]$ ssh-keygen -t ed25519 -C “[Github email]"
(Output): ">"
One of your quote symbols is the wrong type of quote symbol - specifically, it's U+201C LEFT DOUBLE QUOTATION MARK. Re-type the command - it was probably messed up by copying it from somewhere.
If your shell prompts you with a >, that means you are not done entering your command yet. Try typing something simple like
echo "test
Bash will display a > and wait for you to finish the command. In this case it's because you've opened a quote (the last character in your command) and not yet closed it.

Powershell commands?

Ok I'm having trouble and google isn't helping, so I thought I'd come to you geniuses. I'm using Powershell and posh-git, and it keeps doing something that I'm sure I can exit out of with a magic command, I just don't know it yet.
Basically, when I run git diff (or something else with a long result), it will only give me a screen's worth of information, and end the screen with a colon
:
And if I keep pressing Enter it will add more to the screen til it is done showing everything for that command, and shows
<END>
But now what? How do I get out of this and back to calling commands? Enter, Esc and the other things I thought to try are not helping. I'm sure this must be a simple thing, but I don't know how to explain to Google what I want.
Anyone know?
if you do a git config -l you may see some relevant entries like:
core.pager='less'
pager.diff=false
pager.log=true
You can enable or disable the pager for different commands, or set a different pager. https://www.kernel.org/pub/software/scm/git/docs/git-config.html has the details, check out the core.pager section and pager.<cmd> sections for specifics.
If you're using 'less' as your pager, hit 'h' at that : prompt to get lots of details about what you can do there, and as pointed out by others, q, Q, or ZZ will get you back to the command line.
You can terminate the current command using CTRL+C. Is that what you're asking?

Appcmd command not working

appcmd set config /section:applicationPools /[name='xxx - yyy'].processModel.idleTimeout:0.00:00:00
When I run this command, instead of receiving a validation message or an error message, the command goes "idle".
It actually just display the caret and I can write text, or wathever... until I CTRL+Break the command.
I tried waiting for 10 minutes but nothing else ever happens.
It's really weird, the command seems correct :S
Do you know what I possibly could be doing wrong?
Apparently when there is a space in the application pool's name, you have to put the "modification parameters" in quote.
So the command should actually be like this:
appcmd set config /section:applicationPools "/[name='xxx - yyy'].processModel.idleTimeout:0.00:00:00"
It really gets me to wonder why the simple quotes aren't useful enough.

Running octave in Emacs

I am using run-octave in Emacs to trigger octave. Something is acting abnormally.
Every time I hit TAB to complete, there would be a tailing ^M; If I edit a .m file using edit a.m, it would start a new frame instead of a new buffer and the prompt is waiting for the closure of that frame so it would not respond to any input. How could I configure .emacs so that run-octave would behave normally?
Any comment is appreciated!
You seem to have two problems. I'm not sure about the trailing ^M, which seems to be caused by some sort of Windows/Unix CR/LF problem, but maybe I can help with the second problem.
The edit command uses the EDITOR environment variable to decide what to run. It seems that yours is either set to emacsclient or has defaulted to it. You haven't said whether you're on Unix or Windows, so I'm going to assume the former: you'll have to change this a bit for Windows.
To avoid the waiting thing, try running octave with a different EDITOR. For example, try out running
EDITOR='emacsclient -n' octave
When you type edit foo, it should bring up an Emacs buffer (if you want a new frame as well, use -c too) but not wait until you're done.
If this fixes things for you, you could change your ~/.bashrc to include the line
export EDITOR='emacsclient -n'

Matlab-like command history retrieval in unix command line

In Matlab, there is a very nice feature that I like. Suppose I typed the command very-long-command and then a few several commands afterwards. Then later if I need the long command again, I just type very and press the up arrow key, my long command appears. It finds the last command that starts with very. I couldn't do the same in unix command line, when I try to do it, it disregards whatever I typed, and goes back to the last commands in chronological order. Is there a way to do it?
In bash this functionality is provided by the commands history-search-forward and history-search-backward, which by default are not bound to any keys (see here). If you run
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
it will make up-arrow and down-arrow search backward and forward through the history for the string of characters between the start of the current line and the point. See also this related Stack Overflow question.
In bash, hitting ctrl-r will let you do a history search:
$ echo 'something very long'
something very long
$ # blah
$ # many commands later...
(reverse-i-search)`ec': echo 'something very long'
In the above snippet, I hit ctrl-r on the next line after # many commands later..., and then typed ec which brought me back to the echo command. At that point hitting Enter will execute the command.
You can do the same thing by using "!". For example:
$ echo "Hello"
Hello
$ !echo
echo "Hello"
Hello
However, it is generally a bad idea to do this sort of thing (what if the last command did something destructive?). If you expect you will reuse something, then I suggest you create a shell script and save it away somewhere (whenever I plan to reuse something, I create a script in ~/.local/bin).