date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,355,075,428,000
I'm currently writing a nemo action script in bash, and I need a way to get input from the user. How?, the terminal isn't showing when running an action script. is there anyway to popup a query window in the GUI to ask the user for input?
Zenity is a good tool for that. user_input=$(zenity --entry) That assigns to variable user_input whatever the user types in the GUI window, unless the user presses cancel, in which case the exit code is not zero. user_input=$(zenity --entry) if [ $? = 0 ]; then echo "User has pressed OK. The input was:" echo...
bash script - request input via gui
1,355,075,428,000
I've been trying to figure out why I get a literal end-of-transmission character (EOT, ASCII code 4) in my variable if I read Ctrl+D with read -N 1 in bash and ksh93. I'm aware of the distinction between the end-of-transmission character and the end-of-file condition, and I know what Ctrl+D does when using read withou...
It might be more helpful if the doc pointed out that there's no such thing as an ASCII EOF, that the ASCII semantics for ^D is EOT, which is what the terminal driver supplies in canonical mode: it ends the current transmission, the read. Programs interpret a 0-length read as EOF, because that's what EOF looks like on...
How to signal end-of-input to "read -N"?
1,355,075,428,000
Pasting some consecutive commands into terminal stops on commands with user input, e.g.: read VAR echo $VAR or select VAR in 1 2 3; do break; done echo $VAR echo $VAR is not getting pasted/executed. Having all commands on a single line works though: read VAR; echo $VAR But this is not preferred when having more com...
A very comfortable way is the following: Just type the following in your terminal: ( paste-your-multiline-script-here ) enter Long description: In the terminal you start with ( Optional: Press enter (only for formatting reasons) Now you can paste multiple lines e.g.: echo hello echo world Alternative: You type/paste ...
Pasting multiple commands into terminal stops at user input
1,355,075,428,000
I need two ways to terminate a part of my bash script. Either a counter reaches a predefined number, or the user manually forces the script to continue with whatever the value the counter currently has. Specifically - I'm listing USB drives. If there is 15 of them, the function that counts them exits and the script ca...
Let me start by saying, you could just inline all the stuff you have in scannew, since you're waiting anyway, unless you intend to scan again at some other point in your script. It's really the call to wc that you're concerned might take too long, which, if it does, you can just terminate it. This is a simple way to s...
Wait for a process to finish OR for the user to press a key
1,355,075,428,000
I have a script that takes an -i flag (→ $interactive) and if set, asks a yes/no-default-no question for each target, à la rm -i and others. Zsh’s read -q is designed for this exact case—it accepts a single key and sets the variable to y if the key was y or Y, otherwise setting it to n. My issue is that I’m doing the ...
Update: From the manual: read ... -s Don't echo back characters if reading from the terminal. And it works: for p in $pids; do read -qs "?Kill $p? (N/y)" >&2 echo $REPLY case $REPLY in (y) do_kill $p ;; esac done read -q also provides a return status: for p in $pids; do if read -qs "?Kill $p? (N...
zsh script prompt reading single keystroke: add newline when appropriate?
1,355,075,428,000
Slurm is workload manager. There are two kinds of modes to run job, interactive(srun) and batch mode(sbatch). When using interactive mode, one needs to leave the terminal open which may lead extra burden to the remote terminal(laptop). However, sbatch mode just submit the bash script(*.sh) and can close the remote t...
echo yes | your-program yes yes | your-program
Automatically input "yes" on the bash file [closed]
1,355,075,428,000
I want to have a line break after prompt while using the cowsay function in the prompt : read -p "$(cowsay "do you know this word?") \n" answer there are multiple answers to this problem : 1)https://stackoverflow.com/questions/4296108/how-do-i-add-a-line-break-for-read-command/4296147 2)https://stackoverflow.com/que...
Why would you use the -p option for which you'd need the bash shell? Just do: cowsay "do you know this word?" read answer In bash, the -p option is only useful in conjunction with -e (another bash extension which makes bash's read behave like zsh's vared) where bash may need to redraw the prompt on some occasions (li...
How to use linebreak in read -p command while using variables in prompt string
1,355,075,428,000
In less's line editing mode, the left and right arrow keys move the cursor backwards and forwards. I was hoping to use these together with the control key to navigate by word, as promised by man less. ^LEFTARROW [ ESC-b or ESC-LEFTARROW ] (That is, CONTROL and LEFTARROW simultaneously.) Move the ...
I managed to get this working in the end. (I contacted less's author, whose response pointed out that I was making things a little more complicated than they needed to be.) Here's the lesskey configuration file I ended up using. #! /usr/bin/env lesskey #line-edit \e[1;5D word-left \e[1;5C word-right \e[3;5~ word-delet...
Why do control-left and control-right (arrow keys) not navigate by word in `less`?
1,355,075,428,000
This is what I have. I am trying to validate 3 inputs. The first and the second inputs do not ask me to enter the correct input. What is wrong? #!/bin/bash while : do ...
Your script exits as soon as invalid input is given for the title or surname, which renders the loop useless. Use continue to re-do an iteration. However, you don't want to force the user to enter their title and surname again only because they entered an invalid ID, so you will need three input loops rather than one...
Script that validates 3 inputs
1,355,075,428,000
I am creating a bash script which creates a user and sets a password. When the command "passwd user" is run it requires the user to enter a password and stops my script. Is there any way to fulfill user input without having the user intervene? #!/bin/bash yum -y update adduser test-user passwd test-user "Password he...
Method #1 - using passwd You can do something like this via a script: echo -n "$passwd" | passwd "$uname" --stdin Where the password you want to set is $passwd and the user you want to set it for is $uname. Method #2 - using useradd You could also provide it to useradd directly: useradd -n -M -s $shell -g $group -d "...
Inputting user input automatically through bash script? [duplicate]
1,355,075,428,000
I would like the timing pause to be replaced with the equivalent of a getchar() in a GNU parallel execution: parallel -j2 --halt 2 ::: 'sleep 5m; return 1' './runMe' However the following does not work (it finishes the execution of the first job immediately): parallel -j2 --halt 2 ::: 'read -n1 kbd; return 1' '/runMe...
GNU Parallel can run interactively using -p. parallel -p echo ::: 1 2 3 You will have to answer y every time, but maybe that is good enough. Also be aware that any output will be delayed. When running 3 jobs in parallel, the output of job 1 will be printed after starting job 3.
Pausing in GNU parallel and waiting for character
1,355,075,428,000
I have numerous of log files that I have to move from a production directory into an archive directory. I need to move them by creation date. Files from January 2016 go into an archive directory labeled 2016-01, as an example. I currently do this manually by typing: $ find /creation/directory/filename -daystart -mtime...
This script should head you in the right direction. #!/bin/bash read -p "Enter number of days back to begin count > " days echo "Calculated date is " date -d 'now - '"$days"' days' find /creation/directory/filename -daystart -mtime +"$days" -exec mv "{}" /destination/directory \;
Script using user input to calculate old date
1,355,075,428,000
I am trying to direct user input file into while loop, but kept on failing when ran the script. The user input file genelist contained a list of numbers where I have been using as prefixes of my other files. Eg. 012.laln, 012.model. genelist: 012 013 025 039 109 . . . This is the script I have been testing on. #!/usr...
The errors have nothing to do with your loop. You are using read wrong: $ read -pr "genefile: " genelist bash: read: `genefile: ': not a valid identifier The -p option needs an argument, and you're giving it r as the argument if you use -pr. You need: read -p "genefile: " genelist or read -rp "genefile: " genelist ...
Read file from user input with a list of prefixes, then call file with prefixes in while loops
1,355,075,428,000
I'm building an automated bash script that will install and configure several packages on a Linux Server. I'm hoping to re-use this script on multiple servers but change some parameters accustom to the needs. So that I don't have to go through lots of code in the future making multiple changes using find and replace, ...
OK, first a few obvious issues. ${script_variables[@]} expands to the entire $script_variables array separated by a space. So your test -z "${script_variables[@]}" will always be false seeing as you define the array at the beginning of the script, so "${script_variables[@]}" will never be empty. When you want to refe...
Set variables via user input and check all variables have been set before continuing script
1,355,075,428,000
I created an update routine for my device. The update process can be started using the serial console, SSH, telnet, a webserver or a REST API. Once the update started, I want to block all user input from all sources until the update is done and the device reboots. Killing SSH, telnet, the webserver and the REST server...
I would suggest temporarily changing the init configuration so the shell isn't active for a moment. Since you mention inittab, I'll assume you're using sysvinit. With that, you can do so by changing the inittab config file, and then running init q (which causes init to reread its configuration file and update internal...
Block user input on interactive shell using "cat /dev/ttyS0"
1,355,075,428,000
I've got the following situation: I'm writing a script that will read its parameters either from a config file (if exists and parameter present) or asks the user to input said parameter if it's not present. Since I'm doing this for a handful of parameters I thought writing a function would be the way to go. However, a...
Alright, looks like I solved my own problem: function getParameter { if [ -z "$3" ]; then # User read -p to show a prompt rather than using echo for this read -p "$2`echo $'\n> '`" parameter # Print to sdterr and return 1 to indicate failure if [ -z "$parameter" ]; then ...
Bash function assign value to passed parameter
1,355,075,428,000
trying to make a basic addition function that adds the numbers entered and outputs a total. Here's my current function: function addition() { read -a arr for i in ${arr[@]} do str=$str'+'$i echo $i done echo $str } but this seems to ask for one input then outputs the above. I've...
If your script/function takes the numbers on the command line, then you don't need to read them with read (which reads from standard input). Instead: addition () { sum=0 for number do sum=$(( sum + number )) done printf 'Sum is %d\n' "$sum" } The loop could also be written more explicitly as...
loop user inputted string in script
1,355,075,428,000
I am trying to prompt the user for two pieces of information: 1) The line number in the file to be changed 2) The value to change it to. My script so far: echo "Do you wish to enter a variable to be changed?" select yn in "Yes" "No"; do case $yn in Yes) echo "Please enter a variable to be changed" re...
In awk the BEGIN block/rule is executing before the first input record is read and only once, for your script and awk to work you need to remove it since that's not required here, then awk will execute that block for every input/record reads. Also personally I use Ternary condition when I only have one action/else sta...
Replace line in text file with user input at terminal
1,355,075,428,000
I'm making a script for monitoring some user processes with Upstart but, since its for the company I work for, they asked me to do it generic...how's so? Well, the number of processes being monitored could vary, as in number as in name so I need to create it so a user can input "n" number of processes and give the she...
It looks like your array syntax is off just a bit. Also, there's no need for the index variable; you can use the += operator to append to an array. #!/bin/bash FILENAME=$1 rutaServ=() while read LINE do rutaserv+=($LINE) echo "ruta -> $LINE" done < "$FILENAME" bash v4 has a new command, mapfile (or readarray) to re...
How to create as many variables as needed from shell script(bash)?
1,355,075,428,000
I have a script that is something like #!/bin/bash echo -n "User: " read -e username echo -n "Password: " read -es password export http_proxy="http://$username:$password@localhost:40080" export https_proxy="http://$username:$password@localhost:40080" $@ unset http_proxy unset https_proxy It reads the user/pass, ex...
I don't quite get why it isn't working, it works fine for me: $ source foo.sh User: terdon Password: ~ $ ## I entered the password here, you can add an echo to clear the line $ echo "$http_proxy" http://terdon:myPass@localhost:40080 $ echo "$https_proxy" http://terdon:myPass@localhost:40080 I would use read -p in...
Source script with user input
1,355,075,428,000
The below code works fine, except for the part the STDIN takes an empty value also and goes to first selection "print "Selected Y \n";". If I use && $check ne "" ) { after /^[Y]?$/i, the issue with empty STDIN also solves. But the question is why empty value passes there? my $check = 'NULL'; while ( $check eq ...
The Perl regular expression /^[Y]?$/i matches an optional Y character case-insensitively. The ? affects the [Y] in that it allows the [Y] to match one or zero characters. This means that the whole regular expression also matches the empty string. The [Y] is identical to just Y. Had you used [Yy], it would have match...
why perl's if condition is satisfying empty string?
1,355,075,428,000
I want to automate user creation along with the rsa key generation in a shell script. But while generating the rsa key we need to give inputs for these three things. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: I want to a custom pa...
From man ssh-keygen: SYNOPSIS ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa | rsa1] [-N new_passphrase] [-C comment] [-f output_keyfile] You'll want to do something like this: ssh-keygen -t rsa -N "" -f /wherever/you/want/id_rsa If you want to silence ssh-keygen's messages, add the -...
Give default path for id_rsa in a shell script
1,355,075,428,000
I prepared an alias to start my tightvnc viewer: alias vnc='/usr/bin/xtightvncviewer MOC' It worked. It asked me for the password and ran the vnc. But it prevented to put next commands in the same terminal window so I tried to move the process to the background. When I simply add ampersand like this alias vnc='/usr/b...
How to do that depends on where the password is coming from. If it is to be interactively provided by the user then you just run /usr/bin/xtightvncviewer MOC and after having entered the password the user would put the process into the background by pressing ^Z and then typing bg %%. If the password is supposed to be...
Move alias command to the background when password is requested
1,355,075,428,000
I have a script that takes input from a user (options 1, 2, 3, etc.) to choose files to deploy to a remote server. Instead of the user running this script multiple times, I would like for them to be able to input multiple options (ex. 2,3) and as a result, those entries would add text to a variable that is then refere...
The following is an example of how to do this using arrays, and optionally taking args from the command line. If no args were provided, prompt for the artifact tags instead. I didn't end up using a case statement because it turned out that by putting all the tags into an array, it wasn't needed. #!/bin/bash # dup st...
How can I take multiple inputs from a user and convert to a string that looks up values and adds them to a variable?
1,355,075,428,000
I am using UP Board. IT has Ubilinux installed in it. I have made a browser kiosk so that it automatically logs in to the browser full screen mode but I am having an issue on reboot. Whenever I try to reboot I have to enter a password on Login screen. I want it to be removed so that it can auto logged in without any ...
I created a file named sddm.conf in /etc/ directory. I placed this in it. Now I can login without any password. [Autologin] User=up Session=LXDE
Removing login username password screen to Autologin
1,391,715,774,000
As far as I know, device driver is a part of SW that is able to communicate with a particular type of device that is attached to a computer. In case of a USB webcam, the responsible driver is UVC that supports any UVC compliant device. This means that enables OS or other computer program to access hardware functions w...
The USB video class (UVC) is a specification to which USB webcams, etc., are supposed to conform. This way, they can be used on any system which implements support for UVC compliant devices. V4L2 is the linux kernel video subsystem upon which the linux UVC implementation depends. In other words, in the kernel UVC su...
Understanding webcam 's Linux device drivers
1,391,715,774,000
I recently needed a single webcam to be shared simultaneously by 3 applications (a web browser, a videoconferencing app, and ffmpeg to save the stream). It's not possible to simply share the /dev/video* stream because as soon as one application is using it, the others cannot, and anything else will get a "device or re...
It's by design. First, let it be said that multiple processes can open the /dev/video0 device, but only one of them will be able to issue certain controls (ioctl()) until streaming starts. Those V4L2 controls define things like bitrate. After you start streaming, the kernel will not let you change them and returns EBU...
Why can multiple consumers access a *single* v4l2-loopback stream from a webcam
1,391,715,774,000
I would like to join some videoconference, but I don't own a webcam and the conference software requires one. So my question is, can I create a dummy one? I don't care what the cam will cast, I just need to appear to have one.
There is loopback device for that: https://github.com/umlaeute/v4l2loopback Just add device with modprobe and stream to it with ffmpeg or gstreamer whatever video you want, or anything else for that matter: https://github.com/umlaeute/v4l2loopback/wiki
How to create dummy webcam?
1,391,715,774,000
I have a Logitech Webcam C930e on /dev/video0. I can use this for doing video conferences (e.g. jitsi). However, the video from this webcam is too high and too broad. I would like to have a "cropped" version of /dev/video0 that does not show the seaside picture on the wall. First, I tried to set v4l2 options to achie...
Lines below create a loopback video device /dev/video5. After that ffmpeg is used to connect /dev/video0 to /dev/video5, but crop and hflip the stream on its way. sudo apt-get install v4l2loopback-dkms sudo modprobe v4l2loopback video_nr=5 ffmpeg -i /dev/video0 -f v4l2 -pix_fmt yuv420p -filter:v "hflip,crop=400:400:0...
How to create a v4l2 device that is a cropped version of a webcam?
1,391,715,774,000
For the past week I have been trying to get my Logitech c920 to act as my default webcam. Despite everything seeming to be in order, it's just not working. I have GUVCview and V4L installed. I have Gstreamer and Multimedia selector installed. In Multimedia selector, I have c920 selected as my default webcam. I get the...
Taking the approach that's outlined in this AU Q&A titled: How to disable integrated webcam and still be able to use an external one, I believe you could disable the built-in camera like so. Example (From my Thinkpad T410 Laptop running Fedora 19 now, just as an example) Step 1: Start with the lsusb output. $ lsusb B...
Trying to make my default selection for USB c920 webcam work in Gstreamer, but still opens laptop internal cam
1,391,715,774,000
We have a problem of losing about one frame every 60 seconds or so with four USB cameras hooked up to Ubuntu 20.04 with the Realtime Linux patches applied. From the user code ioctl(VIDIOC_DQBUF) call level we see that v4l2_buffer.sequence skips a buffer, but with no error reported. What makes it odd is that one camera...
Is it possible that a higher priority task or thread is interfering with your USB cameras / ports? By default on PREEMPT_RT (or when using threaded interrupts on mainline linux) all IRQ threads will be run at 50 prio with SCHED_FIFO. So unless you've set these threads/tasks of yours to a higher priority, it's very pos...
Why would USB video be dropping frames in Realtime Linux?
1,391,715,774,000
In order to build and install V4L2 module, do I have to download it, or it is already part of the kernel (and all I have to do is to choose it, in order to build it, via kernel configuration)? I 'm running Angstrom distribution [kernel 2.6.32.61]. Kernel configuration's result: --- Multimedia support *** Multime...
It is part of the vanilla linux source, and that should include 2.6.x. If you run make menuconfig and hit /, you get a search. For the 3.11 source, the V4L2 core is triggered by VIDEO_DEV which requires Device Drivers->Multimedia Support and either Device Drivers->Multimedia Support->Cameras/video grabbers or some ...
Install kernel module [V4L2]
1,391,715,774,000
Im using OBS with v4l2sink and v4l2loopback to edit my video for a remote trainig. The preview in obs looks fine, but the video has some serious color shifts in any tool I try to display the v4l2loopack I'm directing the sink to. View from OBS: View from Browser: You can see that all colors have a green shadow about...
After reinstalling everything, it works fine for me now. So I have no idea which setting I fiddled with to create this problem :/
Why are my colors separated/shifted when using obs/v4l2sink/v4l2loopback?
1,391,715,774,000
with v4l2-ctl, one can know camera-parameters with following: $ v4l2-ctl -d2 --list-ctrls brightness 0x00980900 (int) : min=0 max=255 step=1 default=128 value=128 contrast 0x00980901 (int) : min=0 max=31 step=1 default=16 value=16 gamma 0x00980910 (int) ...
Short: It's not always in ms It goes down to each firmware implementation, there is no standard. Each camera has its own way of handling the provided value, so you need to check the documentation for each device that you intend to use
How to know the V4L2 camera's exposure time in ms?
1,391,715,774,000
I have an FM radio USB dongle (Silicon chip), I have managed to stream the radio reception via icecast using the following configuration: the USB dongle is recognized by v4l2 driver and mounted at /dev/radio0 as a separate audio device Pulseaudio uses the FM radio device as a record device ices2 uses the 'alsa' modu...
Ok. The answer was easy. As you can see in the picture, PulseAudio allows different capture inputs for each recording software (in our case for each ices2 Alsa capture module). Therefore, one needs to start ices2 twice with one separate configuration file each Each ices2 should define a new alse pulse source: <i...
Multiple FM radio streams from /dev/radio* via v4l2, ices2 and icecast
1,391,715,774,000
I am using an HDMI to USB capture device that linux sets up as /dev/video0. It works like a webcam, but captures from HDMI. It works perfect using the vmlinuz-5.0.0-32-generic kernel. After updating to the vmlinuz-5.0.0-47-generic kernel, v4l2 does not set up the /dev/video device. After rebooting to the vmlinuz-5...
I have another PC with the same OS running the 5.3.0-28 kernel and the problem is resolved.
video4linux not working in new kernel (new kernel is not creating /dev/video0)
1,391,715,774,000
I'm to capturing 10 images from camera. Like so: ffmpeg -hide_banner -loglevel error -f video4linux2 -i /dev/video0 -vframes 10 -video_size 640x480 test%3d.jpg Since JPG is lossly, at I need to change the image format. Let's say tiff. Like so: ffmpeg -hide_banner -loglevel error -f video4linux2 -i /dev/video0 -vframe...
That solely depends on your source. Some cameras provide MJPEG/H.264 output, so it's hard to talk about "lossless" at all. Check ffmpeg output for more info. I'm not entirely sure about TIFF (it has some compressed lossy forms AFAIK) but BMP and PNG formats are 100% lossless. Another point to consider is that your cam...
How to make sure images captured by FFMPEG from USB is lossless?
1,391,715,774,000
I have problems with webcam and I need v4l-utils package. As per this page: https://centos.pkgs.org/7/centos-x86_64/v4l-utils-0.9.5-4.el7.x86_64.rpm.html It was availbel in CentOS 7 official repos. However for CentOS Stream 8 I cannot find it: $ sudo dnf search v4l-utils Last metadata expiration check: 13:59:10 ago o...
It was neither replaced nor deprecated. Some packages are just being "missed" from rebuilding for the newer operating system, and there's a fair amount of waiting (even forever) until there are enough requests for it to be built. Thus you may notice the package is available from a bunch of 3rd party repositories.
v4l-utils for CentOS Stream 8?
1,416,942,070,000
I have following line in /etc/fstab: UUID=E0FD-F7F5 /mnt/zeno vfat noauto,utf8,user,rw,uid=1000,gid=1000,fmask=0113,dmask=0002 0 0 The partition is freshly created by gnome-disks under the respective user, and spans the whole card. Now: Running mount /mnt/zeno as user (1000) succeeds, but right after that I find out ...
mnt-zeno.mount was created by systemd-fstab-generator. According to Jonathan de Boyne Pollard's explanation on debian-user mailing list: [systemd-fstab-generator is] a program that reads /etc/fstab at boot time and generates units that translate fstab records to the systemd way of doing things [.....] The syst...
systemd keeps unmounting a removable drive
1,416,942,070,000
Situation: I need a filesystem on thumbdrives that can be used across Windows and Linux. Problem: By default, the common FS between Windows and Linux are just exFAT and NTFS (at least in the more updated kernels) Question: In terms of performance on Linux (since my base OS is Linux), which is a better FS? Additional i...
NTFS is a Microsoft proprietary filesystem. All exFAT patents were released to the Open Invention Network and it has a fully functional in-kernel Linux driver since version 5.4 (2019).[1] exFat, also called FAT64, is a very simple filesystem, practically an extension of FAT32, due to its simplicity, it's well implemen...
exFAT vs NTFS on Linux
1,416,942,070,000
POSIX filenames may contain all characters except /, but some filesystems reserve characters like ?<>\\:*|". Using pax, I can copy files while replacing these reserved characters: $ pax -rw -s '/[?<>\\:*|\"]/_/gp' /source /target But pax lacks an --delete option like rsync and rsync cannot substitute characters. I'm ...
You can make a view of the FAT filesystem with POSIX semantics, including supporting file names with any character other than / or a null byte. POSIXovl is a relatively recent FUSE filesystem for this. mkdir backup-fat mount.posixovl -S /media/sdb1 backup-fat rsync -au /source backup-fat/target Characters in file nam...
What is the best way to synchronize files to a VFAT partition?
1,416,942,070,000
I want to mount my usb drive (kindle vfat32). When I do mount -t auto /dev/sdf1 /mnt/usb I get mount: unknown filesystem type 'vfat' I checked if the drive is recognized with sudo fdisk -l and the recognized filesystem is W95 FAT32 my kernel is 3.2.0-4-686-pae. I checked the recognized filesystem with cat /proc/f...
mount use libblkid to guess the filesystem from the device you're trying to mount, and you can see that it work from the error message it give: mount: unknown filesystem type 'vfat' but the weird thing here is that if the required filesystem is in a module that isn't yet loaded, mount try to auto-load the module usi...
vfat not recognized in debian
1,416,942,070,000
When rsyncing a directory to a freshly plugged-in external USB flash drive, via rsync -av /source/ /dest/ all files get transferred (i.e. rewritten) despite no changes in the files. Note that overwriting the files only takes place once the USB is un- and replugged. Doing the rsync command twice in a row without unplu...
Your FAT drive can store timestamps only to two second accuracy. When you unplug and replug the drive you effectively break all the file times. See the --modify-window option for a workaround: rsync -av --modify-window=1 /source/ /dest/ Secondly, you're never going to see fast backups with rsync like this, because wh...
rsync to USB flash drive always transferring all data
1,416,942,070,000
When I plug in a USB drive it is automatically mounted on /run/media/user/fslabel. This is done, I guess by some udev/dbus/thunar/nautilus/gvfs or other system, and I find this convenient and do not want to revert to manual mounting by root. However, I have a problem with the default mount options: vfat drives are m...
External media/drives mounting is handled by udisks2 on most modern distros. I don't think there's any trivial way to change the default mount options as they are hard-coded (see FSMountOptions in udiskslinuxfilesystem.c) that is, they're not configurable (at least not yet1). Your options are quite limited: unmount th...
How do I change automatic mounts of removable vfat / fat32 drives/partitions to use "noexec"?
1,416,942,070,000
Out of curiosity, is this possible nowadays? I remember some old Slackware versions did support FAT root partition but I am not sure if this is possible with modern kernels and if there are any distros offering such an option. I am interested in pure DOS FAT (without long names support), VFAT 16/32 and exFAT. PS: Don'...
OK, I tried it. First two problems from the beginning: NO support for hard and symbolic links. It means that I had to copy each file, duplicating it and wasting space. Second problem: no special file support at all. This means things like /dev/console are unavailable at boot time to init before even /dev is remounted ...
Can I install GNU/Linux on a FAT drive?
1,416,942,070,000
I was trying to move a set of 7 files to my computer, via mv g* dir. The command line moved 6 of them, and for the last file gave the following error: mv: g.tex: Argument list too long Since the other files, both those before and after it, are already moved, I tried mv g.tex dir. Same error. Moving other files wor...
E2BIG is not one of the errors that read(2) may return. It looks like a bug in the kernel. Pure speculation, but it could be down to some corruption on the file system and the macOS driver for the FAT filesystem returning that error upon encountering that corruption which eventually makes it through to the return of r...
mv `Argument list too long` for a single file
1,416,942,070,000
For some debugging purposes, I'd like to be able to manually set the dirty bit of a FAT32 partition to true. I found tons of information on how to use fsck.vfat to remove the dirty bit, but none on how to set it. It's possible, since mount does it. When a FAT32 partition (where dirty is false) is mounted, then mount s...
The dirty bit is set and cleared in the kernel, when mounting and unmounting a device; see http://lxr.free-electrons.com/source/fs/fat/inode.c?v=3.19#L578 for the implementation. There's no way currently to access this function outside the kernel, except by mounting and unmounting... To set it yourself, you'd need to ...
How to manually set the dirty bit on a FAT32 partition
1,416,942,070,000
I have created a FAT16 formatted partition on my USB stick using mkdosfs /dev/sdb1 when I plug in my stick, it appears in /dev/ as: /dev/disk/by-uuid/ABCD-1234 How can I change the UUID of the disk to something else than ABCD-1234 ? UPDATE tune2fs does not seem to work: # tune2fs /dev/sdb1 -U AAAA-1111 tune2fs 1.42....
mtools comes with an utility mlabel which might do the job. mlabel -N aaaa1111 -i /dev/sdb1 :: Apart from that you might have to resort to a hex editor. The dosfstools only lets you change the label using the fatlabel command (which mlabel does too, just without the volume id). If you're willing to re-create the file...
change FAT16 partition UUID
1,416,942,070,000
When I write ls -la the output is : tusharmakkar08-Satellite-C660 tusharmakkar08 # ls -la total 88 drwxr-x---+ 10 root root 4096 Apr 18 19:43 . drwxr-xr-x 4 root root 4096 Mar 18 17:35 .. drwxr-xr-x 4 root root 32768 Jan 1 1970 CFB1-5DDA drwxrwxrwx 2 root root 4096 Feb 23 00:09 FA38015738011473 drwxrwxrwx ...
chmod 777 CFB1-5DDA fails because CFB1-5DDA is a mount point and the mounted file system is vfat. So you are trying to write meta data to a file system which the file system does not support (i.e. cannot store). Simple as that. strace chmod 777 CFB1-5DDA shows you the kernel error. In order to change the access rights...
Unable to change permissions of file system root
1,416,942,070,000
The only way I know to set VFAT volume name under Linux is mkfs.vfat -n desired_name ..., which obviously destroys volume's contents. Is there a way to change the volume name non-destructively, as Windows does? This name is conveniently used to name the volume on auto-mount. (I'd gladly use a better FS, but all my cam...
You can use dosfslabel (from the same package as mkfs.vfat): dosfslabel /path/to/device newlabel Or mlabel from mtools: mlabel -i /path/to/device ::newlabel
Set a VFAT volume name non-destructively?
1,416,942,070,000
I have an embedded Linux device with a read-only file system. I have another partition that is used to store an archive of logs. This partition will be written to a lot. What linux partition should I use to ensure longevity and stability? I heard the ext2-ext4 file systems use a lot of reads/writes for journaling. Wha...
You could safely use ext3 with noatime option: then only actual file writes would touch your flash device in write mode. The ext3fs journal is a good thing in case of embedded system that may get lack of power suddenly. I personally run this way a few Raspberry PI's equipped with simple SD memory cards for a couple ...
Embedded device, log partition, what file system is more resilient and uses less reads/writes?
1,416,942,070,000
I have a centOS 7.5 server that does not boot up. Only boots up to rescue mode. This happened after a forced reboot of the server. I got the following error on CentOS 7.5 after checking the journalctl -p err grub2 was installed after getting the correct x86_64 file into the system, tried to mount the boot/efi, but g...
Some security hardening manuals suggest disabling the loading of unnecessary filesystem types. The examples typically include vfat among the types to be disabled. But for systems using UEFI, vfat is a necessary filesystem type: the EFI System Partition (ESP) that contains the bootloader *.efi files is typically a FAT3...
/boot/efi failed to mount due to unknown file system "vfat" : CentOS 7.5
1,416,942,070,000
I'm struggling to create a FAT-formatted a disk image that can store a file of known size. In this case, a 1 GiB file. For example: # Create a file that's 1 GiB in size. dd if=/dev/zero iflag=count_bytes of=./large-file bs=1M count=1G # Measure file size in KiB. LARGE_FILE_SIZE_KIB="$(du --summarize --block-size=1024 ...
It would seem to me you're trying to fit a file on a file system that doesn't have enough space – by design! You're basically saying "For a file that takes N kB, make a disk image exactly N kB in size". Where exactly is FAT going to store the file metadata, directory tables and volume descriptor? With FAT32, the stand...
Create FAT-formatted disk image that can fit 1G file
1,416,942,070,000
This is a further question after this one. I google for it, but most of the search results are about how to grow the partition and the file system at the same time. I think this question is simpler than that, because I the partition is already larger than the file system, but I want to grow the file system to fill the...
I just ran into this while upgrading the size of the microSD card in my phone. I had used dd to clone the existing card onto a new card. The new partition was larger, but the filesystem was still the same size as the previous microSD. To solve it I used fdisk and fatresize. Also, I should mention that I was workin...
How to increase the size of a vfat file system to exactly the size of the containing partition?
1,416,942,070,000
Troubles formatting usb-flash under GuixSD, cause it cannot find mkfs.vfat. I've installed dosfstools but util-linux installation shows some another stuff. # guix package -i dosfstools The following package will be upgraded: dosfstools 4.1 → 4.1 /gnu/store/4im5hyda53qjnkc869m0fxdi7dm5f0lg-dosfstools-4.1 nothin...
How to format to Fat 32 under GuixSD? You should use the following command: mkfs.fat -F 32 /dev/sdb The command mkfs.vfat is deprecated (old) according to the source package, (check guix package -s dosfstools to get the package source). To get the command mkfs.vfat again you should rebuild the package with the --e...
mkfs.vfat not found on GuixSD
1,416,942,070,000
$ lsblk -o+FSTYPE /dev/sdc1 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT FSTYPE sdc1 8:33 1 3.7G 0 part /mnt/bart_sdc1 vfat $ cd /mnt/bart_sdc1 $ file dvorak-walzes dvorak-walzes: directory $ ls -dl dvorak-walzes drwxrwxr-x 2 bart wheel 16384 Oct 23 14:03 dvorak-walzes $ ls -dl . drwxrwxr-x 13 bart wheel 32768 J...
The (driver for the) FAT filesystem is case insensitive, meaning dvorak-walzes is equivalent to Dvorak-walzes, which is why you get the complaint from mv that: mv: cannot move '/mnt/bart_sdc1/dvorak-walzes' to a subdirectory of itself A portion of the Linux Kernel VFAT documentation says: check=s|r|n -- Case sens...
why can I not rename directories on my walkman?
1,416,942,070,000
I am trying to get the map of empty space on any partition in a filesystem-agnostic way. To do this I create a file that uses all of the empty space, then use the 'filefrag -e' command (e2fsprogs v1.42.9) to create a map of the space (on Ubuntu 14.04 Trusty, tested with kernels 3.16.0-67 and 4.1.20-040120, dosfstools ...
I have been in touch with OGAWA Hirofumi and Theodore Ts'o and tested various kernels and e2fsprogs tags. The remaining problem is fixed in e2fsprogs v1.43-WIP from 2015 onwards. I believe this commit fixed the issue. Full testing history and test script can be found here. The moral of the story: don't bother using fi...
filefrag fibmap returning wrong physical offset for FAT
1,416,942,070,000
I found an older external hd I want to reuse for something else. I was doing an rsync of it to a NAS I run over the network but it was taking ages. So I decided to rsync to my local drive first (SSD) and do the final backup to NAS later. I ran rsync -avvz --progress /media/ubuntu/9AB4-7DB9/ubuntu/ bak. This seems to ...
The du command measures file size in blocks, not bytes. Since vfat and ext4 use completely different block sizes, a size change of 2x or even 8x would not be even slightly surprising. ext4 typically uses 4k blocks but both ext4 and vfat use a variable block size set when the disk is formatted. vfat supports logical b...
rsync from external vfat disk to local ext4 yields VASTLY different sizes [duplicate]
1,416,942,070,000
I am looking for options regarding recovering deleted files (don't recall if corrupted applied). Filesystem for the corrupted files are VFAT-formatted on a USB, though I run a Linux system (but can use Windows if necessary). The original files were created using Windows. The corrupted files I have found (so far) are i...
I suspect the comment you’re referring to is this one: See PhotoRec, it fits your requirements and is available packaged in most Linux distributions. For more advanced recovery, see also Foremost. These tools are file recovery tools, designed to retrieve deleted files; they won’t help you fix corrupted file contents...
Recovery software for corrupted files when running a linux system?
1,416,942,070,000
I'm trying to mount a VFAT file system placed on a USB key drive, so that I can manipulate the drive contents. 12:10 boffi@debian:~ $ lsblk | grep sdc sdc 8:32 1 7.5G 0 disk └─sdc1 8:33 1 7.5G 0 part 12:10 boffi@debian:~ $ grep sdc /etc/fstab /dev/sdc /home/boffi/key vfat noauto,r...
Disclaimer The following is stolen from an AskUbuntu answer that the Author kindly showed me in a comment to my question. If my answer is useful to you, please remember to thank sudodus, not me and possibly up-vote the original AskUbuntu answer. Answer As far as I have understood, you need root privileges to execute t...
Mount an USB key drive VFAT file system as user, or at least having writing rights on its contents
1,416,942,070,000
I created a new partition in Windows 10 formatted as Fat32, so that I could work with files located in one place despite being logged into my MX Linux installation or Windows 10. While logged into Windows 10, I can move files in and out of the partition no problem. While logged into MX Linux, the drive wasn't mounted,...
Best not to use FAT32 for larger partitions. Use NTFS. FAT32 has a file size limit of 4GB and you cannot then copy large files to it. It also does not have a journal so chkdsk can take longer or not be able to repair it. You cannot change permissions nor ownership on Windows formatted partitions. How you mount it is t...
Sharing a Partition Between Windows and Linux Throws Permission Errors
1,416,942,070,000
I wanted to install Arch Linux on my Raspberry Pi 3 and I found this tab[Installation] article that describes the process step-by step: Now, I've run into a problem when I tried to create the vfat fs on the first partition: My partition table: Command (m for help): p Disk /dev/mmcblk0p7: 28.4 GiB, 30438064128 bytes, ...
You are trying to install Arch inside partition 7 of your SD card. What you have done is to create two partitions inside that one partition. The fdisk utility has assumed that /dev/mmcblk0p7 is the SD Card (whereas it's actually just a partition on the SD Card) and derived the two partition names from it, /dev/mmcblk0...
mkfs.vfat can't find the first partition on my disk
1,416,942,070,000
I want to use cp to copy a file named with Chinese characters to my fat32 usb stick. This is done using a script, so using nautilus is not a solution for me. I do not want to rename the files, too. I receive an error cp: cannot create regular file '测试.pdf': Invalid argument. On Ubuntu, the cp command works perfectly. ...
I'm going to give you a few meta-answers. First up, (just for background) FAT32 handles UTF-8/UTF-16 filenames in an odd way. More than likely, it's just a mount option (covered below)... just in case it's not though I'm covering a few other options... Step 1: Check your mount options. When I tried to mount a vfat fil...
Fedora: cp: Invalid argument while coping a file named with Chinese characters to a vfat filesystem
1,416,942,070,000
In the post access resource on window'sntfs,we solve the problem ,succeded in making apache in debian access the resource on the window's ntfs filesystem,now i want to make apache in debian access the resource on the window's vfat filesystem. The disk partition sda2 is vfat format. sudo blkid |grep 995A /dev/sdb2: LA...
Here's an answer to the actual problem, which you already had in your former question and which was addressed and explained. You are misled into thinking the problem is one or two directories beyond the directory causing the error. The problem is right at /media/debian/. Stay away from /media/someuser directories such...
How to make apache in debian access the resource on the window's vfat filesystem?
1,416,942,070,000
I have now just one vfat USB stick in travelling but I still need to take backups. I get gzip: stdout: File too large because vfat's limiting files bigger than 4.3 Gb. My backup command sudo tar czf /media/masi/KINGSTON/backup_home_9.7.2016.tar.gz $HOME/ I need to split the backup to parts. Merge it later if possibl...
If you have an USB stick bigger than 4 GB and you want to put big files on it, try NTFS. (You could also use Ext[234], but you wouldn't be able to read it on Windows, while NTFS naturally works on Windows). No more worrying if your file is bigger or smaller than than 4GB. Some graphical formatting programs will sugges...
How to Tar Much With Big .tar Parts on vfat? [duplicate]
1,416,942,070,000
Considering the fact that exfat does not store ownership information of files, is it possible to mount an exfat partition in Linux with an allow_utime option that is also available for vfat? If not, is there a way to allow any process to use utime on any file in the filesystem? I found an answer to this here, but this...
It turns out that allow_utime does work with the kernel exFAT driver, but not the olf FUSE driver as far as I can tell. My real issue was that I was using FUSE to mount the filesystem. After uninstalling exfat-utils, the OS mounted the drive using the kernel driver instead of FUSE, and it was able to use allow_utime j...
Using allow_utime with exfat
1,343,388,628,000
I use vim for essentially all my editing needs, so I decided to once again try vi-mode for my shell (currently ZSH w/ oh-my-zsh on OS X), but I find myself trying (and failing) to use Ctrl-R constantly. What's the equivalent key-binding? And for future reference, how would I figure this out myself? I'm pretty sure I c...
You can run bindkey with no arguments to get a list of existing bindings, eg: # Enter vi mode chopper:~> bindkey -v # Search for history key bindings chopper:~> bindkey | fgrep history "^[OA" up-line-or-history "^[OB" down-line-or-history "^[[A" up-line-or-history "^[[B" down-line-or-history In emacs mode, the bindi...
How do I perform a reverse history search in ZSH's vi-mode?
1,343,388,628,000
When you press Ctrl+L in bash default mode the screen is cleared. But when I run set -o vi and press Ctrl+L the keystroke is printed (^L). Is there any way to keep this behavior?
Ctrl+L is also bound in vi command mode but not in insert mode. There's no default binding for clear-screen in insert mode. Readline bindings should be specified in ~/.inputrc, like so: set editing-mode vi $if mode=vi set keymap vi-command # these are for vi-command mode Control-l: clear-screen set keymap vi-insert ...
Is there any way to enable Ctrl+L to clear screen when 'set -o vi' is set?
1,343,388,628,000
This question follows directly from the answer. In this case I am specifically unable to understand the part which says: In that regard, its behaviour is closer to emacs' than with bash(readline)/ksh/zsh emacs mode, but departs from the terminal driver embedded line editor (in canonical mode), where Ctrl-W delete...
In "vi" mode you can edit/navigate on the current shell prompt like a line in the vi editor. You can look at it like a one-line text file. Analogously in "emacs" mode you can edit/navigate the current command line using (some) of Emacs' shortcuts. Example For example in vi-mode you can do something like (in bash): $ s...
What is meant by a shell is in "vi" mode or "emacs" mode?
1,343,388,628,000
I wanted to try vi mode in bash but now I would like to change it back to normal. How can I unset -o vi ?
The only two line editing interfaces currently available in bash are vi mode and emacs mode, so all you need to do is set emacs mode again. set -o emacs
How to unset set -o vi?
1,343,388,628,000
I have enabled the mode prompt indicator in my ~/.inputrc with set show-mode-in-prompt on. There is a delay of about half a second in the indicator when switching to normal mode after pressing ESC but no delay in the indicator when entering insert mode. I am aware of a similar issue experienced inside of Vim and when ...
That sounds like keyseq-timeout, which is 500 (milliseconds). You could decrease it, e.g., to 50 (milliseconds). Setting it to zero would be a bad idea (see for example Re: How does one disable completion when nothing but tabs or spaces is on the line?). Not a duplicate, but one of the answers in How do I switch to v...
Bash + urxvt: delay after ESC in Vi mode
1,343,388,628,000
How would I map jj to Esc in zsh? I'm trying to recreate a key-mapping that I have setup in vim, where I have jj mapped to ESC so that whenever I double-press j, it sends the an <Esc> to vim--allowing me to enter normal mode with greater convenience. I've already tried bindkey 'jj' ^[, and I'm about to try bindkey ...
You need -s to bind actual strings instead of widgets: bindkey -s jj '\e' Though you probably want to map jj to the vi-cmd-mode widget here: bindkey jj vi-cmd-mode (note that's for binding in insert mode, not normal/command mode)
bind key sequence to Escape, zsh
1,343,388,628,000
Is it possible to configure the vi-mode of the Z shell so that backspace can delete characters before the position where the insert action was started? Basically the behavior of vim which can be achieved by adding the following line to ~/.vimrc set backspace=start – is it possible to have this in Z shell vi-mode?
You can add this to your zsh configuration: bindkey -M viins '^?' backward-delete-char bindkey -M viins '^H' backward-delete-char Explanation: Vi-mode is just a set of preconfigured keymaps (viins, vicmd, viopp, visual) that bind certain keys to certain widgets. Some of these widgets are specifically designed to beha...
Going over start of insert action in Z shell vi-mode
1,343,388,628,000
tldr: Does anyone know how to configure what buffer is used by vi-mode bash for yanking (copying) and pasting? Long version: I have set editing-mode vi in my .inputrc, so that programs using the readline library, namely bash, use vi-like key bindings. Unrelated to this, I have set up both vim and tmux to use the syste...
After doing a bit of research it seems like bash uses an internal variable for this, and not any system buffer that is readily available. It is reffered to as the "kill ring" in the manual entries for bash and readline, and the implementation can be read on GitHub, and other places. It might be possible to hijack this...
How to configure the buffer used by vi-mode bash for yank and paste?
1,343,388,628,000
I am aware how to set ZSH's default line editor to use vi-like keybindings... bindkeys -v ...and even to default each new prompt to be in command mode instead of insert mod by default... zle-line-init() { zle -K vicmd; } zle -N zle-line-init ...and most of the time I prefer this behavior. However, it makes a few thi...
Maybe like: vicmd-accept() { prev_mode=vicmd; zle .accept-line } viins-accept() { prev_mode=viins; zle .accept-line } zle-line-init() { zle -K ${prev_mode:-viins} } zle -N viins-accept zle -N vicmd-accept zle -N zle-line-init bindkey -M viins \\r viins-accept bindkey -M vicmd \\r vicmd-accept Or even simpler: accept-...
How can I configure ZSH's vi mode to persist the state between commands?
1,343,388,628,000
I'm using zsh in vi-mode. When I go to normal mode with ESC and then back into insert mode (for example using i, a or s), the line editor kind of "protects" the part of the line in front of the char, at which I was when re-entering insert mode. I fixed it for the backspace char by rebinding it with bindkey "^?" backwa...
AFAICT, the only problematic widgets are: vi-backward-delete-char vi-kill-line vi-backward-kill-word So you could do zle -A kill-whole-line vi-kill-line zle -A backward-kill-word vi-backward-kill-word zle -A backward-delete-char vi-backward-delete-char
How can I get back into "normal" edit-mode after pressing esc in zsh (vi mode)?
1,343,388,628,000
Using bash in the default (emacs) mode I get the following behavior when I hit Esc, .. $ echo hello hello $ hello # I hit `<ESC>.` to insert this Note there is no space before the word hello that is inserted when I hit Esc, .. If I switch to vi mode and configure . I do get a leading space: $ set -o vi $ bind -m vi-...
That really looks like a bug, but actually Bash is just trying to follow the POSIX specified behavior of _, [count]_ Append a <space> after the current character position and then append the last bigword in the previous input line after the <space>. Then enter insert mode after the last character just appended. With ...
Insert the last argument in bash in vi mode without inserting a leading space
1,343,388,628,000
I'm trying to get Bash to mimic the behaviour of KornShell93 (ksh) when the shells are in Vi command line editing mode. KornShell defaults to "Vi normal mode" (a.k.a. "command" mode) and it also places the cursor at the very start of the command line when stepping backwards through the command line history. This is in...
It seems that there is no adequate way to insert an Esc in the command line. While in vi-insert most alpha/numeric keys are used. Esc is quite far away, and any chord (like Alt-j (which works)) seem more complex than desired. So, there is a way to make two keys convert to a configurable string. The workaround works by...
Make Bash's vi-mode default to "normal" Vi mode (not "insert"), and place cursor at start of line, mimicking KornShell
1,343,388,628,000
I know there is, for readline, set editing-mode vi You can put the above option in ~/.inputrc, editing-mode is documented by Readline as editing-mode (emacs) Controls whether readline begins with a set of key bindings similar to emacs or vi. editing-mode can be set to either emacs or vi. There is also, for Bash, se...
The two are identical. Doing set -o vi in an interactive bash shell calls the set builtin. The C code for the set builtin calls rl_variable_bind("editing-mode", option_name) (where option_name will be vi) which is the Readline library function that sets the command line editing mode. Setting the command line editing ...
Bash's "set -o vi" vs readline's own options?
1,343,388,628,000
Hey guys I'm trying to figure out how can I take my nth arg, from my last command, without using the !:nth. In a normal bash (emacs mode) I can do that using the follow shortcuts: <ESC>nth_arg <ESC><c-y> how can I do the same using the bash vi mode (bash -o vi) ? my relevant .bashrc lines set -o vi #BASH yank-nth-arg...
You can also use below bind key: bind -m vi-insert '".": yank-last-arg' or: bind -m vi-insert ".":insert-last-argument To get the nth arguments: bind -m vi-command '"\e-": yank-nth-arg' Now you can use <ALT>n <ALT>- to get nth argument from previous command.
How to enable yank-nth-arg using vi mode on Bash?
1,343,388,628,000
I am using zsh with bindkeys -v. Alt + . does not work as expected. It seems to repeat what is currently typed in stdin, but not entered, on the next line. This post seems to imply it does work as it does in bash, which is to grab the last argument to the last command entered. What is needed to make this work as inten...
On a terminal, Alt+char is normally the same as Esc char. (It's possible to configure some terminals differently.) In vi insert mode, Esc switches to command mode. In vi command mode, Esc does nothing. In vi command mode, . repeats the last command. The widget insert-last-word is bound to Alt+. and Alt+_ by default in...
How to use `Alt + .` in zsh with Vim bindings
1,343,388,628,000
I am new at using Tmux. I have seen that it is quite difficult to copy-paste inside Tmux. So I searched for an easier method. Some sites suggested that I should use vim mode as I am quite familiar with vim. But, vim mode copy-paste isn't working. I don't know what I am doing wrong. This is my ~/.tmux.conf file. # Impr...
Make sure to have setw -g mode-keys vi in your conf file As you can see your yanking (which is also sent to the clipboard) is using an external command: xclip. Therefore, make sure to have xclip installed or install it with this script for example. Make sure to enter copy mode with C-b [, then v to begin selection,...
Vim Mode copy-paste not working on Tmux
1,343,388,628,000
Zsh vi mode doesn't have ctrl-o behavior set by default how do I get to work like in vim ?
It's as simple as this: vi-cmd () { local REPLY # Read the next keystroke, look it up in the `vicmd` keymap and, if successful, # evalute the widget bound to it in the context of the `vicmd` keymap. zle .read-command -K vicmd && zle $REPLY -K vicmd } # Make a keyboard widget that calls the function ab...
Make one normal mode command while in insert mode in zsh's vi mode
1,343,388,628,000
I'm using vim and configured :terminal with bash and vi-mode. To do that I've configured .inputrc config from: https://vim.fandom.com/wiki/Use_vi_shortcuts_in_terminal. I've noticed that my keybindings don't cooperate with bindings in the terminal. Eg. I'm switching buffers with <TAB>. That keybinding doesn't distingu...
Vim can't really tell whether the bash shell inside its terminal is running in vi-insert mode or in vi-normal mode. In fact, it can't even tell whether it's using vi or emacs mode. Or at some moments, while you're running a command inside bash, it doesn't even make sense to talk about whether bash is in insert or norm...
Using vim mappings in normal :terminal mode
1,343,388,628,000
I just set my zsh to vi mode as I feel the word/WORD (w/b W/B) skip keybindings will help me work faster than plain ^a ^e in emacs binding mode. However, I'd like to set backspace=2 or set backspace=eol, start; I have this in my .nvimrc, and it's what I'm used to right now. Is there any way to set this variable in zsh...
Bind the backspace key to backward-delete-char instead of vi-backward-delete-char. bindkey -v '^?' backward-delete-char You may want to bind other vi-* widgets to their non-vi- variant. Run bindkey -LM viins to list the insert mode keymap in a form you can tweak and copy to your .zshrc. Alternatively, if the word mot...
Setting backspace=2 in zsh with vi bindings
1,343,388,628,000
in my current .zshrc file I have bindkey -M viins -s '^tm' '^[Iman ^[Ela ^[d$' and this doesn't work, however when I remove m from the shortcut and it is now only ^t the shortcut is working. I'd like to have it ^tm. Any ideas?
It works, but you have to be quick. You can bind sequence of characters, but the idea is to bind that to keys that send sequences of characters. For instance, when you press the Home key, many terminals send ^[[1~. The first character there is ESC which is also bound in vi insert mode. So it's important that binding s...
Is it possible to use two characters (e.g. ^tm) in insert mode in zsh for a command binding?
1,343,388,628,000
Specifically Up/Down for history navigation. What I already know I understand dash is a minimalistic, no bloat, (somewhat) strict POSIX shell. I understand the philosophy behind it, and the reason features, that have become basic in other interactive shells, are not present in dash. I've looked into the following reso...
I ran into this problem on macOS and ended up finding that the simplest option was to use rlwrap (https://github.com/hanslub42/rlwrap). In my particular case, in iTerm, I set up a profile for dash with the following command to execute it whenever I want to use the dash shell (-l is for login mode; -E is for emacs comm...
Anyway to bind keyboard to dash (Debian Almquist Shell)?
1,343,388,628,000
I've recently switched to vi-mode in my zsh and there is a feature from emacs-mode that I cannot find how to do in vi-mode. The feature is browsing history by lines starting by something I've already typed. For example if I type vi and press ↑ or ↓ then I browse through my recent commands starting with vi. Is it even ...
emacs-mode and vi-mode are only different presets of key bindings. Any widget can be bound in any mode. The widgets in question here are history-beginning-search-backward (presumably for ↑) and history-beginning-search-forward (for ↓). To bind them to the up and down keys in vicmd mode, you just need to run bindkey '^...
zsh vi mode: browse recent commands starting with
1,343,388,628,000
I like vi mode in Zsh, set with bindkey -v. Pressing escape triggers command mode as it should, but it irks me that unbound keychords trigger command mode, for example, Alt+1 and F1. Any way to stop that?
Note that your terminal sends the same ESC then 1 character sequence when you press Alt+1 as when you press Escape then 1. Here you could redefine the vi-cmd-mode widget so that if there are pending keys (characters received within $KEYTIMEOUT centiseconds after ESC and otherwise not forming a ESC-starting sequence bo...
Zsh goes into command mode on unbound key
1,343,388,628,000
for example; if [ 'readline is vi-command' ]; then echo 'normal mode' else echo 'insert mode' fi I really don't have any idea how to do this and I can't seem to find anything on the man pages either, or is it possible at all?
vi-append-eol (defaults to A) is only bound in command-mode. Therefore, by querying if it is currently bound, the current mode can be ascertained. if LC_ALL=C bind -q vi-append-eol | grep -q 'not bound'; then echo 'insert mode' else echo 'normal mode' fi LC_ALL=C is used because in other locales "not bound" will...
how to detect state of bash readline using bash script?
1,343,388,628,000
Let's say I want to bind R to redo in vicmd mode. This works. bindkey -a r redo If I change it to this, it does not work. bindkey -a rr redo I have tried different things with no success. Is this not possible? I know it should be possible to bind sequences to keys in emacs mode, but can you do the same with letters ...
In the standard vicmd mode R is already bound to vi-replace-chars. So when you define R+R to redo with bindkey -a rr redo you have two possible actions Zsh could follow when R is pressed interpret it as the command vi-replace-chars or wait for a second character and then interpret the command redo The algorithm fo...
How to bind a key sequence to a widget in vi cmd mode zsh?
1,343,388,628,000
Is there something similar to Vim's "Command Line Window" for Bash where I can see/edit/execute items from the history? In Vim when I press : and then Ctrl-F it opens the window that shows the entire command history: 7. Command-line window *cmdline-window* *cmdwin* *command-lin...
You have two alternatives. Either you can install hstr (https://github.com/dvorka/hstr) which features a suggest box with advanced search options to easily view, navigate, search, and manage your command history: Otherwise, Bash features a vi-like command line history editor. Do a set -o vi, then you can search throu...
Is there a Vim like "Command Line Window" for Bash?
1,343,388,628,000
How can I switch to Vim mode in FreeBSD shell? I echoed the value of $SHELL and it is /bin/csh however man csh opens tsch's manual page. set -o and shopts are not available as well. And /etc/inputrc (Readline) is not there too. Should I install bash or is it possible to have Vim line editing mode rather than Emacs nat...
The csh shell does not have Vi keybindings, while tcsh has. The tcsh shell is available in the FreeBSD base system (as is sh, which on FreeBSD is ash, the Almquist shell). To switch to Vi keybindings with the tcsh shell, use bindkey -v
Vim mode in FreeBSD shell?
1,343,388,628,000
I am using the following to edit the current command line in Sublime Text 2 (using a working subl alias) .zshrc set -o vi EDITOR='subl'; export EDITOR bindkey -M vicmd v edit-command-line This opens up sublime, but the window is blank. If I set the editor back to Vim, I am able to open a new vim buffer with the c...
According to the the OSX docs the EDITOR environment variable should be set to subl -w, which means "Wait for the files to be closed before returning." This behavior is undocumented but similar in Linux, where subl is generally a symlink to the sublime_text executable file, wherever you decide to install it.
Issues using sublime text to edit command line in VI mode
1,343,388,628,000
I know that I can use CTRL+ALT+J in gdb to get vim keybindings but how do I get gdb to start in vi mode by default ?
Put set editing-mode vi in a .inputrc file in your home directory. bash, gdb, and other programs using readline will be in vi--mode by default. Note that zsh does not use readline as a line editing library but zle and therefore you will need to set bindkey -v or set -o vi in your ~/.zshrc : (https://unix.stackexchange...
How to have gdb start in vi mode by default?
1,331,741,565,000
I have an application that binds CTRL+ALT+F7, but my linux machine seems to catch the keystroke. Is there a way to rebind/disable this key? A recompile of the kernel is an acceptable answer. The distributions in question are Fedora 16 and Ubuntu 11.10.
Place this in your /etc/X11/xorg.conf file to disable VT switching with Ctrl+Alt+Fn: Section "ServerFlags" Option "DontVTSwitch" "on" EndSection You will also need the following to cause events to be passed through to clients connected to the display: Section "InputClass" Identifier "keyboard defaults" Ma...
Rebinding/disabling CTRL+ALT+F# Virtual Terminal/Console Switching
1,331,741,565,000
What's the fastest way to copy/paste between a non-graphical console (<Ctrl><Alt><F...>) and an X session ? Right now : I select the text with the mouse on the console (I've installed gpm) Then I paste the text inside a temporary file And finally I switch over to the x session, open the temporary file, and copy/paste...
The "best" way to achieve that sort of thing is almost probably opinion based. The way I prefer uses the backlog of the native terminal. Knowing that the backlog of tty[N] can be accessed via /dev/vcs[N], I simply fire cat /dev/vcs[N] from my Xterm and do whatever I want with the result displayed. Of course if your Xt...
How to copy/paste between a console and an X session?
1,331,741,565,000
I have a serial console working for a centos7 guest without graphics, which I access with virsh console vm. The guest has the appropriate console=ttyS0,115200n8 kernel command line parameter for it. Is it possible to configure additional consoles, so that I can say virsh console vm --devname vc1 and get a login prompt...
I frequently use multiple "consoles" on my VMs - one for an interactive console showing the boot-up and ending with a login prompt, and another to log all of that to a text file (usually /var/lib/libvirt/consoles/<domain>.log) I don't know if you can have multiple interactive "consoles" in a VM, but you can add as man...
Multiple virsh/kvm guest consoles without graphics
1,331,741,565,000
When you are running Raspbian without graphics (GNU bash), only in bash mode, if you press ALT+F2, ALT+F3... you switch from current tty to another. How to make that if you press these shortcuts nothing happens? Not even switching, nothing. Why do I need that? I have a Raspberry without screen launching a python scrip...
As VPfB says you can find all the key mappings that switch to the console eg with dumpkeys | grep Console >/tmp/map This gives a long list of keys eg: altgr keycode 59 = Console_13 alt keycode 59 = Console_1 control alt keycode 59 = Console_1 altgr keycode 60 = Console_14 Re...
Remove shortcuts to switch virtual terminals on Linux
1,331,741,565,000
Linux has 7 virtual consoles, which correspond to 7 device files /dev/tty[n]. Is a virtual console running as a process, just like a terminal emulator? (I am not sure. It seems a virtual console is part of the kernel, and if that is correct, it can't be a process.) Is a virtual console implemented based on pseudoterm...
That is incorrect. There's a terminal emulator program built into the Linux kernel. It doesn't manifest as a running process with open file handles. Nor does it require pseudo-terminal devices. It's layered on top of the framebuffer and the input event subsystem, which it uses internal kernel interfaces to access....
Is a virtual console running as a process and implemented based on pseudoterminal?