oh my zsh's plugin "osx" not work - macos

As the title,my oh my zsh has installed autojump plugin by homebrew,but osx doesn't work,I have open the plugin named osx in the .zshrc file.eg: plugins=(osx zsh-syntax-highlighting git autojump),and the file names ~/.oh-my-zsh/plugins/osx/os.plugin.zsh is correct.
I use the following command feedbacked a error "zsh: command not found: quick-look".
$ quick-look xx.jpg
I don't know why?Could somebody give me some help?Thx.

You could try:
$ qlmanage -p xx.png
quick-look is a function implemented inside the osx plugin that is actually calling the qlmanage command, if the above command works for you, just create an alias in your ~/.zshrc to your convenient, some like this:
Creating the alias:
$ echo "alias 'quick-look=qlmanage -p' >> ~/.zshrc
Load the new changes to your current session:
source ~/.zshrc
Then you should be able to run:
quick-look xx.png

Related

Show Git Branch Name in Terminal - MacOS Catalina - missing zsh files

I have a fresh MacOS Catalina 10.15.6 and I'm following the steps on this link show git branch name in terminal macos so I can display the branch name on my terminal whenever I cd in a git repository.
I'm in my home directory so when I run ls -la, I can't see any of the following files
.zshrc, .bashrc, .bash_profile, .zprofile
The only relevant files showing on the list are .bash_history and .zsh_history.
Are these located on a different path or am I missing any step in the process?
MACOS Instructions- execute the following commands in your terminal:
cd
nano .zshrc
copy and paste this lines of code:
autoload -Uz vcs_info
precmd() {vcs_info}
zstyle ':vcs_info:git:*' formats '(%b)'
setopt PROMPT_SUBST
PROMPT='%n> ${PWD/#$HOME/~} ${vcs_info_msg_0_}%%'
CTRL+o ENTER to save and CTRL+x to exit
source .zshrc
and that's it. Please share your configuration!
Simplest answer, install Oh My ZSH
Trust me, you can't do a better job customizing your own .zshrc file.
Just go here: https://ohmyz.sh/#install
Run this command in your terminal:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Voila, you got pretty terminal outputs
Following this answer on SuperUser StackExchange, I would assume that you have to create .zshrc, .bashrc, etc., on your own. As far as I can tell, you just need a .zshrc for what you are doing. Then you can continue with the setup from the tutorial.

$ mvn -v – command not found

I installed Maven on macOS 10.12.6.
Added environment to .bash_profile file:
export PS1="\h --- \t *************************** \w $ "
export JAVA_HOME=$(/usr/libexec/java_home)
export MAVEN_HOME=/Users/{user}/Documents/Path/Maven/maven_3.3.9
export GRADLE_HOME=/Users/{user}/Documents/Path/Gradle/gradle_6.1.1
export PATH=$PATH:$MAVEN_HOME/bin
export PATH=$GRADLE_HOME/bin:$PATH
After that I save it and set source .bash_profile command in Terminal.
When I try in Terminal input mvn -v command I see:
-bash: mvn: command not found
When I input $MAVEN_HOME I see:
: No such file or directory/Path/Maven/maven_3.3.9
If I use echo $MAVEN_HOME command I see:
/Users/{user}/Documents/Path/Maven/maven_3.3.9
If I input this mvn I see:
-bash: mvn: command not found
JDK on Mac - $JAVA_HOME command in Terminal:
-bash: /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home: is a directory
Can you help me please to understand where I missed.
Thank you very much for your answers, I fixed my problem just like that:
export PATH=/Users/{user}/Documents/Path/Maven/maven_3.3.9/bin:$PATH
After that everything worked as expected.
If you think my method is not good, please tell me why?
Since it is a maven 2+, export M2_HOME (see "What is the difference between M2_HOME and MAVEN_HOME")
And double check what echo $PATH returns after sourcing the .bashrc.
Make sure it:
includes $M2_HOME/bin
ls $M2_HOME/bin does exists.
Check this
1) Review your path, I think you are missing '$' character right before {user}
2) Review execution permission for 'maven_3.3.9/bin/mvn'
3) Make sure you are using Bash as Unix shell (and not zsh or another)
echo $SHELL
# output should look like: '/bin/bash'
4) If you are using bash then add maven's ENV variables to the file ~/.bashrc (or ~/.zshrc if you are using zsh)
5) 'source' your configuration
source ~/.bashrc
Notes
I recommend understand differences between .bashrc and .bash_profile: http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
If you want to keep your configuration on .bash_profile then just rebooting your system should be enough (to start a login shell which load .bash_profile)

