কীভাবে সর্বদা ম্যাক টার্মিনাল (যেমন লিনাক্স টার্মিনাল) এ সম্পূর্ণ ডিরেক্টরি পথ দেখানো হবে


70

আমার উবুন্টু টার্মিনালে আমার সর্বদা বর্তমান ডিরেক্টরি সম্পূর্ণ প্রদর্শিত থাকে shown ঠিক এই রকম:

blabla @ blublu: ~ / সঙ্গীত / my_album / শাস্ত্রীয় / বিটোফেন $

তবে আমার ম্যাক (ম্যাক ওএস এক্স 10.6.5) টার্মিনালে পুরো পথটি দেখায় না এবং এটি এর মতো:

ব্লেবস-ম্যাকবুক-প্রো: ধ্রুপদী বিথোভেন $

লিনাক্স টার্মিনালের মতো কাজ করার জন্য কি আমি ম্যাক টার্মিনাল আচরণটি পরিবর্তন করেছি?


1
টার্মিনাল অ্যাপের পছন্দগুলিতে অবশ্যই একটি পর্দা থাকতে হবে। যা আপনি আচরণ পরিবর্তন করতে পারেন।

1
লিনাক্স টার্মিনালগুলি যাদুতে পুরো পথটি প্রদর্শন করে না; এটি আপনার সেটিংসের উপর নির্ভর করে। কিছু লিনাক্স ডিস্ট্রোস ডিফল্টরূপে পুরো পথটি দেখানোর জন্য জিনিসগুলি কনফিগার করে, কিছু করে না। এটি সমস্ত $ PS1 ভেরিয়েবলের উপর নির্ভর করে। (Asmus এর উত্তর দেখুন।)
অস্পষ্ট

উত্তর:


108

আপনার প্রম্পট হিসাবে বাশকে "ব্যবহারকারীর @ হোস্টনাম: পাথ / থেকে / ডিরেক্টরি return" ফেরত দিতে আপনার ~ / .bash_profile এ নিম্নলিখিত লাইনটি যুক্ত করুন:

export PS1='\u@\H:\w$'

অথবা

export PS1='\u@\H:\w$ '

যদি আপনি $ এবং কমান্ডের মধ্যে একটি স্থান থাকতে চান

পরিবর্তনগুলি অবিলম্বে কার্যকর করতে, প্রতিটি খোলা উইন্ডোতে নিম্নলিখিত কমান্ডটি চালান (বা টার্মিনাল পুনরায় চালু করুন):

source ~/.bash_profile

সম্পাদনা করুন : বাশ ( man bash) এর জন্য ম্যান পৃষ্ঠাতে "প্রম্পটিং" অনুচ্ছেদে উপলব্ধ স্ট্রিংগুলির একটি তালিকা পাওয়া যাবে :

প্ররোচনা

  When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command.  Bash allows these prompt strings  to  be  customized  by
   inserting a number of backslash-escaped special characters that are decoded as follows:
          \a     an ASCII bell character (07)
          \d     the date in "Weekday Month Date" format (e.g., "Tue May 26")
          \D{format}
                 the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation.  The braces are required
          \e     an ASCII escape character (033)
          \h     the hostname up to the first `.'
          \H     the hostname
          \j     the number of jobs currently managed by the shell
          \l     the basename of the shell's terminal device name
          \n     newline
          \r     carriage return
          \s     the name of the shell, the basename of $0 (the portion following the final slash)
          \t     the current time in 24-hour HH:MM:SS format
          \T     the current time in 12-hour HH:MM:SS format
          \@     the current time in 12-hour am/pm format
          \A     the current time in 24-hour HH:MM format
          \u     the username of the current user
          \v     the version of bash (e.g., 2.00)
          \V     the release of bash, version + patch level (e.g., 2.00.0)
          \w     the current working directory, with $HOME abbreviated with a tilde
          \W     the basename of the current working directory, with $HOME abbreviated with a tilde
          \!     the history number of this command
          \#     the command number of this command
          \$     if the effective UID is 0, a #, otherwise a $
          \nnn   the character corresponding to the octal number nnn
          \\     a backslash
          \[     begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
          \]     end a sequence of non-printing characters

1
অথবা কেবল PS1প্রতিটি খোলা উইন্ডোতে সেই কাজটি প্রবেশ করান enter যাইহোক, exportঅপ্রয়োজনীয়।
ডেনিস উইলিয়ামসন

6
আসলে, আপনি যদি রফতানি ব্যবহার না করেন, আপনার শেল ভেরিয়েবলের সংজ্ঞা দেওয়া হবে, এনভায়রনমেন্ট ভেরিয়েবল নয়, তাই PS1 সমস্ত প্রক্রিয়াতে বিশ্বব্যাপী পাস করা হবে না।
আসমুস

1
এক্সপোর্ট কম প্রস্তাবিত হিসাবে কাজ করছে এবং পুরো পথ দেখায়, তবে আমি একবার টার্মিনালটি পুনরায় চালু করলে এটি কেবল উপস্থিত ডিরেক্টরি দেখায় (সম্পূর্ণ পাথ নয়)। আমি কীভাবে এটি চিরকাল ধরে রাখতে পারি।
জিতেশডব্লিউ 25'15

1
তা ব্যাখ্যা করতে হবে তা সম্ভব হবে PS1, \u@\H:\w$মানে?
জাস

3
@ যাস আমি সেই অনুসারে আমার উত্তর আপডেট করেছি, জানিনা কেন আমি এই বছর আগে করিনি ^^
আসমাস


8

আমি আমার ম্যাকের সেন্টোস টার্মিনালের সাথে একেবারে অনুরূপ দেখতে এটি তৈরি করেছি। টার্মিনালে bash_profile খুলুন

nano ~/.bash_profile

নিম্নলিখিত যোগ করুন

# Show always fullpath on terminal
export PS1='\u@\H [\w]$ '

টার্মিনাল পুনরায় আরম্ভ করুন এবং তারপরে এটি দেখতে দেখতে এমন দেখাবে

username@host.local [/Applications/MAMP/htdocs]$ 

6

PS1 মানের ভিতরে, "\ w" পুরো পথটি উপস্থাপন করে, যেখানে "\ W" কেবলমাত্র বর্তমান ডিরেক্টরিটির নাম উপস্থাপন করে।

http://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html


আমি ম্যাকবুকের কেন '\ ডাব্লু' এবং '\ ডাব্লু' এর মধ্যে কোনও পার্থক্য দেখছি না? আমি পুরো পথটি ঘুরে দেখছি, তবে এটি দেখতে পাচ্ছি না।
দানিজেল

1

আমি কেবলমাত্র বর্তমান ফোল্ডারটি তৈরি করতে / ডাব্লু / ডাব্লু তে পরিবর্তন করি

রঙিন টার্মিনাল

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '

কোনও রঙিন টার্মিনাল নেই

    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '

আমি উবুন্টু 16.04 ব্যবহার করি এবং ফাইলটি ~ / .bashrc এ পরিবর্তন করি


0

আমি এই আদেশ ব্যবহার করেছি। এটা আমার জন্য কাজ করে.

প্রথম,

vi ~/.bash_profile

তারপরে, এই শব্দগুলিকে একটি নতুন লাইনে যুক্ত করুন।

`export PS1='\u@\H:\w$ '`

পরিশেষে,

`source ~/.bash_profile`
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.