How do I copy a file to the clipboard in the terminal (linux) [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I would like to copy a file to the clipboard with the terminal, like when right clicking a file and selecting "copy" in the gui. Someting like "cp test.txt" (without a destination) so whenever I want, I could right click and paste the file (or files) in the gui. Thank you
No file in clipboard
What I am trying to do: (copy a file to the clipboard with the terminal). Exactly like right clicking a file and selecting copy. (test.txt already on desktop)
Now the file is in the clipboard and I can paste it anywhere
File is pasted

What you want to achieve isn't impossible, but looks like there isn't any universal solution. The only thing I managed to find was this question: Copy file from commandline, paste into Gnome window or vice-versa.
When you want to copy and move files via the X clipboard in CLI use xclip-copyfile and xclip-pastefile.
Additionally:
xclip -i -selection clipboard < ~/foo.c
This will copy the contents of file ~/foo.c into CLIPBOARD (without -selection clipboard it will copy into PRIMARY).
Tools will be different on other systems (e.g. on Windows will be copy) or if you aren't using X server.

Related

Readline does not read user config specified in INPUTRC variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I am trying to change the location of my inputrc. The docs say that it reads the config location from the INPUTRC environment variable
Readline is customized by putting commands in an initialization file (the inputrc file). The name of this file is taken from the value of the INPUTRC environment variable
I exported this variable in my ~/.bash_profile
export INPUTRC="~/.config/readline/inputrc"
and added the following lines to ~/.config/readline/inputrc
$include /etc/inputrc
# Case insensitive tab completion
set completion-ignore-case on
# Single tab partially completes and shows all options
set show-all-if-ambiguous on
# shift + arrows to go back and forth one word at a time
"\e[1;2D": backward-word
"\e[1;2C": forward-word
# Cycle through completions inline
Tab: menu-complete
"\e[Z": menu-complete-backward
Now if i try to open a new bash session, none of these options seem to have taken effect. It works as expected if I put them in ~/.inputrc with or without the INPUTRC variable exported. I've also tried exporting it from ~/.bashrc and ~/.profile, neither has worked.
I could add these lines to my bashrc using bind but that would mean that other programs that use readline wouldn't share these options.

Installed Go, but command go not found. Does work on one terminal linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I installed go on linux yesterday. It worked fine and downloaded some tools and they worked also. I left the terminal open and when I came back today go stopped working... In the left terminal go works and does everything... But when I open another terminal and type go it said "command go not found" (see screenshot).
Can anyone help me please? I don't know what I did wrong or what went wrong...
Go works on the left terminal, not right...
tl;dr
Add the export command you ran to the $HOME/.bashrc file (preferably at the end).
When you installed go you probably ran the export command to add the location of go binaries to the PATH variable. But here's the thing. The PATH variable is, effectively, reset to the previous value when you open the new terminal. To make it permanent you need to add the command to your shell's rc file.
What's an rc file?
When you open the terminal it uses a rc (short for run commands) file and runs the commands in this file. The name of the file depends on the shell you are using.
If you are using bash, the name would be .bashrc. If you are using zsh, the name would be .zshrc.
You can run echo $PATH in both the terminals and see the PATH variable in which go runs would have the location of go binaries and the other wouldn't.
So to make this permanent, add the export PATH=$PATH:{PATH_GO_BINARIES} to the rc file. And, then, whenever a new terminal is opened, the PATH variable would be updated to contain the location of go binaries.

How to change the username displayed within terminal window on Linux Mint? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am trying to change my current username on Linux Mint that shows up when I open a terminal window.
Currently:
john#myLinux
I want to change to:
gary#myLinux
I have tried:
(1) Start -> Settings -> Account Detail and altered the 'name' field.
(2) The steps mentioned here: https://askubuntu.com/questions/34074/how-do-i-change-my-username
(3) Altering the passwd file: https://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/
Option #3 seems to affect the username displaying in the terminal window but causes issues with logging in(my password becomes incorrect).
How can I successfully change the username that is displayed in my terminal window on Linux Mint OS?
This assumes you are using bash, and might not work for a different shell.
This will only change the terminal prompt text, it will not update your user account or change any other system files.
in a terminal type DEFAULT=$PS1
next type PS1='gary#\h\$ '
last of all, if you want to return to your default prompt type PS1=$DEFAULT
Note 1: Make sure to save these settings in your .bashrc file under the home directory to have changes persist across terminal sessions.
Note 2: In step 2, \h tells the bash prompt to print out the computer hostname, the \$ prints out show the (#) symbol if you're ROOT otherwise show the ($) symbol.
More information can be found here: https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/

:wq! results in E212: Can't open file for writing Press ENTER or type command to continue [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I am just trying to exit my vim file with :wq! but it gives me the error:
E212: Can't open file for writing
Press ENTER or type command to continue
I press enter or type anything and it goes back to editing the file. Is there something wrong?
I am now stuck in my text editor.
You can get more details about the error via :help E212:
For some reason the file you are writing to cannot be created or overwritten.
The reason could be that you do not have permission to write in the directory
or the file name is not valid.
If you don't need the changes any longer, just :q! and be done with it. For multiple Vim arguments, there's also :qall!.
If you do want to keep the changes, one approach is to investigate the permissions issue, e.g. in another terminal or via the file explorer, and fix the issue (e.g. via chmod / chown).
Alternatively, you can persist the changes elsewhere via :w /tmp/changes, then :quit Vim, and then resolve the problem outside of Vim.
To address the "I'm stuck in Vim" (assuming it's not possible / tedious to start another session on the system): :suspend puts Vim in the background, and drops you into the original shell you started Vim from. :shell starts a new shell from inside Vim, to which you return via exit.

Restore trash item to original location - Linux [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm wondering if it is possible to restore a file that is in the trash (~/.Trash) to its original location.
I understand there is a restore command but I don't understand its arguments or how to correctly use it.
Is this a fairly simple thing to do?
Cheers
If your desktop environment followed the XDG Trash Can Specification when trashing the file, then restore-trash from trash-cli would do the trick.
What desktop do you use?
.Trash is just a (hidden) directory. All you need to do is move it out:
mv ~/.Trash/foo ~/
or using the file browser of your desktop environment, open the trash and drag it out.
As far as I know, in the trash folder (~/.local/share/Trash/), there is a folder with the files (files/) and a folder with the file information (info/). Each file has an associated .trashinfo file in which the original path and time of deletion are stored. You can use that to restore the file to its original location.

Resources