CD를 푸시로 앨리어싱-좋은 생각입니까? 사용하는 것이 좋습니다. cd() {

다음 별칭을 사용하는 것이 좋습니다.

cd() {
    pushd $1;
}

bash에서?

나는 이것이 한 번 popd대신 일련의 s 를 사용할 수 있기 때문에 이것이 매우 유용 할 것이라고 생각합니다 cd -.

이것이 문제가 될 수있는 경우가 있습니까?



답변

개인적으로, 나는 이것을 내 bashrc에 가지고 있으며 항상 사용합니다 :

pushd()
{
  if [ $# -eq 0 ]; then
    DIR="${HOME}"
  else
    DIR="$1"
  fi

  builtin pushd "${DIR}" > /dev/null
  echo -n "DIRSTACK: "
  dirs
}

pushd_builtin()
{
  builtin pushd > /dev/null
  echo -n "DIRSTACK: "
  dirs
}

popd()
{
  builtin popd > /dev/null
  echo -n "DIRSTACK: "
  dirs
}

alias cd='pushd'
alias back='popd'
alias flip='pushd_builtin'

그런 다음 명령 줄에서 브라우저처럼 약간 탐색 할 수 있습니다. cd디렉토리를 변경합니다. back이전 디렉토리로 이동합니다 cd. 그리고 flip디렉토리 스택에서 그들을 터지는없이 현재 및 이전 디렉토리 사이를 이동합니다. 전반적으로 훌륭하게 작동합니다.

내가 아는 유일한 문제는 내가 완전히 익숙하지만 다른 사람의 컴퓨터에는 존재하지 않는 일련의 명령이라는 사실입니다. 따라서 다른 사람의 컴퓨터를 사용해야하는 경우 약간 실망 스러울 수 있습니다. 당신은 그냥 사용하는 데 사용하는 경우 pushdpopd직접, 당신은 문제가 없습니다. 그냥 별명이 있다면 반면 cd되지 넣어 popd, 당신은 문제가 없습니다 back존재하지를, 당신은 여전히 문제가 있습니다 cd매우 다른 시스템에서 기대하는 일을하지 않습니다.

나는 당신의 특정 구현은, 그러나,주의 할 cd확실히처럼 작동하지 않는 cd정상적인 점에서 cd그 자체로는 홈 디렉토리로 이동합니다,하지만 당신은하지 않습니다. 내가 가지고있는 버전에는 그 문제가 없습니다. 광산은 또한 인쇄물 DIRSTACK의 앞면에 추가 dirs하지만 그것은 무엇보다도 개인적인 취향의 문제입니다.

그래서 내가 말했듯이, 나는이 별칭을 항상 사용하고 아무런 문제가 없습니다. 다른 기계를 사용하고 거기에없는 기계를 찾는 것이 약간 실망 스러울 수 있습니다. , 예전처럼 작동하지 않는 것은 여전히 ​​놀라운 일입니다.)


답변

이것은 질문에 대한 직접적인 대답은 아니지만 4DOS의 디렉토리 기록 창에 빠져 들었습니다. 리눅스와 Cygwin을위한 나만의 버전을 작성했습니다. 나는 설치하기 쉬운 유틸리티를 만들려고 한 적이 없지만 Bash 프롬프트를 잘 알고 있다면 실행하기 어렵지 않아야합니다 . 귀하의 질문에 따라 Git 리포지토리에 넣고 GitHub : dirhistory에 업로드했습니다 .

기본적으로 모든 쉘에서 디렉토리 변경 사항을 수집하는 데몬이며 기록을 표시하고 전환 할 디렉토리를 선택할 수있는 Cdk 프로그램입니다 (따라서 스택에만 국한되지 않음). 나는 그것이 정말로 유용하다는 것을 알았고 4DOS와 마찬가지로 Ctrl-PageUp에 바인딩되었습니다. (Puty를 패치하여 Ctrl-PageUp을 Bash로 보냈습니다.)


답변

나를 위해 밀어 / 팝 / 디렉토리는 도움이되지만 부족합니다. 그래서 나는 ‘navd’라고 불리는 이들 주위에 ‘래퍼’를 만들었습니다. 본질적으로 20 개의 별칭 세트로 구현되었습니다. (그중 하나는 실제로 함수입니다.) 코드는 아래에 있지만 여기에 간단한 설명이 있습니다. ( “navd”와 다른 사람들의 머신에서 작업하는 것에 대한 좋은 점 : “no-install”형태로 실행하는 방법이 있습니다. 하나의 설치 옵션으로 bash-prompt에서 “navd”를 구현하는 명령을 간단히 붙여 넣을 수 있습니다. 해당 시스템의 bash-session 기간 동안 navd가 작동합니다. 그러면 파일 시스템에서 풋 프린트가 전혀 발생하지 않지만 임시 설치입니다. “실제”설치를 위해 .bashrc에 해당 명령을 넣습니다. 코스.)

풍모:

navd <path>;   -- will make that path the current dir AND will add it to the stack
                         AS A BONUS: If a relative path is used, this command is added to history
                         with an absolute path instead. This improves navigation even when only
                         using history ... because very often relative-path commands in history
                         are useless if the command changes the current directory. (After all, you
                         would have to be in the directory the command was originally issued
                         from in order for such a command to work correctly.)
navd           -- shows the stack, with index numbers for convenience
navd0          -- makes the first entry on the stack (read left-to-right) **the current dir**
navd1          -- makes the second entry on the stack (read left-to-right) **the current dir**
.
.
.
navd9          -- makes the tenth entry on the stack (read left-to-right) **the current dir**
navd-1         -- makes the first entry on the stack WHEN READ RIGHT-to-LEFT(!) **the current dir**
.                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
navd-9         -- makes the 9th entry on the stack WHEN READ RIGHT-to-LEFT(!) **the current dir**

navd <N> 명령 중 19 개가 스택을 회전하여 현재 디렉토리가되는 디렉토리 스택의 맨 앞에 표시됩니다. 양의 <N> 값은 왼쪽에서 dir counting을 찾고 인덱싱은 0에서 시작합니다. 음의 <N> 값은 RIGHT에서 계산하고 -1에서 시작하는 dir을 찾습니다. (이는 Java 및 기타 언어에서 배열 색인을 사용하는 방법에 대한 규칙을 따릅니다.)

참고 : “navd”명령은 “pushd”및 “dirs”가 사용하는 것과 동일한 스택을 표시하지만 “dirs”가 표시하는 가장 왼쪽 항목 없이
표시합니다 (항목이 실제로 스택에 없기 때문에- 현재 디렉토리
“DIRS”와 함께 가장 왼쪽 항목의 변경에 CD 명령을 입력 한 경우). ( “cd <path>”명령은 푸시 / 디렉토리 / popd 의 동작영향 을 주지만 navd 의 동작에는 영향을 미치지 않습니다 . 또한 … “cd-“를 사용하여 “back”으로 한 번 돌아가는 것을 좋아 합니다. 방금 이동 한 디렉토리이며 “cd-“는 navd의 동작에도 영향을 미치지 않습니다.)

보너스 : 스택을 회전시키지 않고 스택에 표시된 위치로 dir을 변경하는 19 개의 별칭이 더있을 수 있습니다.

 nav0 ... nav9   and   nav-1  ... nav-9

두 번째 보너스 : “navh”는 cut-n-paste로 스택을 쉽게로드하기 위해 기록에서 navd <path> 명령을 보여줍니다. (이력에 여러 번 있어도 각 목록은 한 번만 나열되고 목록이 정렬됩니다. 또한 항목을 $ HOME / .navhignore 파일에 넣어 정확한 항목이 탐색 목록에 나타나지 않도록 할 수 있습니다.)

 navh

세 가지 주요 행동 :

  1. 스택을 지우고 특정 “navd <path>”명령을 반복하면 해당 경로가 스택으로 이동합니다. 그것이 내가 원하고 기대하는 것입니다 …하지만 푸시하지 않습니다-스택에서 멀리 떨어져있는 현재 디렉토리를 넣습니다. 따라서 명령을 반복 할 때 스택에 미치는 영향은 가변적입니다 (예기치 않은 느낌). .

  2. “navd <path>”는 스택에 동일한 경로를 두 번 배치하지 않습니다.

  3. “navd <path>”는 명령 에 상대 경로를 입력 한 경우에도 절대 경로를 사용하여 명령 내역에 자신 을 저장합니다.

저에게있어, 설명 된 마지막 세 가지 동작은 히스토리의 “navd <path>”명령을 사용하여 히스토리의 “pushd <path>”를 사용하는 것보다 훨씬 유용합니다. 정말 할 수 장소를 갈 역사를 재사용. 그리고 그렇게 할 때 나는 스택을 “손상”하지 않습니다.

당신이 할 수 있고 뇌를 감싸고 싶다면 navd와 pushd / dirs / popd 사이를 전환 할 수 있습니다. 둘 다 동일한 스택을 사용합니다. 다른 스타일로. 예를 들어, “navd”스택에서 항목을 제거하려면 “popd”를 사용하고 navd 스택을 지우려면 “dirs -c”를 사용하십시오.

pushd / dirs / popd는 “내 단계를 어떻게 다시 추적합니까?”로 생각하십시오.

navd를 “내가 좋아하는 디렉토리 세트를 유지하고 쉽게 전환 할 수있는 방법”으로 생각하십시오.

다음을 터미널 창에 붙여 넣으면 해당 터미널 세션 동안 즉시 navd를 사용할 수 있습니다. 이것이이 기능에 대한 모든 코드입니다.

# Add 1 function and many related aliases for something like "pushd", called "navd". http://unix.stackexchange.com/a/229161
# Think of pushd/dirs/popd as "how do I retrace my steps?".
# Think of navd as "how do I hold on to a set of favorite directories, and easily switch between them?".
# Pseudo-code to explain each part of the "navd" bash function just below:
#              If no arguments to the 'navd' command:
#                  If stack has entries, then print the stack one-line-per-dir with each line numbered.
#                  Else, if stack is empty, automatically run the equivalent of the navh command.
#              Else (there **are** arguments to the 'navd' command):
#                  If arg is '--help' or '/?' then show help.
#                  Else    (arg is assumed to be a path to a directory)
#                      Remember the directory we are starting at
#                      Change to dir given as argument (the "arg-dir"), and do a few chores:
#                      Do not use arg-dir literally ... instead, magically put the **absolute** path we arrived at into history.
#                      Set a flag if the arg-dir is already in the stack.
#                      If the flag is set then just show the stack (on one line), else ADD to stack, ROTATE to end-of-stack, and show the stack.
#                      Change to dir we started at and then back to the arg-dir. This allows "cd -" to go back to dir we started at.
#                  End-If
#              End-If
navd () {
    if [[ $1 == '' ]]; then                             #--no arguments to the 'navd' command
        if dirs +1 >/dev/null 2>&1; then                #------stack has entries
            dirs -p | perl -ne 'print (-1+$cn++); print "$_"' | grep -v "^-1";
        else                                            #------stack is empty
            echo "The navd stack is empty. Now running 'navh' in case that's helpful. navd --help works."
            if [[ ! -f $HOME/.navhignore ]]; then echo -n ''>>$HOME/.navhignore;fi;diff --new-line-format="" --unchanged-line-format="" <(history | perl -ne "if (m/^\s*\d+\s+navd [\"~.\/]/) {s/^\s*\d+\s+/  /;s/\/$//;print}" | sort -u) <(cat $HOME/.navhignore | sort -u);echo "cat $HOME/.navhignore # (Has "`grep -c . <(sort -u $HOME/.navhignore)`" unique lines.)"
        fi
    else                                                #--(there **are** arguments to the 'navd' command)
        if [[ $1 == '--help' || $1 == '/?' ]]; then     #------arg is '--help' or '/?'
            echo "The 'navd' functionality is nothing but one bash function and a set of aliases."
            echo "It offers a different style of handy directory navigation than pushd/popd."
            echo "It uses the same 'stack' as pushd. Look in the .bashrc file for details."
            echo "    (Think of pushd/dirs/popd as 'how do I retrace my steps?'."
            echo "     Think of navd as 'how do I remember a set of favorite directories,"
            echo "     and easily switch between them?'.)"
            echo "As of 10/2015, this link has more info: http://unix.stackexchange.com/a/229161"
            echo "Here is the set of navd-related aliases. None need any parameter:"
            alias | grep 'alias nav' | cut -d= -f1 | grep -v '-' | grep -v 'navh'
            alias | grep 'alias nav' | cut -d= -f1 | grep '-'
            echo "alias navh  # The 'navh' alias has nothing to display until a 'navd <path>' is run. Short for nav-history."
            echo "---- To get started, simpy type navd followed by your favorite path. ----"
            echo "---- navd with no param shows stack. nav0 navigates to first on stack. ----"
        else                                            #------(arg is assumed to be a path to a directory)
            mypwd="$PWD"
            cd "$1" >/dev/null;
            history -s `echo "$PWD" | perl -pe 's/$ENV{'HOME'}/~/;s/ /\\\\ /g;s/^/navd /'`
            myflag=`dirs -p | perl -pe 's/\n/:/' | perl -ne '@a=split(":");$pwd=shift(@a);$flag=0;foreach (@a) {if ($_ eq $pwd) {$flag=1}};print $flag'`
            if [[ $myflag == 1 ]]; then dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"; else pushd .>/dev/null; pushd +1>/dev/null; dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"; fi
            cd "$mypwd"; cd "`dirs -l -0`"
        fi
    fi
};
# Aliases for navigating and rotating the "pushd" stack in the style of "navd":
alias navd0='cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"' # "-l" is dash-L, and expands "~" to denote the home dir. Needed inside back-ticks.
alias navd1='cd "`dirs -l +1`";pushd -n +1;cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd2='myd=$PWD;cd "`dirs -l +1`";for i in {1..2};do pushd -n +1>/dev/null;cd "`dirs -l +1`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd3='myd=$PWD;cd "`dirs -l +1`";for i in {1..3};do pushd -n +1>/dev/null;cd "`dirs -l +1`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd4='myd=$PWD;cd "`dirs -l +1`";for i in {1..4};do pushd -n +1>/dev/null;cd "`dirs -l +1`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd5='myd=$PWD;cd "`dirs -l +1`";for i in {1..5};do pushd -n +1>/dev/null;cd "`dirs -l +1`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd6='myd=$PWD;cd "`dirs -l +1`";for i in {1..6};do pushd -n +1>/dev/null;cd "`dirs -l +1`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd7='myd=$PWD;cd "`dirs -l +1`";for i in {1..7};do pushd -n +1>/dev/null;cd "`dirs -l +1`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd8='myd=$PWD;cd "`dirs -l +1`";for i in {1..8};do pushd -n +1>/dev/null;cd "`dirs -l +1`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd9='myd=$PWD;cd "`dirs -l +1`";for i in {1..9};do pushd -n +1>/dev/null;cd "`dirs -l +1`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-1='cd "`dirs -l -0`";pushd -n -0>/dev/null; dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-2='myd=$PWD;cd "`dirs -l -0`";pushd -n -0>/dev/null;cd "`dirs -l -0`";pushd -n -0>/dev/null;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-3='myd=$PWD;cd "`dirs -l -0`";for i in {1..3};do pushd -n -0>/dev/null;cd "`dirs -l -0`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-4='myd=$PWD;cd "`dirs -l -0`";for i in {1..4};do pushd -n -0>/dev/null;cd "`dirs -l -0`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-5='myd=$PWD;cd "`dirs -l -0`";for i in {1..5};do pushd -n -0>/dev/null;cd "`dirs -l -0`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-6='myd=$PWD;cd "`dirs -l -0`";for i in {1..6};do pushd -n -0>/dev/null;cd "`dirs -l -0`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-7='myd=$PWD;cd "`dirs -l -0`";for i in {1..7};do pushd -n -0>/dev/null;cd "`dirs -l -0`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-8='myd=$PWD;cd "`dirs -l -0`";for i in {1..8};do pushd -n -0>/dev/null;cd "`dirs -l -0`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias navd-9='myd=$PWD;cd "`dirs -l -0`";for i in {1..9};do pushd -n -0>/dev/null;cd "`dirs -l -0`";done;cd "$myd";cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
# BONUS commands (beyond the 20). Aliases for navigating but NOT rotating the "navd" stack:
#      Help in remembering: "navd<#>" does more since it both changes the PWD and rotates the stack, whereas "nav<#>" does less
#            (and has one letter less) since "nav<#>" only changes the PWD. Also "navd<#>" acts like the pushd-related command: dirs
#      There is no "nav" command (with no number) so that there will be no conflict if any program called "nav" is used.
alias nav0='cd "`dirs -l +1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav1='cd "`dirs -l +2`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav2='cd "`dirs -l +3`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav3='cd "`dirs -l +4`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav4='cd "`dirs -l +5`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav5='cd "`dirs -l +6`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav6='cd "`dirs -l +7`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav7='cd "`dirs -l +8`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav8='cd "`dirs -l +9`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav9='cd "`dirs -l +10`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-1='cd "`dirs -l -0`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-2='cd "`dirs -l -1`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-3='cd "`dirs -l -2`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-4='cd "`dirs -l -3`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-5='cd "`dirs -l -4`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-6='cd "`dirs -l -5`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-7='cd "`dirs -l -6`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-8='cd "`dirs -l -7`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
alias nav-9='cd "`dirs -l -8`";dirs -p | perl -ne "chomp;s/$/ /;print unless ++\$cn==1"'
# BONUS command (beyond the 20). Alias for showing 'history' of all navd commands that add to the stack.
#                Can be used in a new terminal session to quickly add recently used dirs to the navd stack.
alias navh='if [[ ! -f $HOME/.navhignore ]]; then echo -n ''>>$HOME/.navhignore;fi;diff --new-line-format="" --unchanged-line-format="" <(history | perl -ne "if (m/^\s*\d+\s+navd [\"~.\/]/) {s/^\s*\d+\s+/  /;s/\/$//;print}" | sort -u) <(cat $HOME/.navhignore | sort -u);echo "cat $HOME/.navhignore # (Has "`grep -c . <(sort -u $HOME/.navhignore)`" unique lines.)"'
# Note: When 'navd <relative-path>' is used, then by bash-magic the navd command puts 'navd <absolute-path>' into history,
#       instead. This allows the output of "navh" to be useful regardless of the directory that is current when it is run.
#
# BONUS commands (beyond the 20). An even shorter alias for navd. An even shorter alias for navh.
alias nd='navd'
alias nh='if [[ ! -f $HOME/.navhignore ]]; then echo -n "">>$HOME/.navhignore;fi;diff --new-line-format="" --unchanged-line-format="" <(history | perl -ne "if (m/^\s*\d+\s+navd [\"~.\/]/) {s/^\s*\d+\s+/  /;s/\/$//;print}" | sort -u) <(cat $HOME/.navhignore | sort -u);echo "cat $HOME/.navhignore # (Has "`grep -c . <(sort -u $HOME/.navhignore)`" unique lines.)"'

이 별명은 “bash”명령을 기반으로합니다. “cd-“의 정상적인 동작을 유지하기 위해 특별한주의를 기울입니다. (푸시 또는 navd를 사용하지 않고 “cd-“를 사용하는 경우가 많습니다. “cd-“는 마지막 “장소”로 돌아가거나 두 곳만 전환하는 데 매우 유용하기 때문에 설치하지 않고 어디에서나 작동합니다.)

물론 이러한 명령은보다 영구적 인 설치를 위해 .bashrc 파일에 넣을 수 있습니다.


답변

여기 또 다른 솔루션이 있습니다. @cjm의 솔루션으로 재생 한 후에 이것을 썼습니다. 대화 상자 명령을 사용하여 dirs 출력에서 ​​ncurses 유형 메뉴를 만듭니다. 항목을 선택하면 해당 디렉토리가 스택의 맨 위로 이동하여 CD로 들어갑니다. 이것은 각 터미널 에뮬레이터에 디렉토리 히스토리의 자체 버퍼를 제공하고 설치가 조금 더 쉽다는 장점이 있습니다.

설치하기 : 일단 CD를 푸시하려면, 대화 상자를 설치 한 다음 bashrc에이 함수를 넣으십시오.

dirmenu(){
    dirIter=$(dialog --backtitle 'dirmenu' --clear --cancel-label "Exit" --menu "Please select:" 0 0 0 $(dirs) 3>&2 2>&1 1>&3)
    cmd="builtin cd ~$dirIter"
    eval $cmd
}

dirs -v를 실행 한 다음 다른 명령을 실행하여 원하는 디렉토리로 팝 또는 CD를 실행하는 것보다 조금 더 좋습니다. 대화 상자 메뉴는 dialogrc를 통해 고도로 사용자 정의 할 수 있습니다.

따라서 귀하의 질문에 대답하기 위해, CD로 푸시 된 앨리어싱은 좋은 생각이라고 생각합니다. 최소한 업데이트를 위해 시스템을 정기적으로 재부팅하는 경우 버퍼 오버 플로우 문제가 발생하지 않을 수 있습니다. 스크립팅 할 때 cd를 사용하는 데주의해야합니다. while 루프에서 cd하면 잠재적으로 버퍼 오버 플로우 문제가 발생할 수 있습니다. dirs / pushd 버퍼 크기를 제어하는 ​​것이 확실하지 않습니다.


답변