ROS installation: no such file or directory

According to ros wiki, to set up environment,
I typed
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
The error is
/opt/ros/kinetic/setup.bash:.:8: no such file or directory: /home/pikashun/setup.sh
In ~/.bashrc file, there is the source /opt/ros/kinetic/setup.bash line.
I use Ubuntu on WSL.
How can I improve?
Thank you!
I had the exact same issue. The problem is not due to setup.bash either ~/.bashrc but the shell that you are using. It turned out that you may be using a different shell than bash (i.e., zsh). When you are executing the setup.bash of ROS, zsh interprets the following command (whici is in /opt/ros/kinetic/setup.bash) differently:
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
It is setting the _CATKIN_SETUP_DIR to your user directory. That is why you are getting error, cause you using the wrong path:
/home/user/setup.bash instead of /opt/ros/kinetic/setup.bash
To check whether this is the issue of your problem, you can check the shell that you are using by execute the following in the terminal:
echo $0; echo $SHELL
It may return something like:
zsh
/bin/zsh
To switch from zsh to bash, use:
exec bash
Once done this, you can use source without any problem.
And to switch back to your previous shell (assuming that is zsh), just use:
exec zsh
The file /opt/ros/kinetic/setup.bash does nothing but loading /opt/ros/kinetic/setup.sh from the same directory. I might be that you are not running bash (check which terminal you run), or that WSL has some different behavoiour than expected.
However, your can just alter your append command like so:
echo "source /opt/ros/kinetic/setup.sh" >> ~/.bashrc
or in your case, since the entry exists already in your ~/.bashrc, edit the line source /opt/ros/kinetic/setup.bash to source /opt/ros/kinetic/setup.sh
The packages or files were not actually downloaded from the "http://wiki.ros.org/melodic/Installation/Ubuntu". To overcome this error first open terminal
check your directory pwd. If your directory is like /home/'Your PC Name' it won't actually work.
Change the directory : Type cd /
Continue the installation process from start which mentioned in "http://wiki.ros.org/melodic/Installation/Ubuntu"
melodic can change to kinetic or other version if you wish

I have to type export PATH=~/anaconda/bin:"$PATH" everytime I rerun the terminal

I have installed the Anaconda for Mac, but there is something wrong with me:
when I type the commandwhich conda or which ipython, I get conda not found and ipython not find
Then I find this command export PATH=~/anaconda/bin:"$PATH" works for me. It solves the problem above, but everytime I rerun the terminal the problem is still there, I have to type it again.
so I want to find a way to solve the problem fundamentally
I have tried to add it into the ~/.bashrc, ~/.profile, ~/.bash_profile, but these don't work for me.
Try this in .bash_profile
export PATH="$HOME/anaconda/bin:$PATH"
Then try launching a new terminal and running:
echo $PATH
The output should start with /anaconda/bin:
If that still doesn't work... A work around might be to invoke bash after running terminal i.e. type "bash". Which should cause bash to launch with .bash_profile
I run on MacOs Catalina 10.15 and this did the trick for me:
shell is zsh !
$ source /Users/myprofilename/anaconda3/bin/activate
then
$ conda init zsh
the new anaconda documentation also highlights this:
Make sure you're not using ZShell or another form of a shell. If the case you'd have to add the path to your respective shell file, e.g .zshrc.
sudo xed /etc/environment
after open this archive add :/home/youruser/anaconda3/bin
If you're using ZShell follow the steps below:
In your terminal type open ~/.zshrc
Add the following to the file export PATH=/opt/homebrew/bin:$PATH
Save your file and then run the following command source ~/.zshrc
Please note that the homebrew path on Apple silicon is /opt/homebrew/bin

Mac OSX .zshrc $PATH variable ignorning local command

I'm on MacOSX Mountain Lion 10.8.2, using OhMyZsh and for some odd reason, I am not able to run a command which should trigger a script in my local directory. If I navigate via terminal to the folder containing "tidy" (http://w3c.github.com/tidy-html5/) I get an error when trying to run it:
➜ tidy test.html test.min.html
zsh: command not found: tidy
My $PATH variable looks very weird in .zshrc (I'm new to zsh, I've always used bash):
export PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Users/Keith/.rvm/bin
Does anyone know what I could do to modify my path to check the local working directory first?
Thanks a ton
The current working directory is . which doesn't appear to be in your $PATH. You can export it the same way you would in bash:
export PATH=.:$PATH
which will add . before the rest of $PATH. You'll need to either source ~/.zshrc or re-open your terminal window to apply the changes. You can check whether . is in the $PATH:
echo $PATH

Resources