`
fantaxy025025
  • 浏览: 1279313 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类

Setting PATH on UNIX or LINUX

阅读更多

PATH is just an Environment variable like any other in a UNIX SHELL. You almost never want to replace the default value of PATH because if you're not careful your shell will forget the location of such useful commands as LS and CP. What you almost want to do is append to PATH like this (in SH, BASH or ZSH if you use one of the CSHs you're on your own.

 > export PATH=$PATH:/your/new/directory

The usual place to add directories to your PATH such that the change is permanent is in the file that your shell executes when you login. Depending on what shell you use this'll be your ZSHRC, BASHRC, TCSHRC etc.

You can edit this file and add the above command and come back and edit the list of directories any time.

After you've edited it your shell must reread the script to pick up the changes. In ZSH this is done with the dot command like SH

 . ~/.zshrc

Or with source like CSH

 source ~/.zshrc

Note the ~/ which always points to your home directory in all shells I know of.

If you're lazy like me, you can permanently add a directory to your path from the command line like this:

 > echo 'export PATH=$PATH:/new/directory' >> ~/.zshrc
 > source ~/.zshrc

 

-------------------

ZSHRC the last file read when U login to the zsh session~

.zshrc, the last file that ZSH reads when you open an interactive session. This includes your login session and any others such as an SSH session or an XTerm session. This is almost always found in your home directory.

.zshrc is the usual place to modify your environment permanently, such as adding directories to your PATH.

For more information take a look at the Man page for ZSH

 man zsh

---------------------

The Z SHELL, a CLI program on Unix that serves as the interface between the user and the rest of the OS. See also BASH and TCSH.

Why zsh?

    * tab-completion (see ZSHCompletion)
    * An awesome prompt with fancy colors:

PS1='%{^[[01;36m%}yourname@%m] %{^[[00m%}'

RPROMPT='%{^[[01;32m%}%~%{^[[00m%}'

which looks like:

yourname@machine]                       ~/your_path

note:

    * ^[ is really the esc charachter
    * 01;36 is light cyan
    * 01;32 is light green
    * see ANSIColors

Misc info (add to ~/.zshrc)

Color Prompt - color_path %key_history)

PS1=$'%{\e[0;34m%}%B%~%b%{\e[0m%} %%%!%) '

XTerm Title - user@hostname: path

precmd () {print -Pn "\e]0;%n@%m: %~\a"}

(see man zshmisc)

    *  %n - username
    *  %m - machine name
    *  %M - full machine name
    *  %~ - path with /home/user -> ~
    *  %B - start bold
    *  %b - end bold

 

 

分享到:
评论

相关推荐

    8192CU LINUX驱动

    #define CONFIG_USE_USB_BUFFER_ALLOC_TX 1 // Trade-off: For TX path, improve stability on some platforms, but may cause performance degrade on other platforms. //#define CONFIG_USE_USB_BUFFER_ALLOC_RX ...

    linux全志R16的linux系统编译的资料_20170502_1655.7z

    全志R16平台编译linux系统V1.0.txt 2017/4/11 13:36 (编译请使用编译android的lichee的选项编译生成的.config文件,不然直接编译会报错!!!!) rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ tar...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 登陆服务器时输入 公帐号 openlab-open123 telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss 老师测评网址 http://172.16.0.198:8080/poll/ 各个 ...

    drupal 6.12

    For more information on setting file permissions, see "Modifying Linux, Unix, and Mac file permissions" (http://drupal.org/node/202483) or "Modifying Windows file permissions" ...

    Maven-The Complete Reference.pdf

    On Windows, you can use the same process as Linux/Unix systems. Extract the archive to a desired location, such as `C:\Program Files`. Set the `M2_HOME` environment variable to the extracted directory...

    apktool documentation

    Update aapt manually or use package r05-ibot via downloading Mac, Windows or Linux Remove framework file $HOME/apktool/framework/1.apk Intermediate Framework Files As you probably know, Android ...

    Python Cookbook, 2nd Edition

    Converting HTML Documents to Texton a Unix Terminal Chapter 2. Files Introduction Recipe 2.1. Reading from a File Recipe 2.2. Writing to a File Recipe 2.3. Searching and Replacing Text in a...

    tomcat-7_API_帮助文档

    Redhat Linux 9.0 users should use the following setting to avoid stability problems: export LD_ASSUME_KERNEL=2.4.1 There are some Linux bugs reported against the NIO sendfile behavior, make sure you ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    To guarantee uniqueness, they should be based on the full path in a project's source tree. For example, the file foo/src/bar/baz.h in project foo should have the following guard: #ifndef FOO_BAR_BAZ...

    python3.6.5参考手册 chm

    PEP 519: Adding a file system path protocol PEP 495: Local Time Disambiguation PEP 529: Change Windows filesystem encoding to UTF-8 PEP 528: Change Windows console encoding to UTF-8 PEP 520: ...

    spring-boot-reference.pdf

    23.8. Using the ApplicationRunner or CommandLineRunner 23.9. Application Exit 23.10. Admin Features 24. Externalized Configuration 24.1. Configuring Random Values 24.2. Accessing Command Line ...

Global site tag (gtag.js) - Google Analytics