Why I can use relative path and absolute path on may MacVim? - macos

I just started to learning C Language.
My system is OS X 10.10 and MacVim 7.4.383 compiled by myself because I need it support python3.
But I find if a just double cilck the MacVim.app and :open ~/Desktop/something.c, it will tell me that something.c is a new file. But I did have a file called something.c on my Desktop, and I search the reason of situation, it seem to there is something about environment variable, so I follow the guide to add this code to file:///etc/launchd.conf
setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
and restart my computer, it didn't change anything
and my /etc/bashrc is
System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\d \A \u # \H \w #\#: \$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
# Tell the terminal about the working directory at each prompt.
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL,
# including the host name to disambiguate local vs.
# remote connections. Percent-escape spaces.
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
fi
# ===== ===== ===== =====
# Custom Setting
export CLICOLOR=1
export LSCOLORS=gxfxaxdxcxegedabagacad
export HISTSIZE=250
# Setting PATH for KDE
export KDEDIRS=$KDEDIRS:$HOME/Library/Preferences/KDE:/usr/local/kde4
export PATH=/usr/local/kde4/bin:$PATH
export DYLD_LIBRARY_PATH=/usr/local/kde4/lib:$DYLD_LIBRARY_PATH
launchctl setenv DYLD_LIBRARY_PATH /usr/local/kde4/lib:$DYLD_LIBRARY_PATH
export XDG_DATA_HOME=$HOME/Library/Preferences/KDE/share
export XDG_DATA_DIRS=/usr/local/kde4/share:/usr/local/share:/usr/share
# Setting PATH for MySQL
export PATH=$PATH:/usr/local/mysql/bin/
# Setting PATH for Node.js and NPM
export PATH=$PATH:/usr/local/bin/node
export PATH=$PATH:/usr/local/bin/npm
# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
And if I used absolute path like this
:open /Users/XXX/Desktop/something.c
it will print an error
E479:Not match
E32:No file name
So, what can I do to make the MacVim work like just under linux, thank you.

:open is not used for opening a file. You need to use :edit or :e command for that.
You can just use:
:e /Users/XXX/Desktop/something.c
Also $PATH doesn't have any impact on :e command.
As per vim help:
1: Simulated command simulated-command
This command is in Vi, but Vim only simulates it:
*:o* *:op* *:open* :[range]o[pen] Works like |:visual|: end Ex mode.
{Vi: start editing in open mode}
:[range]o[pen] /pattern/ As above, additionally move the cursor to the
column where "pattern" matches in the cursor
line.
Vim does not support open mode, since it's not really useful. For
those situations where ":open" would start open mode Vim will leave Ex
mode, which allows executing the same commands, but updates the whole
screen instead of only one line.

Related

bashrc in opt/distra/bashrc changes are not reflecting permanently

I have my bashrc file in /opt/distra/bashrc and trying to add a path in LD_LIBRARY_PATH variable but the changes are not reflecting after closing the terminal and re-starting and re starting the Linux Machine.
OS : Oracle Linux 7.7
My bashrc looks like this
# User specific environment variables
export DISTRA_USER=$USER
export M2_HOME=/opt/maven/apache-maven-3.0.5
export JAVA_HOME=/usr/java/default
export BT3_HOME=/opt/distra/bt3
export LD_LIBRARY_PATH=/opt/oracle/product/18c/dbhomeXE/lib:/opt/distra/executive/current/lib:/opt/mqm/java/lib64
I am trying to add :/opt/mqm/java/lib64 to the LD_LIBRARY_PATH variable
I have to do . /opt/distra/bashrc everytime i start my machine. There must be some way that i am not aware of to make the change permanently.
What shall i do to make the changes permanent ?
Edit :
My .bashrc in home directory has the following lines:
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Source distra definitions
if [ -f /opt/distra/bashrc ]; then
. /opt/distra/bashrc
fi
My .bash_profile in home directory has the following lines:
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:$HOME/scripts
export PATH
The line "export LD_LIBRARY_PATH=/opt/oracle/product/18c/dbhomeXE/lib:/opt/distra/executive/current/lib**:/opt/mqm/java/lib64**"
looks bogus because: 1) LD_LIBRARY_PATH should contain only directory paths, not individual library archive paths; and 2) since this entry is unquoted, the shell wildcards "**" will be expanded; I don't think this is what you really want. Try:
export LD_LIBRARY_PATH='/opt/oracle/product/18c/dbhomeXE/lib:/opt/distra/executive/current/lib:/opt/mqm/java/lib64'
i.e., enclose the value in single quotes. This really isn't necessary here but the single quotes will keep you safe from directories with embedded whitespace, not that you should actually use those on a Linux box.

tput: No value for $TERM and no -T specified in Sublime Text3

