bash

Git remote push: failed to load advapi32.dll

冷暖自知 提交于 2021-02-07 18:20:24
问题 I am new to Git and Github; and I came across a problem. There is a similiar question here (git bash failed to load advapi32.dll), but they are experiencing a different problem and there are no answers either. I have searched online and was unable to fix this. Here is the issue: I am using Git Bash to push/pull commits to Github. When I try to push my work, I get this error saying "failed to load advapi32.dll ". I do have this file in my registry. The full Git message is bellow. It is worth

How to login as another user and then log out in bash script?

北城以北 提交于 2021-02-07 18:15:51
问题 I need to write a bash script to do something as another user and then return to the initial user... Suppose I run the following as root: #!/bin/bash USER=zaraza su - "${USER}" #do some stuff as zaraza ________ #here I should logout zaraza #continue doing things as root In the console I should write "exit", but in bash is a keyword and it exits the script... Thanks in advance, 回答1: Use su -c . From the man page: su man -c catman Runs the command catman as user man. You will be asked for man's

Conditional pipelining in Bash

为君一笑 提交于 2021-02-07 18:12:41
问题 I have a filter that I want to enable optionally and I wonder how can I do this in bash in a clean way. FILTER="| sort" # also can be empty ls $FILTER | cat This code does not work because it will call ls with | and sort as parameters. How can I do this correctly? Please mind that I am trying to avoid creating if blocks in order to keep the code easy to maintain (my piping chain is considerable more complex than this example) 回答1: What you have in mind doesn't work because the variable

How to automatically hit Enter in bash script when asked?

妖精的绣舞 提交于 2021-02-07 14:50:31
问题 I know that this question is answered many times, but I still can't figure out how to do it. Maybe it's because I don't know the correct keyword to search for. Using echo -ne '\n' | enter doesn't work. My code is: #! /bin/bash #Grub-customizer sudo add-apt-repository ppa:danielrichter2007/grub-customizer echo -ne '\n' | return sudo apt-get update sudo apt-get install grub-customizer 回答1: You're supposed to pipe the \n into the command that's going to be receiving it (otherwise it won't ever

How to automatically hit Enter in bash script when asked?

ぐ巨炮叔叔 提交于 2021-02-07 14:49:27
问题 I know that this question is answered many times, but I still can't figure out how to do it. Maybe it's because I don't know the correct keyword to search for. Using echo -ne '\n' | enter doesn't work. My code is: #! /bin/bash #Grub-customizer sudo add-apt-repository ppa:danielrichter2007/grub-customizer echo -ne '\n' | return sudo apt-get update sudo apt-get install grub-customizer 回答1: You're supposed to pipe the \n into the command that's going to be receiving it (otherwise it won't ever

Cygwin wraps text back on to the same line, causing text to be overwritten

泄露秘密 提交于 2021-02-07 14:40:40
问题 I have cygwin installed on my Windows 7 box and I have been running into a problem where when I type a command it will occasionally be wrapped back onto the same line, deleting the bash prompt. Here is an example: The command in question is command "201" (4 lines from the bottom). I included the others for context. The text of the command I was typing was git commit -m "Forced LF line endings." ( Note: I am posting this with mostly git commands, but the problem occurs with any command. I have

Cygwin wraps text back on to the same line, causing text to be overwritten

余生颓废 提交于 2021-02-07 14:38:45
问题 I have cygwin installed on my Windows 7 box and I have been running into a problem where when I type a command it will occasionally be wrapped back onto the same line, deleting the bash prompt. Here is an example: The command in question is command "201" (4 lines from the bottom). I included the others for context. The text of the command I was typing was git commit -m "Forced LF line endings." ( Note: I am posting this with mostly git commands, but the problem occurs with any command. I have

AWS CodeDeploy Command Not Found

拜拜、爱过 提交于 2021-02-07 14:35:41
问题 When trying to deploy a Node.js application I'm getting an error npm: command not found in my post_install.sh AfterInstall script. What's super strange is in my BeforeInstall script I run npm install -g pm2 and it works perfectly fine without any errors. Both are being run as the ubuntu user. Why would this command work in one CodeDeploy script and fail in another? 回答1: Looks like I was able to solve this by adding the following to my script files. export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR

How to customize virtualenv shell prompt

一曲冷凌霜 提交于 2021-02-07 14:33:21
问题 How do you define a custom prompt to use when activating a Python virtual environment? I have a bash script for activating a virtualenv I use when calling specific Fabric commands. I want the shell prompt to say something like "(fab)" so I can easily distinguish it from other shells I have open. Following this example, I've tried: #!/bin/bash script_dir=`dirname $0` cd $script_dir /bin/bash -c ". .env/bin/activate; PS1='(fab) '; exec /bin/bash -i" but there's no change to the prompt. What am

Bash completion to make 'cd' command complete working directories from other running shells?

不想你离开。 提交于 2021-02-07 14:31:13
问题 I'm trying to write a bash completion that will let me complete directory names that other shells are in. For example, suppose I have another shell open in /very/long/path/name , and I'm currently in a directory that contains subdirs foo and bar . When I type cd <Tab> , I want to see: $ cd <Tab> foo/ bar/ /very/long/path/name I have this command to produce the list of potential completions: ps -Cbash -opid= | xargs pwdx | cut -d" " -f2 | sort -u | while read; do echo ${REPLY#$PWD/}; done |