How to echo custom startup message in vim - echo

Is there a way to echo a custom message in vim on startup? I tried using echo "Message" in my vimrc, but nothing seems to come up.

You probably want to set up an autocmd to ensure everything is finished loading before your message appears.
autocmd VimEnter * echo "Message"

Heres a command line version that might be helpful in tandem with some type of launcher:
vim -c 'e .|redraw|echom "Welcome!"'

Related

How can I Launching vscode from command line in background?

I'm using shell on linux.
I would like the a way that will launch vscode in the background such that my terminal is still in focus.
I don't want to show any output on my terminal,perhaps chould show in integrated terminal which inside vscode.
Is someone can help me ?Thank you!
Add an & at the end (see: job control), you probably also want to redirect the output. If you would like to log it, redirect to a file like this &> vscode.log, but if you want to ignore it, &> /dev/null (this is called a null device, see this page for more). So the final command is something like this: code . &> /dev/null &.

How to set shell-mode prompt in emacs?

I have set in my ~/.emacs.d/init_bash.sh:
export PS1='\h:\w$ '
without it, my prompt is
bash-3.2$
but now it is
bash-3.2$ computername:~/path/to/directory$
How do I make it just be
computername:~/path/to/directory$
?
It seems to just do this on the first line in the Emacs shell, and "bash-3.2$" goes away after I hit return once. To really get rid of "bash-3.2$", set PS1 in your ~/.bashrc instead.

How to use the ANSIcolor plugin in Jenkins?

