特定のディレクトリへのパスを設定するようにcshrcを設定します。

特定のディレクトリへのパスを設定するようにcshrcを設定します。

ディレクトリに入るたびにさまざまなパスを設定する必要があります。別のディレクトリで作業している場合は、他の場所を指す必要があるため、.cshrcファイルに設定することを躊躇します。特定のディレクトリにCDを移動するときに自分のパスが自動的に設定されるように設定する方法はありますか?

ベストアンサー1

特別なエイリアスを使用できますcwdcmd。からtcsh(1)

   cwdcmd  Runs after every change of working directory.  For example,  if
           the  user is working on an X window system using xterm(1) and a
           re-parenting window manager that supports title  bars  such  as
           twm(1) and does

               > alias cwdcmd  'echo -n "^[]2;${HOST}:$cwd ^G"'

           then the shell will change the title of the running xterm(1) to
           be the name of the host, a colon, and the full current  working
           directory.  A fancier way to do that is

               >          alias          cwdcmd          'echo          -n
               "^[]2;${HOST}:$cwd^G^[]1;${HOST}^G"'

           This will put the hostname and working directory on  the  title
           bar but only the hostname in the icon manager menu.

           Note  that  putting  a cd, pushd or popd in cwdcmd may cause an
           infinite loop.  It is the author's opinion that anyone doing so
           will get what they deserve.

私はあなたに提案します~/.tcshrc

set basepath = (/sbin /bin /usr/sbin /usr/bin)
set path = ($basepath)

alias cwdcmd source ~/.tcsh/cwdcmd.tcsh

# Do this on startup as well
cwdcmd

それから~/.tcsh/cwdcmd.tcsh

# Reset path
set path = ($basepath)

# cwd is exactly this
if ( "$cwd" == "/home/martin/code" ) then
    set path = ($path /code-path)
# cwd starts with this
else if ( "$cwd" =~ "/home/martin/tmp*" ) then
    set path = ($path /tmp-path)
endif

おすすめ記事