OSX terminal broken after trying to install cisco packet tracer - bash

I tried to install cisco packet tracer on my mac. It was a sh script to install it. I ran it but not in su and it did some mess on my mac. After 1min i saw that my disk was full, since the script copied repertories everywhere.
Now, when i launch my terminal, the commands i recently installed (npm, brew, cordova...) are not recognized anymore, and there is not my user name at the beginning of the line, there is
-bash-3.2$
At every launch of the terminal, i get this error on the top of it :
Last login: Wed Jan 4 17:04:13 on ttys000
-bash: /etc/profile: line 1: syntax error near unexpected token `('
-bash: /etc/profile: line 1: `-e \n# System-wide .profile for sh(1)\n\nif [ -x /usr/libexec/path_helper ]; then\neval `/usr/libexec/path_helper -s`\nfi\n\nif [ "${BASH-no}" != "no" ]; then\n[ -r /etc/bashrc ] && . /etc/bashrc\nfi\nPT7HOME=/Users/myusername/Documents/pt'
I deleted the folder /Users/myusername/Documents/pt, but it seems that this is where the error is coming from. Thank you in advance for your help.

The error message implies that your /etc/profile, which by default looks like
# System-wide .profile for sh(1)
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
was intended to be modified by adding a single line to the bottom
# System-wide .profile for sh(1)
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
PT7HOME=/Users/myusername/Documents/pt
However, something went wrong, and in addition to adding a few extra characters to the beginning of the file, the indentation was removed and the newlines were converted to literal \n sequences, resulting in the contents becoming a single line, perhaps
-e \n# System-wide .profile for sh(1)\n\nif [ -x /usr/libexec/path_helper ]; then\neval `/usr/libexec/path_helper -s`\nfi\n\nif [ "${BASH-no}" != "no" ]; then\n[ -r /etc/bashrc ] && . /etc/bashrc\nfi\nPT7HOME=/Users/myusername/Documents/pt
Without further information, I would suggest that you could simply edit the file to look like the modified version above. However, #n.m.'s and #cdarke's suggestions should both be taken: restore from backup if possible, and contact user support to figure out what exactly may be wrong with the script.

Related

duplicate paths found in tmux mac

i have a mac terminal where i have a tmux session running. When i call my env variable, i get duplicate paths that repeat. I tried various solutions here but none seem to work. I'm using zsh shell by default.
What i tried:
Went to my zprofile and included the following line:
if [ -f /etc/profile ]; then
PATH=""
source /etc/profile
fi
Didn't work.
Went to my profile and have the following code, still didn't work:
if [ -x /usr/libexec/path_helper ]; then
PATH=""
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
My bashrc file:
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
All the above files are located in /etc/ directory.
All my env variables are in .zprofile.
Thanks
Actually, this worked for me.
tmux set-option -g default-command zsh
i put above statement in my terminal

Weird combination of numbers and letters in front of terminal prompt macOS

Curious as to why I have the sequence : h-63-4 in front of my terminal prompt.
Example: (base) h-63-4:~ axel$
Screenshot
I believe I was messing around with virtual environments in python when it first started appearing, but haven't been able to figure out as to what's causing it.
Contents of my .bashrc:
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"

Automatically enabling bash completion on Fedora 28

I have a Fedora 28 installation on which I have installed the bash bash-completion package.
I have run the following:
source /etc/profile.d/bash_completion.sh
And bash completion works as expected.
However, whenever I re-login, I must run the above command before bash completion starts working - it is not enabled automatically.
I have checked the permissions of the bash_completion.sh file and even added the x flag, but it is still not enabled automatically.
How can I get this working?
The /etc/bashrc file provided by the setup package, will source all scripts in /etc/profile.d/ by default. Also, by default your ~/.bashrc, should have the following (you can verify it's the default by looking in /etc/skel/.bashrc) :
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
Here's the relevant part (towards the end) of that file that I see on my system (Fedora 28 Workstation):
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
Here's the version of setup that I'm using (and proof that that's where it comes from):
$ rpm -q --whatprovides /etc/bashrc
setup-2.11.4-1.fc28.noarch

How to deactivate bash_history stats print when opening a new terminal window on my mac?

I just reinstalled MacOS (OSX 10.12) and as I'm redoing my IDEs and such I get this strange bash_history stats object that prints to every new terminal window! It's driving me bonkers, and after looking through all the preferences an settings I can't seem to turn it off! Does anyone know why this is suddenly happening? Is it something to do with iCloud Profile Syncing? Here's s picture below. Thanks so much for your help!
Screenshot of bash terminal history stats
Last login: Wed Jul 5 03:23:51 on ttys005
/Users/admin/.bash_sessions/5D8EB886-1FE8-4DF6-AC4C-6ACE7B8CF803.historynew Stats {
dev: 16777220,
mode: 33152,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 1411298,
size: 0,
blocks: 0,
atime: 2017-07-05T10:24:18.000Z,
mtime: 2017-07-05T10:24:18.000Z,
ctime: 2017-07-05T10:24:18.000Z,
birthtime: 2017-07-05T10:24:18.000Z }
CafeMisto:~ admin$
so the /etc/profile is like this:
# System-wide .profile for sh(1)
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
and the /etc/bashrc is like this:
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
and I've checked my user/profile home folder and there's no .bashrc...
I've had the same problem, and have tracked it down to having the touch NPM/Node package installed globally on the system, which places an alternative touch command in your PATH.
$ ls -l $(which touch)
lrwxr-xr-x 1 timshel admin 74 18 Jul 12:47 /usr/local/bin/touch -> ../../../Users/timshel/.config/yarn/global/node_modules/touch/bin/touch.js
(I've used yarn global add to install packages on my system rather than npm install -g)
On my system, a simple $ rm /usr/local/bin/touch fixed the issue (I think the touch NPM package got installed as a dependency on my system; it isn't even installed properly).
Also, the reason you only observed this in Apple Terminal is that the touch command which causes the Stat data to be printed is located in /etc/bashrc_Apple_Terminal; which is only loaded in Apple Terminal by the following line in /etc/bashrc:
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
/etc/bashrc_Apple_Terminal isn't loaded in other terminal emulators (e.g. your platformioIDE example).

A usage of dot in bash script

What does dot mean in line 8 of the following code snippet, from the source of /etc/profile in Mac OS X Mavericks terminal.
1 # System-wide .profile for sh(1)
2
3 if [ -x /usr/libexec/path_helper ]; then
4 eval `/usr/libexec/path_helper -s`
5 fi
6
7 if [ "${BASH-no}" != "no" ]; then
8 [ -r /etc/bashrc ] && . /etc/bashrc
9 fi
In bash, . is another way to spell source. So this line is the same as this:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && source /etc/bashrc
fi
source interprets the file as if the content was included at the location of the source command. The difference with executing it is that it can set alias or define function or variables.
According to Bash Prompt HOWTO:
When a file is sourced (by typing either source filename or . filename
at the command line), the lines of code in the file are executed as if
they were printed at the command line. This is particularly useful
with complex prompts, to allow them to be stored in files and called
up by sourcing the file they are in.

Resources