Questions tagged [bashrc]

bashrc is one of the scripts the Bash shell reads as `.bashrc` and executes when started as an interactive (but not login) shell.

Filter by
Sorted by
Tagged with
0 votes
2 answers
2k views

how to get bash and zsh setup correctly on macOS mojave

I'm running macOS (Mojave.) I'm wanting to make the switch from default bash to zsh/oh-my-zsh. Everything I install assumes I'm going to be editing my .bash_profile (or .bashrc.) I'm not 100% on how ...
user7314150's user avatar
0 votes
1 answer
194 views

Use output text from a command as filename

curl http://v6.ipv6-test.com/api/myip.php returns me my current IPv6 addr. I'd like to use this string as part of a filename to be created, followed by timestamp of when the script ran. Any idea how ...
Hikari's user avatar
  • 307
3 votes
3 answers
3k views

How to show git status and conda environment in command prompt?

I am using the git-prompt.sh script to show the git status at the bash command prompt. Using the PROMPT_COMMAND method to also have colors: .bashrc : source ~/.bash.d/git-prompt.sh # Show git ...
jost21's user avatar
  • 757
0 votes
1 answer
700 views

Customize Bash Prompt and apply the modification for all logged users

I have a linux with dynamic IP address. I would like to change the bash prompt according to the current IP. A python script is responsible for this connection and his launched at boot. os.system('...
hotips's user avatar
  • 145
0 votes
1 answer
42 views

Print time after command has been entered

Is there a way to concatenate time after command has been entered? Example: user@machine$ date 11:50:41 Tue Jun 25 11:50:41 EEST 2019 Current workaround is to add \t\n to PS1 before the username but ...
krg's user avatar
  • 17
0 votes
1 answer
590 views

Shell prompt: \W shown as '\w', left puzzled

TL;DR: PS1 is not as it's supposed to be. PS1="\W" shows as \w█ the block being the blinking cursor. The folder name will appear only after directory change. OS is Debian 9.9 Stretch. I'm not quite ...
krg's user avatar
  • 17
0 votes
1 answer
277 views

Unable to use `read` command in .ssh/rc

I want to read input from keyboard when SSH connection established. So I edited .ssh/rc file and used read command, just like: #!/bin/sh read -p "input: " something echo $something But the output ...
Alexander Zhang's user avatar
0 votes
2 answers
972 views

Two .bashrc files in my home dir

I'm using Ubuntu on Windows and I was attempting to modify my .bashrc file to add a directory to my PATH variable. I used redirection to do it like so: pwd >> ~/.bashrc Now I have two .bashrc ...
joshisanonymous's user avatar
3 votes
3 answers
857 views

Alias to source .bashrc after it's been edited?

I would like to add an alias (for convenience sake) that would allow me to edit my bashrc, and if changes were made, source it, but if no changes were made, don't source (in case I changed my mind). ...
psycho9o's user avatar
0 votes
1 answer
1k views

Correct syntax in a script to append to .bashrc for root

I'm trying to script some things and cannot figure out the correct syntax to append to root's .bashrc file. For this script, I'm just trying to get it to display the hostname in red when we ssh into ...
808mrb's user avatar
  • 33
8 votes
1 answer
2k views

Does .bashrc contain syntax errors?

In the Ubuntu 18.04 LT .bashrc file there is the following: # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in xterm-color) color_prompt=yes;; esac Isn't xterm-...
Argent's user avatar
  • 285
0 votes
1 answer
155 views

How to escape this command to add alias in .bashrc?

I want add alias command to .bashrc. the command like this : xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }' I am confused to escape character from that command. ...
ryanw's user avatar
  • 103
0 votes
1 answer
202 views

Setting and MSYS Home and abbrviating the directory in the prompt line

I run Msys specifically for running OMNETpp - a simulation library. I modified the mingw environment setup scripts in order to get it to start with my home directory, ~/, by setting up HOME. Example ...
EdL's user avatar
  • 123
1 vote
1 answer
3k views

How do I make bash completion behave like this?

