OSX terminal weird prefix - macos

I noticed that I have some weird prefix in my bash terminal - unknown-MACADDRESS. I think in all unix terminals it is suppose to be host name and login. I've tried go to sharing and change my host name in there, but unknown- stays in terminal.
Not sure where problem is, do you know how to change it?
Thanks a lot for any help!

Use the hostname command
$ sudo hostname dan

For me this: scutil --set HostName yourname changed the name and it works even after a restart.

Related

Opening terminal in current directory

I am attempting to set up the behavior described in the title. For reference, there is an answer which solve this for emacs. I however use DWM/ST and Zsh.
The solutions I have clumsily tried to come um with include modifying the .zshrc file in the with the following lined:
cd $pwd
I have realized this does not make sense as the path displayed by this instance of pwd will in fact be the path in which the terminal itself is opened, which is $HOME. Maybe the solution is messing with ST, but I have not had any ideas of how to do do so. Any help would be appreciated.
it depends on the terminal emulator that you're using: for instance
$lxterminal --working-directory=./
Works for zsh in my manjaro distribution.
in Ubuntu i might use:
$x-terminal-emulator ./

Command line prompt changed in local network

I was sitting in my university and working with terminal (mac os, bash). So far i connected to the local wi-fi and after certain amount of time i found out that my cli prompt line changed from default to h55
I printed:echo "$PS1"
it showed, what it should: \h:\W \u\$
Also, my friend told me, that it happen to him too.
I googled that connecting to local network can cause this behaviour
So i wonder, how it works, that connecting to local network can change my prompt line?
Thanks in advance.
\h means your current hostname. When you connect to a network via dhcp, it will often try to set your hostname for you, and I'm guessing that's what happened here. You could run hostname to confirm what your current hostname is.
Also, I'm assuming that only that hostname part of the prompt changed to h55, not the entire thing. If that is wrong, please update your question with "before" and "after" examples of your prompt.
On Mac
I prefer to shorten this to a simple dollar sign ($) in order to free up space.
To change your default command line prompt, follow these instructions:
Navigate to your home directory: cd ~
Create a file called .bash_profile: vi .bash_profile
Add the following line (press i) export PS1="$ "

Yosemite Terminal weirdly says Meia:/

My Yosemite Terminal App say "Meia:/ username$"?
I don't know what Meia stands for.
Normally I would expect something else. Can I change it?
That is the name given to your computer!
Change it here, no need for terminal command.
System Preferences > Sharing
Change your Computer Name here.
I ran this command and it changed to MYHOSTNAME.
sudo scutil --set HostName MYHOSTNAME.local

/bin/dash cannot find hostname

I have newly installed a remastered ubuntu 12.10. after installation I ran a script to make a standard user and do some other works. now when I log into the new standard user and open terminal, it only shows a $ mark and doesnt show username#hostname$.
it can return whoami but doesnt return anything for echo $HOSTNAME
the interesting thing is when I run bash, everything is ok, but when I run dash(which is default in ubuntu) I see the problem.
I've tried dpkg-reconfigure dash but nothing changed.
can anyone guess what is happened to my system!
thank you in advance.
I suggest to use bash instead of dash since the former is far better for interactive use.
The shell for the new user is probably set to /bin/dash, you just have to create the new user specifing the shell you want using the --shell option for the adduser command.
To change the shell for an alredy created user you can use the command chsh.

How to set up sh script to be ran with Terminal (mac os) by default?

I have a sh script (scala compiler). I'm trying to run it from Terminal application: sudo fsc, but it says that the file can't be found. I've set chmod +x, so script should be visible. It's sh script, not bash.
Is it any possible?
UPD: thanks all for the great answers, i really did learn a lot :)
to set up Path properly, everyone can see: http://macosx.com/forums/unix-x11/250180-set-path-environment-variable.html
thx everyone!
If the script is in the current directory, you must always prefix its name by "./" which would gave in that case :
sudo ./fsc
Cheers
First, if it's in the local directory and not a directly specified in $PATH, you need to preface it with ./ .
Second, once the script is given execute permissions, if it's still not working, try adding #!/bin/sh or whatever the path to the interpreter is at the top.
Has sudo been configured with the --wth-secure-path option. If so then it will use a secure path and ignore your path setting altogether.
You can find this out by typing sudo -v when you are already root.
If it is configured with secure path then the only way is to put the command into one of the directorys specifed in secure path or to pass the full pathname as the argument to sudo.

Resources