Chrome add the http:// when I copy address from addressbar, i often paste the address to console, to ping or ssh, it is possible to copy only hostname from addressbar ? How to switch off that feature in chrome and also in firefox ? I also like solution that will allow to unhide http:// in addressbar, so i can select domain without it.
8 Answers
Bit of a hack as well, however I simply click in the toolbar, press the Home key, press Space, then press Shift+End and Ctrl+C.
So basically, just add a space to the start. Most commands don't even care if you keep the space in the parameters.
- 3,679
- 311
If you want Firefox to permanently show http in the adress bar:
- go to
about:config - search for the option
browser.urlbar.trimURLs - set it to
false
I don't use Chrome, but there is this question: Make chrome put http:// in the browser
I use the following javascript snippet in Google Chrome to get the hostname and copy it to clipboard. I just tested it in Google Chrome.
You can create a bookmark int the Bookmarks Bar, name it GetHostname and paste the following javascript code into the "URL" part of the bookmark:
javascript:(function(){
function executeCopy(text) {
var input = document.createElement('textarea');
document.body.appendChild(input);
input.value = text;
input.select();
document.execCommand('Copy');
input.remove();
}
executeCopy(window.location.hostname);
})();
Warning: Total hack response…
If you highlight the left-most character of the domain name, Chrome automatically adds on the http:// because its implicit in the address. If you highlight and copy all but the first character, you don't get that issue (and need to re-add it in the command).
However as hacks go, I find it easier to do the above (highlight, Ctrl+C, terminal, type first char, Ctrl+V) than to remove the http:// myself.
Others may have better solutions.
- 58,727
- 1,267
- 7
- 12
This is pretty awful that chrome needs it, but you can use this addon to copy the host by clicking a button: http://chrisiona.com/post/122938597943/hostcopy-google-chrome-extension
- 1,193
Where is the answer? The suggestion with Home button doesn't work anymore.
While reading all not working answers (I don't need host? for what? if people copy url, they need full url..:), I made my own solution. Just click to address bar, then hold "Ctrl+Shift", then click "Right" and "Left", Voila. Then you can "Ctrl"+"C"...
- 41
While I am not sure you can force Google Chrome to stop prepending protocol when copying addresses from your addressbar, it seems that it is quite straightforward to actually force the browser to display that trimmed portion of the URL in the address bar, making it possible to copy just the domain or IP in question, without protocol being prepended. To do that, you need to right-click the address bar and enable the "Always Show Full URLs" option.
- 434
Chrome 83 will be adding the flag chrome://flags/#omnibox-context-menu-show-full-urls
- Go to
chrome://flags/#omnibox-context-menu-show-full-urls.- Click the drop-down menu on the right side of the flag to select 'Enabled'
- Restart the web browser.
Sources:
- 642