vscode integrated terminal throwing bash error - echo: command not found - bash

On my Macbook, the integrated terminal in VSCODE which is using bash shell is throwing the error "bash: :echo: command not found" as soon as I open it and on every command that I execute in it.
But I dont see this error in my iterm or Terminal though. They both work fine. I am getting this error only in VSCode integrated terminal
It was not happening previously. I am not sure what got changed recently.
I checked if the same issue is happening in iterm and Terminal also or not. But it doesn't happen in them.
Checked the .bash_profile and .bashrc files. But they seem to be fine.
Only place I can find echo command in my bash_profile:
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007";':"$PROMPT_COMMAND";
fi
.bashrc doesn't contain any echo commands
Please let me know why this error is coming in vscode integrated terminal only and how to fix it.

Instead of this:
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007";':"$PROMPT_COMMAND";
Try this one:
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"';

Related

-bash: ls: command not found [duplicate]

This question already has answers here:
Bash script prints "Command Not Found" on empty lines
(17 answers)
Closed 4 years ago.
I have setup react-native in my system.
I have mac OS X El Capitan.
After completing setup of react native, whenever i open my terminal and type command ls then, it shows "command not found".
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
After executing above two lines in my terminal, everything works fine. ls command is working after that. But once i close my terminal and again open it, ls command stops working and it shows "command not found".
I have also tried to add above two lines in .bash_profile file, but didn't get success. I don't know how to get rid of this issue.
Add following line to you .bash_profile
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
Simply you can do it by following command
echo "export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in" >> ~/.bash_profile
After that please restart your terminal

Set up path on prompt on pycharm terminal windon

I just upgrade pycharm into 2016.3.1. Before upgrade, I do not have problem to see the current directory path under the prompt on terminal window. After upgrade into pycharm 2016
3.1. All directory path on prompt on terminal window seems like messed up with 133;C;133;D;01337;RemoteHost=hawkins#pc_name.home1337;CurrentDir=/Users/hawkins/path133;MAC:path hawkins$ 133;B for some reason. Anyone have expereience on how to resolve this?
MAC:path$
133;C;133;D;01337;RemoteHost=hawkins#pc_name.home1337;CurrentDir=/Users/hawkins/path133;MAC:path hawkins$ 133;B
133;C;133;D;01337;RemoteHost=hawkins#pc_name.home1337;CurrentDir=/Users/hawkins/path133;MAC:path hawkins$ 133;B
133;C;133;D;01337;RemoteHost=hawkins#pc_name.home1337;CurrentDir=/Users/hawkins/path133;MAC:path hawkins$ 133;B
I had a similar problem. It turned out my problem was due to have iTerm shell integration installed.
As you have tagged the question [osx], I assume that you might also have done this.
There is a nice explanation to what these strange symbols mean in this answer: https://unix.stackexchange.com/a/294886/47407
I figured I could avoid having to uninstall Shell Integration by clearing my PROMT_COMMAND, and setting PS1 again. I made a shell script called pycharm_terminal.sh with the following
export PROMT_COMMAND=
export PS1="\[\e[31m\]\u\[\e[0m\] at \[\e[33m\]\h\[\e[0m\] in \[\e[32m\]\w\[\e[0m\] at [\A] \[\033[31m\]`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\[\033[35m\]\n$ \[\033[00m\]"
bash -i
The PS1 variable can be set to whatever you had before. This is just how I like mine.
Now, in PyCharm Settings: Go to Tools > Terminal and in "Shell path" set it to /bin/bash <path_to_pycharm_terminal.sh>.
Now try opening a new terminal in PyCharm. It shouldn't have those control character errors.
Solution that worked for me:
Go to Settings > Plugins
Find plugin "Python Terminal" and disable it
Restart PyCharm
The only negative effect I've noticed - auto activation of virtualenv on terminal start doesn't work.
for some reason, I figure it out by create a .pycharmrc under by user directories
and setting up /usr/local/bin/bash --rcfile ~/.pycharmrc under Tool->Terminal on shell path. It seems like it fixed but i have no idea why
MAC: path$ cat ~/.pycharmrc
exec bash
This is what worked for me:
Created new file pycharm_terminal.sh with one command bash -l
Then I set PyCharm Settings: to Tools > Terminal and in "Shell path" set it to /bin/bash/path_to_pycharm_terminal.sh.
Restart PyCharm and all work as expected
bash -l, by man, is a: -l Make bash act as if it had been invoked as a login shell (see INVOCATION below).
which is probably mean, that when PyCharm starts the Terminal and executing the pycharm_terminal.sh with bash -l, everything in .bash_profile is include by default
Found this question while trying to resolve similar issue for 'Geany' on mac osx. I had an install of iterm2 on my machine and was getting garbage in front of the terminal prompt.
similar solution as KPLauritzen offered also works for 'Geany' terminal as such.
Hope this helps someone:
Create shell script in home directory using desired PS1 & CLICOLOR settings:
~/geany_terminal.sh
export PROMT_COMMAND=
export PS1='[\e[1;32m][\u#\h \W] \D{%F %T}\n\$[\e[0m]'
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
bash -i
Then I went to 'Edit -> Preferences --> Terminal' and set my 'Shell' to:
/bin/bash /Users/myusername/geany_terminal.sh
Upon reloading Geany, the Terminal now displays with PS1 and CLICOLOR settings exactly as I have set in my .bash_profile without garbage in front.
You can just activate your .bash_profile
/bin/bash --rcfile ~/.bash_profile

