গাম্বাই এবং এর অন্যান্য প্রস্তাবিত রূপগুলির তুলনায় আমি উত্তরের উত্তর দিয়ে অন্য কোথাও একই রকম প্রশ্নে হোঁচট খেয়েছি । এটা থেকে ভাল।
- এটি তৈরি হওয়া ফাইলটিকে টিএমপি ফোল্ডারে রেখে দেবে যাতে এটি সিস্টেমের মাধ্যমে মুছে ফেলা যায়
- এটি আরও পরিষ্কার কোড (যদিও গাম্বাইয়ের উত্তর একটি ফাংশনে রূপান্তরিত হতে পারে)
ইতিমধ্যে রেঞ্জারের গিট রেপোতে একটি শেল ফাইলে একটি ফাংশন রয়েছে:
https://github.com/ranger/ranger/blob/master/examples/bash_automatic_cd.sh
function ranger-cd {
# create a temp file and store the name
tempfile="$(mktemp -t tmp.XXXXXX)"
# run ranger and ask it to output the last path into the
# temp file
ranger --choosedir="$tempfile" "${@:-$(pwd)}"
# if the temp file exists read and the content of the temp
# file was not equal to the current path
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
# change directory to the path in the temp file
cd -- "$(cat "$tempfile")"
fi
# its not super necessary to have this line for deleting
# the temp file since Linux should handle it on the next
# boot
rm -f -- "$tempfile"
}
আপনি এই ফাংশনটি আপনার পছন্দের শেল আরসিতে (উদাহরণস্বরূপ ~/.zshrc
) ফাইলটিতে রাখতে পারেন এবং হয় উপনাম তৈরি করতে পারেন এবং / অথবা এটি একটি মূল সংমিশ্রণে আবদ্ধ করতে পারেন (আবার উভয়ই আরসি ফাইলে যেতে পারে):
alias nav=ranger-cd
এবং / অথবা
# This will run the function by Ctrl+O through returning
# the string "ranger-cd" in addition to a new-line character
# to act as Enter key-press
bindkey -s "^o" "ranger-cd\n"
দাবি পরিত্যাগী:bindkey
ZSH উপরে কাজ করে এবং আপনি আপনার পছন্দসই শেল উপর ভিত্তি করে এটি পরিবর্তন করা উচিত
;
এবং এটি দিয়ে শেষ করতে পারেন এবং তারপরে সেমি-কোলনের পরে আরও কমান্ড নির্দিষ্ট করতে পারেন যা - আমি ধরে নিচ্ছি যে আপনি যে বিন্দুতে এসে পৌঁছেছেনranger
, ধন্যবাদ!