I have installed the ANSI-color plugin for Jenkins.
In the Jobs I have activated that plugin with the default profile 'xterm'.
I cannot figure out how to colorize the output of the Console Log when printing to the
log from the batch files (Windows-platform).
The documentation on
https://wiki.jenkins-ci.org/display/JENKINS/AnsiColor+Plugin
is not helpful. There are no examples how to actually print in color.
I tried several different echo/print commands, but I cannot get colors to work.
Any hint appreciated.
The ANSI-color plug in transforms your console output to HTML. If your output contains ansi escape sequences, then it converts these special char sequences into (colored) HTML. You can only configure the mapping via 'ANSI color map'.
Example:
\x1b[31m is transformes html color red
It looks that your program does't use Escape sequences. But if you wrote your own software or script, you can use these Escape sequences.
1st Example BASH:
echo -e "\033[31mRed\033[0m"
2nd Example BASH:
printf "\033[31mRed\033[0m"
If you need it, you have to add a newline sequence to printf:
printf "\033[31mRed\033[0m\n"
More to Escape sequences:
English: http://en.wikipedia.org/wiki/ANSI_escape_code
Deutsch: http://de.wikipedia.org/wiki/Escape-Sequenz
There's a lot more documentation available on the Jenkins-ANSIcolor plugin here:
https://github.com/dblock/jenkins-ansicolor-plugin
I wasn't seeing colors because I was using "high intensity" colors (in the 90's range) and these aren't supported. Gotta stick to colors in the 30's
Double check that the software really is outputting ANSI colours. For example, a bash script running this echo will produce colour with the AnsiColor plugin installed, but it'll produce messed-up escape sequences in the console output with no plugin.
In BASH:
echo -e '\033[35mPurple!\033[0m'
Check your project configuration, check the "Build Environment" and make sure "Color ANSI Console Output" is checked.
If you can't find the "Build Environment" section, go to Manage Plugins to double-check that the right plugin is really installed.(I recently installed the "Ansible" plugin instead of "AnsiColor"....)
Jenkins console output is place where you can spend decent amount of time trying to figure out what went wrong (or perhaps right?).
AnsiColor plugins gives you opportunity to color monochromatic Jenkins console output.
Set-by-step guide
Install AnsiColor plugin Under Build Environment section check Color
ANSI Console OutputJenkins -
Color ANSI Console Output -should look like
TesterFenster Inside Execute shell step add something like:
set +x
info() {
echo "\033[1;33m[Info]    \033[0m $1"
}
error() {
echo "\033[1;31m[Error]   \033[0m $1"
}
success() {
echo "\033[1;32m[Success] \033[0m $1"
}
info "This is information message"
error "Houston we have a problem"
success "Great!!!"
echo "Foreground colors"
echo "\033[31m Red \033[0m"
echo "\033[32m Green \033[0m"
echo "\033[33m Yellow \033[0m"
echo "\033[34m Blue \033[0m"
siz
echo "\033[35m Magneta \033[0m"
echo "\033[36m Cyan \033[0m"
echo "Background colors"
echo "\033[41m Red \033[0m"
echo "\033[42m Green \033[0m"
echo "\033[43m Yellow \033[0m"
echo "\033[44m Blue \033[0m"
echo "\033[45m Magneta \033[0m"
echo "\033[46m Cyan \033[0m"
echo "Different combinations"
echo "\033[1;31m Red \033[0m"
echo "\033[1;4;37;42m Green \033[0m"
echo "\033[1;43m Yellow \033[0m"
set -x
you should see like your output
This only works from the Jenkins console, and not from the actual scripts that out put to your console Output
The OP asked explicitly about using AnsiColor Jenkins Plugin on Windows, so here is my answer:
cmd.exe is not a terminal emulator
As #ocodo wrote, cmd.exe (which is triggered by Jenkins) is not a terminal emulator, so it won't support ANSI output from batch commands by default.
So this is just unsupported on Windows.
These tests were unsuccessful in Jenkins using Windows Batch build step:
echo \e[33m hello \e[0m
echo \033[33m hello \033[0m
echo \x1b[33m hello \x1b[0m
echo \27[33m hello \27[0m
echo \[33m hello \[0m
echo ←[33m hello ←[0m
Last line: To inject an ESC character in a Firefox testbox form, press alt+27, which is also the escape sequence in most editors. more info here: http://www.robvanderwoude.com/ansi.php#AnsiColor and https://groups.google.com/forum/#!topic/jenkinsci-users/0OcjlZQfqrk
A solution: Use Python print for text coloring
The build jobs which use Python for console output had no problem with AnsiColor, so if Python is available in your environment where the console output is generated by a script, you can inject ANSI codes from there. Here's how I worked around it to make it colorful.
Create a helper script in util/ansiGreen.py like so:
#!/usr/bin/env python
print("\033[32m");
Register as env var at the level of your global build configuration:
set ansiGreen=python %cdRootPath%util\ansiGreen.py
Add it to your scripts:
call make-some-tests.bat
if %errorlevel% gtr 0 (
%ansiRed%
echo [ERROR] You screwed up trunk!
%ansiOff%
)
As you can see, %ansiOff% is also required, to end with coloring (Its simply "\033[0m" printed through python). Else everything after %ansiRed% will be in red.
This script is run on a Jenkins slave. To set and get an environment directly within Jenkins batch build step is another challenge.
It's a bit ugly but after a lot of research it seems to be the best workaround to enable AnsiColor to be returned to a Windows Jenkins master from a Windows Jenkins slave.

How to stop Emacs from rendering junk characters in shell?

In my emacs shell, I see this output:
^[[J~% echo $PS1
%2c%%
On my other machine, this stuff doesn't show up at all. Can anyone suggest a reason why and how to fix it?
It's related to your PS1 setting. Basically Emacs will not accept TOO fancy settings of PS1. I used the following code in ~/.bashrc to distinguish PS1 between xterm and other term simulators such as Emacs. You can give it a try.
case $TERM in
xterm)
export PS1='\[\e]0;\u#\h: \W\a\]\[\e[31;1m\]\w\n\[\e[0m\]'
;;
*)
export PS1='\[\e[31;1m\]\w\n\[\e[0m\]'
;;
esac

Invoking external commands with options from a makefile

I have a makefile for compiling Arduino programs.
I need to add some text at the beginning of some files based on some logic. I am using echo command for that.
ECHO = echo
and later in the file, I have lot of places like
$(OBJDIR)/%.cpp: %.pde
$(ECHO) '#if ARDUINO >= 100\n #include "Arduino.h"\n#else\n #include "WProgram.h"\n#endif' > $#
which works fine.
Recently, some users complained that echo command doesn't work properly in some linux distros and I had to add the '-e' option to the echo command.
So I changed the first line where I declare the command to
ECHO = echo -e
This is not working, because makefile considers -e as part of the text and not as part of the option.
Edit:
I am not getting any error, but the text -e is also appended to the file that I am creating.
Is there a way to declare the -e as an option and not as part of the text?
Most likely you're seeing behavior differences because echo is a shell built-in command in some versions of some shells. Then that's being compounded because make only sometimes uses the shell to invoke commands -- it will prefer to invoke commands directly if possible. So, sometimes, on some systems, you are not invoking the echo command that you think you are.
You would probably have better luck by setting
ECHO = /bin/echo -e
which will explicitly invoke the external echo command, even if the shell has a built-in version. That way you should get consistent results.
if get /bin/sh: 1: -e: not found error it's related to your shell, not makefile.else, please put your error. of course if you get error.