Bash aliases not recognized after uninstalling oh my zsh

After I attempted to uninstall oh-my-zsh, I am getting the error
/Users/Thomas/.zshrc:source:56: no such file or directory: /Users/Thomas/.oh-my-zsh/oh-my-zsh.sh
This issue indicates that the original shell needs to be reverted back to, however the provided command
chsh -s /bin/bash
is not working. I've restarted my iTerm as well. And my aliases still don't work, as well as exported variables such as $JAVA_HOME return empty, even though they are properly set using my former .bash_profile. Also rather than ending with a ~ my terminal prompt ends with a %
Thomas%
How can I revert?
One detail, when I attempted the uninstall via uninstall_oh_my_zsh I mistyped my password. Rather than prompting me again, it looked as though it went ahead and completed the uninstall, but maybe some component of it didn't complete properly.
Make sure you have Brew installed.
Enter brew remove zsh into the terminal then reset your terminal, it should reconfigure back to your original shell.
For this kind of error, you need to check if you set the default bash to zsh in .bashrc file. So, if there is any, just comment them out.
Example for mine.
#Launch Zsh
if [ -t 1 ]; then
exec zsh
fi
So, you just need to comment that out.
#Launch Zsh
#if [ -t 1 ]; then
#exec zsh
#fi

OSX/ how to exit bash in terminal

I was trying to setup home-brew and git(installed) via terminal . After i failed to install home-brew i tried to fix the errors that appeared and terminal entered bash and doesn't accept my commands . I tried quitting the terminal app or exit,logout, restart system etc.
Savvass-MacBook-Pro-2:~ Solen$ clear
-bash: clear: command not found
Savvass-MacBook-Pro-2:~ Solen$
SO your path seems to be wrong. You have to fix it :
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
Then export it :
export PATH;
And that should be enough

Bash Login prompt disappeared

I recently made changes to my /etc/profile, and afterwards when I open a new tab in iTerm or Terminal I don't get a prompt. I tried reverting the changes in /etc/profile to the way I thought they were before - using Vim's undo - but I still don't get a login prompt, I just get a blank screen with a blinking cursor in the top left corner. I tried logging in as a different user, and the other user has the same problem, so I think the error is in the global bash login. /etc/motd doesn't run, but I'm not sure about the other files. Normally I would restart the computer but I have one shell that works and I'm hesitant to lose it by restarting the computer. Is there anywhere where an error would be logged? Thanks for your help,
Kevin
Here's my /etc/profile:
#put this in to try and debug, but does not show on the screen
echo "hello"
export PYTHONPATH=/Library/Python/2.6/site-packages:$PYTHONPATH
# System-wide .profile for sh(1)
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
fortune
Since when you open a new terminal it remains open, it seems that bash is still running but:
It does not show a prompt because you broke $PS1. In that case you might be still able to enter commands. export PS1='$ ' would be a good start in that case.
or
It is still doing something from /etc/profile. Either it's waiting for another process, or it has entered some kind of infinite loop - like the one caused by a shell file source loop.
Since you have a working terminal, you should check the running processes in ps before and after you start a new shell, to get an idea on what's going on.
I accidentally closed the window, and after I did I tried restarting the computer. When I logged back in the prompt displayed properly. Thanks for the help in the meantime.

Resources