CentOS7右键打开终端无法继承父Shell目录问题求助(无root权限)
Hey there, I totally get how annoying it is to lose that convenient right-click terminal shortcut that inherited your parent shell's directory after upgrading from CentOS6 to CentOS7—especially when you don't have sudo rights to install the recommended nautilus-open-terminal package. Let's go through some user-level workarounds that'll get you back that functionality:
1. Create a Custom Nautilus Script (Right-Click Option)
This lets you add your own "Open Terminal Here" option to the right-click menu without needing root access:
- First, create the required scripts directory if it doesn't exist:
mkdir -p ~/.local/share/nautilus/scripts/ - Create a new script file (name it whatever you like, e.g.,
OpenTerminalHere.sh):nano ~/.local/share/nautilus/scripts/OpenTerminalHere.sh - Paste this content into the file:
#!/bin/bash gnome-terminal --working-directory="$NAUTILUS_SCRIPT_CURRENT_URI" - Save and exit, then give the script executable permissions:
chmod +x ~/.local/share/nautilus/scripts/OpenTerminalHere.sh - Restart Nautilus to apply the changes:
nautilus -q
Now when you right-click in a directory, you'll find your new script under the Scripts submenu—click it to open a terminal in the current directory.
2. Use Terminal Shortcuts as a Quick Fix
If you don't want to mess with scripts, these shortcuts can save you time:
- If you're already in a terminal window, press
Ctrl+Shift+Tto open a new tab (or window, depending on your terminal settings) in the same directory. - If you're in the file manager, copy the current directory path from the address bar, open a terminal, and run
cd [paste-your-path-here]to jump straight there.
3. Adjust Gnome-Terminal Default Settings
Tweak your terminal's preferences to ensure it uses the current directory by default:
- Open Gnome-Terminal, go to Edit > Preferences
- Select your default profile (usually called "Default") and click Edit
- In the Command tab:
- Uncheck "Run a custom command instead of my shell"
- For "Working directory", select either "Current working directory" or "Directory of last window" (options may vary slightly by CentOS7 version)
These changes are all applied to your user account only—no root access required. They should replicate that CentOS6-era behavior you're missing.
内容的提问来源于stack exchange,提问作者builder-7000

