Prompt in zsh starts with ↑255 after an error command? - zsh

I'm new to zsh and am using the ZSH_THEME="jnrowe", which works great for a little while.
It starts out and I get a prompt that looks like this:
Ξ ~ →
but if I run a command like: ssh it becomes:
↑255 ~ →
I suspect something is messing up the character that was creating the triple bar in the first one, but have no clue really as to what's going on. I could just pick a different theme, but I've noticed most of them with a fancy character in the prompt do the same thing.
Is this a special error code or something? Or is something just borking out?

I don't know the prompt theme "jnrowe" (it's not part of the default zsh distribution afaics), but I suspect this prompt includes the error code of the last command in its output.
Try to run "ls" or "true" and the number will disapper. Run "false" and it will be 1, run ssh without arguments and it will be 255. zsh preserves this value until you run the next command, so pressing ENTER many times will not clear it.
(This will be the same value that is stored in the shell variable "$?")

Related

system2("bash", "ls") -> cannot execute binary file

Anyone got an idea why
system2("bash", "ls")
would result in (both in R-Gui and RStudio Console)
/usr/bin/ls: /usr/bin/ls: cannot execute binary file
while other shells work w/o issues (see example below) and the "bash" in the RStudio Terminal also works w/o problems. AND if there is a remedy for that?
Working system2 example:
system2("powershell", "dir")
Running R-3.6.3 on Windows 10 here ... with "Git bash" executing as "bash".
PS: just in case someone wonders - I also tried the full path ie /usr/bin/ls -> same result
Ok - this does the trick
system2("bash", input = "ls")
so instead of args = ... as with the powershell command one needs (or more interestingly sometimes 'can') use the input = ... parameter with bash
OR as mentioned in the comments by #oguzismail this will also work
system2("bash", "-c ls")
as well as pointed out by #Christoph
system2("ls")
also works sometimes (ie in some RStudio[?] setups it will not return results in some it will).
But I have come to notice that different combinations of R-versions with different RStudio versions [or more probably Locales] will not always behave consistently of course also depending on the availability of bash commands like ls (more generally /usr/bin) being on the PATH or not.
So choose what suits u best!

why zsh adds "%" at the end of my output

i'm using zsh on my mac (oh-my-zsh) and i don't understand why at the end of my output there is always this character: "%"
If i don't put export TERM="xterm-256color" in my ~/.zshrc i haven't that character:
Usually a bold % (or # for root) with reversed colors is used to signify a "partial" line in the output. That is a line, which is not terminated with a newline character.
As it seems to depend on the value of TERM I suspect an incompatibility between that value and the settings of terminal emulator. Contrary to the warning shown in your second screenshot, you actually should not set TERM in your ~/.zshrc (or anywhere inside the shell session). TERM should always be set by the terminal emulator itself. Its value (in conjunction with the terminfo terminal capability data base) tells the shell and other programs, which features a terminal emulator supports and how to use them. If the value is changed in the shell, the terminal emulator will not know about it. This may lead to programs sending control codes the terminal emulator does not understand correctly or at all.
In order to change the value of TERM you should change it in the terminal emulator settings. According to the iTerm 2 FAQ the settings is to be found at Preferences->Profiles->Terminal->Report Terminal Type.
I personally placed export PROMPT_EOL_MARK='' inside my ~/.zprofile and hide the character.

After effects (CS6) is 'disabled' when running AfterFX.exe -s argument

Writing my first script with after effects to automate some of my process. I want the script to run at startup of AE with some arguments passed via command line so I use the -s command.
Everything is done except for one problem, when I run AfterFX.exe with the -s, for example if i do this:
"PATH_TO_ADOBE_CS6\Support Files\AfterFX.exe" -s "alert('foo')"
It opens after effects and i do get that 'foo' dialog but for some reason After Effects is 'disabled'. What I mean is I can't do anything, not open any project, nothing. all options are grayed out.
Note that if after effects is already running, and I run the command, it doesnt 'disable' after effects and I get the desired result.
I am using windows and after effects CS6.
note: obviously I intend to do something more complex than alert('foo') which was used a minimalist example to show my issue.
figure it out. for those who find this later, the solution is to add app.exitAfterLaunchAndEval = false.. i.e,
"PATH_TO_ADOBE_CS6\Support Files\AfterFX.exe" -s "app.exitAfterLaunchAndEval = false; alert('foo')"

How to prevent zsh prompt from collapsing

I have written my own zsh (actually, I'm using zsh with oh-my-zsh, if it's relevant to the subject) prompt, its code follows:
PROMPT="%{$fg[green]%n%}#%{%m%}:%{$fg[yellow]%~%} %{$fg[red]%#$reset_color%} "
Everything is fine except the only issue: when I use autocompletion (press Tab), prompt collapses to first few symbols.
Here's the screenshot, collapsed prompt is in the left Terminal window, and the normal prompt is in the right window.
http://i.imgur.com/a1iWHdA.png
I'm not sure whether I got it exactly as you wanted but try this for a start:
local gr=${1:-'green'}
local bl=${2:-'blue'}
local re=${3:-'red'}
local wh=${4:-'white'}
local cy=${5:-'cyan'}
local ye=${6:-'yellow'}
export PROMPT="%F{$gr}%n%f#%m:%F{$ye}%~%f %F{$re}%#%f "
I'm not sure exactly what you did wrong, but it appears that those curly braces were messing with your prompt. By approach to prompt customization uses %F{$ID} where ID is one of the identifiers I defined for starting colouring and %f for stopping colouring. You can make text bold using %B (remove bold using %b).

previous command in R console

I would like to retrieve the previous command in my R console that started with a certain character. For example, i can just press the up key to get the last command. However, I'd like the last command that started with xyz for example. Is there a way to do this?
if you're on a linux distro, you can press ctrl+R and start typing, and then ctrl+R to toggle through search matches.
you can also do, history(pattern="^xyz"), but this would require an additional copy.

Resources