I’m not sure if what I’m asking is possible, but what I would like bash to do on tab presses is this: On the first tab press, expand a common prefix (skip/beep and do nothing, I don’t really mind, if ...
Luna Razzaghipour's user avatar
0 votes
1 answer
83 views

How do I provide an environment to a script started like bash -c bla.sh

I noticed that e.g. ~/.bashrc is not sourced when starting a script with bash -c bla.sh. So how else can I provide environment variables? Preferably without explicitly setting them in the invocation.
rhall's user avatar
  • 3
0 votes
2 answers
2k views

No value for $TERM and no -T specified Ubuntu LTS 18.04

I edited my .bashrc and .bash_profile files in the home directory for both the user and root. Everything works perfectly. About a week later, upon reboot I get this error, but everything still works ...
Dash Conroy's user avatar
0 votes
1 answer
63 views

Why file content is not remain after unmount a drive in linux?

I wrote a script on bashrc.cmd from my windows 10 to activate my virtual environment automatically. I pointed the path of bashrc.cmd into AutoRun according to this post. bashrc.cmd @echo off CD dev-...
testuser's user avatar
  • 115
0 votes
1 answer
351 views

How to automatically add characters to the user input before command execution

I love reading on the terminal - it focuses my attention and lets me read twice the amount I used to read on browsers, etc. I wrote a script using alias for bash.bashrc that changes the working ...
ExceptionInTheRye's user avatar
0 votes
0 answers
44 views

Execute `ls` whenever user does a `cd` on terminal [duplicate]

I know bashrc is executed on terminal startup. But my use case is something like this, To execute a specific command, say ls, whenever user executes another specific command, say cd, on the ...
swayamraina's user avatar
0 votes
2 answers
5k views

How to automatically close the ssh-agent along with closing Cygwin?

I am on Windows 10 Pro. I have added the following lines to my Cygwin (fully up-to-date) ~/.bashrc file: eval $(ssh-agent) > /dev/null ssh-add > /dev/null 2>&1 in order for me not to ...
Vlastimil Burián's user avatar
4 votes
3 answers
21k views

Bash on Ubuntu on Windows gives error "-bash: /home/user/.bashrc: Permission denied" on startup

So I was working with Bash on Unbuntu on Windows in order to learn Linux, so I attempted to edit the .bashrc file as a way of learning. To do this I went into the root folder in my C: drive and opened ...
wjmccann's user avatar
  • 143
5 votes
1 answer
2k views

Ctrl D not exiting bash after sourcing bashrc

The bashrc was not written by me, and sources a lot of different configuration files. Upon sourcing it, I can't exit bash with Ctrl+D anymore. I found this related question about zsh, and I would ...
MayeulC's user avatar
  • 185
3 votes
0 answers
830 views

Is there a way to enable fuzzy Bash auto-completion like Intellij has?

I use Intellij a lot, and one of the features I love is the auto-completion. Notice how you can skip letters in your input and it guesses what you want based on those letters: Is there a way to ...
AggieDev's user avatar
  • 131
0 votes
1 answer
270 views

Bashrc unexpected EOF Error

I am pretty new to all this so apologies if i am asking an easy question.. I need to update my .bashrc file which is a hidden file in home directory. İ opened it using gedit and overwrite it with my ...
Muhammad Kashif's user avatar
0 votes
1 answer
3k views

How to bring bash history to default in CentOS 7

$ set -o | grep history history on $ echo $HISTFILE /root/.bash_history $ echo $HISTSIZE 1000 $ echo $HISTFILESIZE 1000 I ran following command and ...
LifeSaver's user avatar
0 votes
2 answers
1k views

Linux: bashrc. How to load bashrc content from another file?

I occasionally have to re-install operating systems on the various linux machines which I manage. Every time I do this, I have to copy the .bashrc file to a USB drive before wiping the old system, and ...
user3728501's user avatar
  • 2,714
2 votes
1 answer
70 views

Automatically list contents of directory when changing to it

I am a huge fan of the ~/.bash_aliases file and I am trying to get the cd command to automatically list the contents of a directory when I change to it. In my .bash_aliases file, I put alias cd='cd $...
tonyWaldheim's user avatar
0 votes
1 answer
330 views

Cygwin bashrc package install error

Cygwin was unable to install a package. Is anyone able to advise with the details below? Nisarg.Rajput ~ apt-cyg install bashrc --2018-01-01 11:42:57-- http://ftp.ntu.edu.tw/pub/cygwin//x86_64/...
Nisarg's user avatar
  • 1
4 votes
2 answers
12k views

Activate virtualenv using alias

I can activate my python virtual environment from it's folder by entering . bin/activate. I'd like to instead type a single word alias, such as shazam, from the home folder (or anywhere else) that ...
landrykid's user avatar
5 votes
1 answer
13k views

How to add all subfolders a folder to PYTHONPATH

All of my Python module sources are in the folder /src/*: /src/module1 /src/module2 ... /src/modules100 If I want to add all of these modules to my PYTHONPATH, I need to add them individually in ...
motam79's user avatar
  • 480
3 votes
1 answer
74 views

Bash macro that does not let me "git push" after 3am

Alright, so basically I've managed to cause problems by pushing very late at night. How could I change git push (without forcefully changing git write-protected files) to need "Are you sure?" dialog ...
Joonatan Samuel's user avatar
2 votes
1 answer
6k views

How to edit a new .bashrc file in a Mac to set the python path?

I have been trying to open a new file .bashrc wit TextEdit on a Mac (which I am not used to work with). How to open such a new file and set the python path? I did a touch .bashrc and a /Applications/...
Alex's user avatar
  • 674
0 votes
1 answer
592 views

What does bashrc PS1 check [ "$PS1" = "\\s-\\v\\\$ " ] mean?

In bashrc file in Fedora/Red Hat I see following line: [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " What is the check being done in [ "$PS1" = "\\s-\\v\\\$ " ] and why is PS1 set only ...
Akilan's user avatar
  • 725
13 votes
3 answers
9k views

`ssh <host>` is a login shell, but `ssh <host> <command>` is not?

I've noticed that when I run a command directly on an SSH host using the ssh <host> <command> syntax, I see the output of .bashrc but not the output of .bash_profile (or .profile). For ...
Ryan Lue's user avatar
  • 505
1 vote
1 answer
5k views

.bashrc not automatically initalising?

When opening a new terminal, I need to do source ~/.bashrc or source ~./bash_profile before my $PATH variable is initalised. I thought .bashrc did this automatically? How do I make it so I don't need ...
user avatar
1 vote
2 answers
177 views

emacs-style partial directory path completion in bash

In emacs, when entering a file path, I can do something like: ~/c/s/h/npu2-o.c<TAB> and have it expand to ~/code/skiboot/hw/npu2-opencapi.c Is there any way to get similar path expansion in ...
ajd's user avatar
  • 113
3 votes
2 answers
22k views

How can I add password of user as alias in bashrc file?

I have created alias for username and it works fine alias yb="ssh name@hostname" It works fine, but I also want to create alias for password, Can anyone help how can I do this?
Ramesh Kumar's user avatar
21 votes
1 answer
11k views

Bash is slow to start because of this line in .bashrc. What could cause this?

My .bashrc file contains a line to this effect: alias prog="/path/to/script.sh $(find $(pwd) -name prog)" When I comment out this line, Bash starts almost instantly when I open a new terminal. With ...
BBales's user avatar
  • 313
9 votes
2 answers
7k views

Which bash rc files are run on non-interactive/non-login shells?

My Understanding there are no rc files called for non-interactive/non-login shells; for example, those run by cron (I don't know this for certain and would lean on the community's expertise) non-...
vol7ron's user avatar
  • 485
1 vote
2 answers
1k views

How to check where my PATH is modified?

I have in my PATH a folder destination included which does not exist any more. Still I just can't find in which file is it set. I checked for .bashrc, .profile, .bash_profile does not exist. Is there ...
MattSom's user avatar
  • 113
0 votes
1 answer
73 views

Turn off the touchpad every time I start linux

Im running a "bastard hodge-podge" Debian (sort of) linux based originally on pratham OS with quite a few things I had to build and install to get running Simply need to turn off the infernal ...
OldBat OnnaRat's user avatar
8 votes
2 answers
769 views

Can I make bash stop parsing and validating a certain alias?

I'm using Fedora 25, and have added the following alias to my bash profile: alias releasenotes="dnf updateinfo --refresh info `dnf check-update | cut -d '.' -f 1 | xargs` | less" (I can't use ...
iLikeDirt's user avatar
  • 333
0 votes
1 answer
540 views

How to change environment variable when user change?

I have portable terminal with bash shell on usb drive, and I want to load different environment variables every time I change computer, users are different on other machines. How to setup .bashrc file ...
dukasvili's user avatar
  • 543
-2 votes
2 answers
2k views

.bash_profile: line 260: syntax error near unexpected token `('

I have bash function: WORKING_REACT_EXAMPLES="$HOME/tutorials/javascript/react/working-react-examples" dualpush() { cd $WORKING_REACT_EXAMPLES; cmpushall "$1"; cd ..; cmpushall $1; cd $...
codyc4321's user avatar
  • 410
0 votes
1 answer
1k views

syntax error near unexpected token `(' bash

I am working on helpers to open my project when I get to work. I have so far: alias cdsloadmin="cd $SLO_ADMIN_SUITE_PATH; workon slo-admin-suite; atom $SLO_ADMIN_SUITE_PATH" runsloadmin() { ...
codyc4321's user avatar
  • 410
142 votes
4 answers
241k views

Bash if on single line

I would like to know how can I write if conditions inside a bash script on a single line. For example, how can I write this on a single line, and then put another one just like it on the next? if [ -...
Horațiu Mlendea's user avatar
4 votes
2 answers
5k views

SSH Login "clear screen" before MOTD is displayed

I'm trying to clear the screen contents before the MOTD is displayed so that when you SSH onto the server the MOTD header is at the top of your screen, not the previous commands ran on your local ...
Jordan Davis's user avatar
0 votes
3 answers
1k views

Enable confirmation for rm command with force flag

Is there any option to enable confirmation for the rm -rf . We had an alias setup for rm=rm -i so whenever we delete a file it asks for confirmation but when -f flag is supplied it will not asks for ...
Geo's user avatar
  • 109
0 votes
1 answer
235 views

How can I alias a binary dependent on the machine I am on

I work on different machines, some as centos7, some are centos6, I build a binary tmux with a different version on each 'type' as the same version cannot runn both. How can I tell my .bashrc to ...
statquant's user avatar
  • 245
1 vote
2 answers
720 views

bashrc substitute in Windows for making auto execution of CMD commands in each bootstrapping?

I want that each time I start the Windows CMD, a certain command will run. In Nix systems like Ubuntu or Centos, I would just add the desired command to /etc/bash.bashrc or /home/USERNAME/.bashrc ......
user avatar