Opening terminal in current directory - terminal

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 ./

Related

source /.bash_profile command not working

I am trying to refresh my aliases on my Mac (OS Catalina 10.15.6) after defining new aliases in my .bash_profile file with the command:
source ~/.bash_profile
But terminal keeps giving this error message:-bash: s: command not found
This is confusing because for the longest time this command worked. I even had it included in my .bash_profile file as an alias, where it worked fine.
I'm aware the problem could have to do it with an error in my PATH but I've never made any edits to my PATH so have no idea what the issue could be?
Thanks in advance.
My first instinct would be to check both ~/.bashrc, and /etc/bashrc if it exists. That is where I customarily define aliases, and it looks to me as though a bad alias may be your problem.
I'm not saying it was the one you made, although it might be. Just go through your rc and profile files and look for any aliases which might in any way clash with source.
I suspect the source command is working just fine and the problem is a bad line in the ~/.bash_profile itself that looks like it's trying to run a command named s. I would look in there for the problem.
It might help to run it with xtrace on via bash -x ~/.bash_profile – running it in a separate process like that won't have any of the presumably-desired side effects of sourceing it in your current shell, but you can see what it's trying to do so that you can fix it.
(You can also just set -x before the source and get both xtrace and running in the current shell; just be sure to set +x afterwards or your shell session will be full of debug output.)

Source Bashrc has no effect

So I am extremely new to any kind of software development. Last week I installed Bash on Ubuntu on Windows to work on some coding for work. Unfortunately I did something wrong and had to reinstall everything.
I was almost done with reinstalling Bash on Ubuntu, when I accidentally closed the screen. Now I get exactly the same errors as previously, but I definately do not want to reinstall this again...
So what changed? Before my terminal was colored purple and green. Now, I only get white colors in the terminal. It looks something like this:
Image of terminal
Furthermore, after googling it said to apply
source ~/.bashrc
But then I get the error: "No such file or directory". Bash is installed because it does actually give
which bash -> /bin/bash
I also read that perhaps it could be my path, where $PATH gives me
bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program: No such file or directory
I was hoping that you'd have an idea what could be wrong, and best how to resolve it. I definately do not want to reinstall it AGAIN, because it took me too long already.
Hope you can help me!
Cheers,
Wessel
As stated by Jack, the configuration for bash should be in ~/.bashrc or similar.
What files are listed if you enter this command?
ls -a ~/
If you see .bashrc, you can edit it.
Here some ideas on colouring your prompt
https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/

Add virtualenv name to prompt when using pew

I am using pew to manage virtual environments on macOS El Capitan. I would like to get some indication of the virtualenv I am in once I activate one. According to the docs, this behavior should be available out of the box, but if it is not, that you can configure it by adding source $(pew shell_config) to your .bashrc/.bash_profile. I have added this, but it has no affect.
To create a minimal example, I have removed everything from my .bash_profile except for source $(pew shell_config). When I run the pew workon command, my prompt does change, but it simply changes to bash-3.2$, with no indication of the virtual environment.
How can I update my .bash_profile so that pew workon will cause the name of the virtual environment to be displayed in the prompt?
It is my understanding that the prompt that is setup when you switch to a virtualenv is set in shell_config/init.bash. In my case, this file looks like this:
source "$( dirname "${BASH_SOURCE[0]}" )"/complete.bash
PS1="\[\033[01;34m\]\$(basename '$VIRTUAL_ENV')\[\e[0m\]$PS1"
It looks like this should give me the behavior that I want, but it does not seem to be working, and I am not sure why.
Make a .bashrc in your ~ directory and paste in "source $(pew shell_config)"
I had this issue as well and discovered that pew looks for .bashrc, not .bash_profile.
On Ubuntu 20 paste this to the end of .bashrc
# Pew
source "$(~/.local/bin/pew shell_config)"
If I understand correctly, the problem lies in quoting:
PS1="\[\033[01;34m\]\$(basename '$VIRTUAL_ENV')\[\e[0m\]$PS1"
will expand $VIRTUAL_ENV only when it is called the first time and will define a prompt which is unresponsive to subsequent changes of $VIRTUAL_ENV. Try this:
PS1='\[\e[01;34m\]$(basename "$VIRTUAL_ENV")\[\e[0m\]'"$PS1"

Lost posix utilities on Mac OSX, any ideas on debugging?

Suddenly I lost almost everything on the command line. I can do cd, exit and pwd...nothing else that I tried...no ls, no vi...nothing....
I do have an open terminal that's still working, but no new ones...as soon as I exit out of the current session, I'm screwed...
I was about to say I'm baffled...but I just noticed that now /etc is symlinked to /etc/private. Don't remember that being the case before...
I recently upgraded to Snow Leopard...but I've rebooted since with no problems... No clue when this came about...
Any ideas on debugging it?
It sounds like your PATH environment variable may be messed up. You may have messed it up in a .profile, .bashrc, .tcshrc, .login or similar shell startup file. Check using:
echo $PATH
Then (assuming you are using a bash shell) try setting it with:
export PATH=/usr/bin:/bin
You could also try typing commands using the full path, e.g. /bin/ls. If you want to make sure that your commands are still there you should be able to use echo /bin/* /usr/bin/*.
/etc has always been a symbolic link to private/etc on Mac OS X.
Start with echo $PATH to see what's there. Mine contains:
/Users/jleffler/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:.
On my machine, /etc is a symlink to /private/etc, and /tmp is a symlink to /private/tmp (and isn't accessible to other user IDs).
If that isn't the problem, check whether /usr/bin and /bin are available (they are not symlinked on my machine).

In Mac OSX 10.5, it can't find my Terminal commands sudo, find, etc

I don't know what has happened, but in my Terminal on Mac OSX 10.5 it can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...
My .bash_login file looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
My .bash_profile file looks like this:
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"
I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must of done something for the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!
Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.
Any help would be grand. Thank you - James
It looks like both of your PATH exports are malformed:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
The end bit there won't work. It should be:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH
Notice the colon before '$PATH'? It's important ;)
Also, the double quotes are not necessary.
If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.
Can you post the results of:
$ echo $PATH
Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:
$ env
This should fix the problem completely and permanently.
first, export environment paths by using below command in the terminal.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,
go to home directory
cd ~
open .bash_profile file in nano / vim (I'm using nano here)
nano .bash_profile
This will open up nano editor. In a new line, paste the following;
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.
All done ! Now try the commands.
Check out --- http://www.sweeting.org/mark/blog/2008/05/26/mac-os-x-tip-setting-path-environment-variables
I went trough the same issue and here is how I solved it.
First of all I reverted the file to its original doing this way
/usr/bin/nano ~/.bash_profile
In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed
After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked

Resources