When I build C++ programming in Sublime Text3, I get following lines at the beginning of any console output:
Here are the contents of my ~/.bash_profile:
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# added by Anaconda3 5.0.1 installer
export PATH="/Users/zhuliwen/anaconda3/bin:$PATH"
export CLICOLOR=1
export LSCOLORS=gxfxaxdxcxegedabagacad
# export PS1="\[\033[38;5;10m\]\u#\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tp ut sgr0)\]\[\033[38;5;220m\]\w\[$(tput sgr0)\]"
# export PS1="\[\033[38;5;10m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;220m\]\w\[$(tput sgr0)\]"
export PS1="\[\033[38;5;10m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sg r0)\]\[\033[38;5;220m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0) \]"
alias ls='ls -G'
alias grep='grep --color'
How can I do to solve this problem? Thank you
When you're building via an application like that, generally you don't have a real terminal used for the output (but as you see, you can run shell scripts). What you do to avoid the message
modify your bash profile to only execute those assignments if it is an interactive session — or if the output satisfies the shell's check for "tty", e.g.,
if [ -t 0 ]
then
export PS1="\[\033[38;5;10m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sg r0)\]\[\033[38;5;220m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0) \]"
fi
alternatively, you could set TERM to match whatever the developer claims the output "terminal" matches. Sometimes that works.

Java_HOME not found when changed shell from Bash to Zsh on OSX?

This is weird, I have set JAVA_HOME for my mac which can be found when I am using bash shell, but if I change shell, I get a message saying JAVA_HOME not set. What could be going on here?
I stumbled upon your question when trying to solve the same issue while migrating from bash to oh-my-zsh. The reason it's not there is that there is no code setting it for zsh but there was for bash. Generally theres something exporting JAVA_HOME whenever a new bash window is opened so it's always set for you. There is a good thread where this might be happening on the Unix & Linux StackExchange site.
To do the same thing in zsh, you can edit the .zshrc which is run every time zsh starts. I found a sample .zshrc which got me most of the way. The key line being:
export JAVA_HOME=`/usr/libexec/java_home`
Here is the file which I appended to the end of my existing ~/.zshrc file:
#zshrc, interactive shell settings
export ZSH=$HOME/.zsh
# emacs integration
[[ $EMACS = t ]] && unsetopt zle
# env
if [[ -e /usr/libexec/java_home ]]; then
export JAVA_HOME=`/usr/libexec/java_home`
fi
if [[ -e /usr/local/lib/node_modules ]]; then
export NODE_PATH=/usr/local/lib/node_modules
fi
# path
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
export PATH=/opt/usr/sbin:/opt/sbin:/opt/usr/bin:/opt/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH=$HOME/.cabal/bin:$PATH
export PATH=$HOME/.gem/ruby/1.8/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$HOME/.bin:$PATH
setopt null_glob
# source all files in zsh root
for include in $ZSH/*.zsh; do
source $include
done
# source all non-controlled files
for include in $ZSH/private/*.zsh; do
source $include
done
unsetopt null_glob
Then source ~/.zshrc to run in the current shell (or just start a new one) and you should be able to see that it is set with export | grep JAVA_HOME.
I also ended up running mkdir ~/.zsh to create the directory this is looking for and removing the .cabal and .gem lines as they were not needed for me.
I have just installed Mac OS Catalina Version 10.15 and found that environment variables such as JAVA_HOME and others that have been set in my .bash_profile :
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_HOME=/Users/mynziak/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export M2_HOME=/usr/local/Cellar/maven/3.6.2/libexec
export M2=${M2_HOME}/bin
export PATH=${PATH}:${M2_HOME}/bin
are not set in fact!
I saw % in terminal instead of general $ that means you are using a zsh shell instead of bash shell. With Catalina zsh is now the default shell and bash will be completely gone in the future.
oh-my-zsh shell:
https://ohmyz.sh/
So you have to setup all environment variables in .zshrc file.
I just copy-pasted every variables from .bash_profile in to .zshrc and re-opened terminal.
Files .bash_profile and .zshrc are hidden (cmd+shift+. - show hidden files in finder) but can be found in path:
/Users/mynziak/.zshrc
but use own username!
When you set JAVA_HOME in a shell, then it is active and available only for that context, and it will be gone when you close that shell.
Instead either change global environment (or) your .bashrc to include it. So that every time you start a shell, the variable will be available.
edit the .profile or .bash_profile to include the JAVA_HOME.
export JAVA_HOME=`/usr/lib....`
and also below command will return the path for java home directory.
/usr/libexec/java_home -v 1.7
where 1.7 is the version you want.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
export PATH=$JAVA_HOME/bin:$PATH
Add above 2 lines in ~/.bashrc or ~/.zshrc and reload the file using source command.

-bash: : command not found when launching the shell in Mac OSX

Lately I tried to made some changes to paths in my .bash_profile.
After I tried to validate these changes with source .bash_profile and got -bash: : command not found, I have also noticed that when I open the shell, before the execution of any command, it stands already "-bash: : command not found"...
Obviously, changes made to .bash_profile weren't taken into consideration by the system niether...
Please, help! I guess that I messed with the .bash_profile too much, have no idea how to fix it...
Contents of .bash_profile:
cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH=/Users/usrname/TreeTagger/cmd:$PATH
export PATH= /Users/usrname/TreeTagger/bin:$PATH
export UIMA_HOME= $/Users/usrname/apache-uima
export PATH=$PATH:$UIMA_HOME/bin
export HEIDELTIME_HOME='/Users/usrname/Downloads/heideltime-kit/'
export TREETAGGER_HOME='/Users/usrname/TreeTagger'
source $HEIDELTIME_HOME/metadata/setenv
Updated contents of .bash_profile:
cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH=$PATH:$UIMA_HOME/bin
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
source $HEIDELTIME_HOME/metadata/setenv
Full shell output after last quotes' correction:
Last login: Thu Jul 31 19:07:05 on ttys000
-bash: : command not found
usr:~ usrname$ cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH="$PATH:$UIMA_HOME/bin"
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
source $HEIDELTIME_HOME/metadata/setenv
usr:~ usrname$ source .bash_profile
-bash: : command not found
Edit with echo commands:
cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH="$PATH:$UIMA_HOME/bin"
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
echo before
source $HEIDELTIME_HOME/metadata/setenv
echo after
usr:~ usrname$ source .bash_profile
-bash: : command not found
usr:~ usrname$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
Edit +bash version:
echo $BASH_VERSION
3.2.51(1)-release
usr:~ usrname$ source ./.bash_profile
-bash: : command not found
Edit +after set -x was added to .bash_profile:
usr:~ usrname$ source ./.bash_profile
++ $'\016'
-bash: : command not found
++ update_terminal_cwd
++ local 'SEARCH= '
++ local REPLACE=%20
++ local PWD_URL=file://usr.local/Users/usrname
++ printf '\e]7;%s\a' file://usr.local/Users/usrname
This line:
export PATH= /Users/usrname/TreeTagger/bin:$PATH
is the problem. In a variable assignment, including an export, you can't have spaces around the =. With the added space, it sets $PATH to the empty string.
Change it to:
export PATH=/Users/usrname/TreeTagger/bin:$PATH
For safety, you should add double quotes:
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
just in case there are any special characters in the value of $PATH.
You have the same problem with UIMA_HOME.
UPDATE :
Based on later comments, you appear to have a stray control character in your .bash_profile. With set -x it's displayed as $'\016'. bash tries to treat that as a command name, and not surprisingly is unable to find it. Edit your .bash_profile and delete that character.
(The other errors needed to be corrected anyway.)

Adding directory to PATH on Mac

I'm trying to add a directory to my path, and I'm having trouble. I have a Macbook Pro running Mac OS X Lion 10.7.5. To make the changes I used the command:
open ~/.bash_profile
It opened up the profile file and it looked like this:
export PATH=${PATH}:/Users/Banderson/android-sdks/tools
export PATH=${PATH}:/Users/Banderson/android-sdks/platform-tools
#
# Your previous /Users/Banderson/.bash_profile file was backed up as /Users/Banderson/.bash_profile.macports-saved_2012-05-16_at_09:53:57
##
# MacPorts Installer addition on 2012-05-16_at_09:53:57: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# Setting PATH for JRuby 1.7.0.RC1
# The orginal version is saved in .bash_profile.jrubysave
PATH="${PATH}:/Library/Frameworks/JRuby.framework/Versions/Current/bin"
export PATH
Then I added this:
export PATH=${PATH}:/Users/Banderson/Documents/awstats-7.1/wwwroot/cgi-bin/
To make the .bash_profile look like this:
export PATH=${PATH}:/Users/Banderson/android-sdks/tools
export PATH=${PATH}:/Users/Banderson/android-sdks/platform-tools
export PATH=${PATH}:/Users/Banderson/Documents/awstats-7.1/wwwroot/cgi-bin/
#
# Your previous /Users/Banderson/.bash_profile file was backed up as /Users/Banderson/.bash_profile.macports-saved_2012-05-16_at_09:53:57
##
# MacPorts Installer addition on 2012-05-16_at_09:53:57: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# Setting PATH for JRuby 1.7.0.RC1
# The orginal version is saved in .bash_profile.jrubysave
PATH="${PATH}:/Library/Frameworks/JRuby.framework/Versions/Current/bin"
export PATH
After I added that, I saved it, then in the terminal, I executed the source ~/.bash_profile command, quit the terminal window, started a new window, and tried to launch a file from the directory I added to the path, but it didn't work. Can someone please tell me what I'm doing wrong and how I can fix it?
EDIT:
Here is what echo $PATH returns:
/Users/Banderson/.rvm/gems/jruby-1.6.8/bin:/Users/Banderson/.rvm/gems/jruby-1.6.8#global/bin:/Users/Banderson/.rvm/rubies/jruby-1.6.8/bin:/Users/Banderson/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/Banderson/android-sdks/tools:/Users/Banderson/android-sdks/platform-tools:/Users/Banderson/Documents/awstats-7.1/wwwroot/cgi-bin/:/Library/Frameworks/JRuby.framework/Versions/Current/bin
Your problem seems to be the inclusion of the rvm scripts. I guess, there your path is overwritten.

Resources