Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [bashrc]

.bashrc is the primary configuration file for the bash shell.

1
vote
0answers
27 views

su - <username> hangs if I added a line in /etc/bashrc

I added this line to /etc/bashrc file export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/glibc-2.14/lib I log in as root throw SSH normally, but if I wanted to change my user by su - myusername the ...
-1
votes
2answers
72 views

sudo without sudo, implying sudo in script

I made some scripts containing some functions which by design needs sudo permission. I have added those path in .bashrc for Linux and .bash_profile for MacOS so that it can be called from anywhere. ...
1
vote
1answer
41 views

Set to non-default user group upon login in bash

Upon login with .bashrc, how to set the user's group to a non-default one, say targetgroup? Specifically, my problem is that I can execute, on the command line: newgrp - targetgroup but when I ...
1
vote
2answers
32 views

wrong echo command

I am having a little problem with my ubuntu16.04 terminal. I wanted to have access to a data-base through the use of the : echo source /Infos/bd/config11 >> .bashrc echo source /Infos/bd/...
0
votes
0answers
17 views

Can some or all profile/login scripts be bypassed on local console login?

The situation I'm thinking of is that something in /etc/profile or ~/.profile or ~/.login or similar is causing you to be logged out immediately or some other problem/mischief, and you're at a text-...
0
votes
2answers
40 views

Bash Shell takes variable amount of time to load

I use bash on Ubuntu 18.04. I have added a lot of functions and a lot of scripts are sourced in my bashrc. I am able to time the total time it takes to load my terminal, sometimes it takes 0.9 seconds ...
1
vote
1answer
25 views

Modifying the default bashrc alert command

I was scrolling through my bashrc (bored) and I got interested in the alert command that is concatenated in there by default. It's practical and everything, but it requires you to type ; alert at the ...
0
votes
1answer
220 views

How to change default text edior for virsh edit? (setting EDITOR env variable didn't work)

I recently installed virt-manager on an Arch Linux install, and unlike under Ubuntu, I was not prompted to choose a text editor on the first launch of virsh-edit. Instead, the XML file was opened in ...
1
vote
1answer
186 views

Set up .bash_profile and .bashrc for local and remote access

I've noticed that when I open a terminal on my ubuntu machine locally, it sources .bashrc, but when I connect via ssh, it sources .bash_profile. I added a line in .bashrc to source .bash_profile so I ...
0
votes
0answers
84 views

Is a .zshenv or .zprofile necessary for a proper/function zshell?

I have an issue where every terminal I open up has the first line: $home/.zshrc:1: command not found: followed by whatever I have as the first line in my .zshrc file. (See "What changes to a .zshrc ...
0
votes
0answers
36 views

Modifying .bashrc to send history to syslog, problems with quotes

Attempting to enable logging of bash commands to syslog, including the ip of the logged in ssh user. The end goal is to have a script which will echo 'export PROMPT_COMMAND=....'' >> ~/.bashrc ...
2
votes
1answer
47 views

how to pipe to a sourced function in bashrc file?

we all know how to pipe to shell scripts and installed programs like grep,awk ... but what about a sourced function in .bashrc or .zshrc ? this is a test function : function fff(){ echo "$@" } ...
0
votes
0answers
20 views

Bash promt (.bashrc) working not properly if added color [duplicate]

Before I used Zsh and some themes are not work properly, I thought that because of Zsh, but when I returned to Bash shell it still got same problem. Here is the problem: It doesn't jump right into the ...
0
votes
0answers
45 views

Sourced .bashrc detection

At the user level is there a way for me to craft a sort of 'tripwire' in my .bashrc file to detect if another user has sourced my .bashrc? What I would like to do is have some sort of log created ...
0
votes
2answers
52 views

How to remove first segment or segments from PATH in shell script [duplicate]

I wanted to remove a CUDA directory from PATH by a sh script. The directories are showed by doing echo $PATH /usr/local/cuda-9.0/bin:/usr/sbin:/usr/bin: I want only: /usr/sbin:/usr/bin: My script ...
1
vote
1answer
131 views

Switch capslock and ctrl with config file on ubuntu 18.04

Recently, I tried to switch capslock and ctrl on my Ubuntu 18.04. I did it by add the following line into my .bashrc: # swap capslock and ctrl /usr/bin/setxkbmap -option "ctrl:swapcaps" This worked,...
0
votes
1answer
76 views

Bash prompt configuration

I've recently switched to Parrot linux and I'm very happy with it, but there's just one thing, this default fancy bash prompt is really ugly. I used zsh before, and for some reasons I want to go back ...
1
vote
2answers
62 views

How can I get the Linux terminal to look like Windows Git Bash?

Before anyone says it, yes, I know this is a duplicate, except when I copy/paste that code into tilde slash period bash(no period)rc, the terminal hasn't changed at all. I'm running Debian on Virtual ...
0
votes
0answers
19 views

Ending slogin session with exit command freezes due to PROMPT_COMMAND modification

I recently embedded an "alert" command into my PROMPT_COMMAND to give me a little notify-send screen notification with the exit code of each command (because I always forget to append the alert when a ...
0
votes
1answer
70 views

How to fix key mapping for control key [closed]

As I have mentioned here for some reason whenever I try to use CTRL key for any of the keyboard shortcuts, it prints the caret sign ^. Here is my .bashrc file: # ~/.bashrc: executed by bash(1) for ...
0
votes
0answers
19 views

Corrupt prompt display after customizing it [duplicate]

I'm using GNU bash, version 4.4.23(1)-release and customized my prompt-look in ~/.bashrc via PS1="\e[0;36m\\u:\e[m\e[0;32m\\w\e[m $ " This gives me following look, including a lengthy command passed ...
1
vote
0answers
58 views

How Linux determines which bashrc file to load when there're multiple of them? [duplicate]

For example, in my company, there're .bashrc, .bash_profile, .bashrc.<username>. However I don't know which one is automatically loaded everytime when it's started. Does it take everything or ...
0
votes
1answer
170 views

Customize bash looks for user profile on debian 9

I am trying to customize the bash prompt on Linux Debian 9. I got the script from Github and I modified the file .bashrc On the terminal, when I log in as root, I can see the customization I was ...
0
votes
2answers
129 views

BASH: how can I save the exit code in PS1 in order to use it later in PS1?

I am attempting to customize my PS1, in the following way (I have removed the colours): PS1='\u@\h:\w$(git_branch)$(useExitCode)\$ ' where git_branch() { git branch 2> /dev/null | sed -e '/^[...
0
votes
1answer
740 views

Initialize program in bashrc

I am in the process of installing Anaconda in Debian. Then I get the following prompt: ... installation finished. Do you wish the installer to initialize Anaconda3 in your /home/isnani/.bashrc ? [yes|...
4
votes
3answers
432 views

Use alias and carry it on

Let's say I have this alias in my .bashrc alias somedir="cd /var/www/site" how can I use somedir in say ... a cd command? e.g. cd somedir/app/ doing this currently returns: -bash: cd: somedir/...
0
votes
2answers
121 views

When should I use .bashrc and when .profile? [duplicate]

I am basically putting all my settings into my .bashrc and when I was using zsh it was all in my .zshrc. The Rust installer just informed me that it has added the new installation to my PATH by ...
0
votes
2answers
920 views

Where is Cygwin set its PATH variable?

If I write echo $PATH in my Cygwin window (mintty) I get a list of paths. That list does not match the Windows Envirnonement variables list. I cannot find a file, where is the variable $PATH set. None ...
-1
votes
1answer
137 views

How can I add find exec command into bashrc?

find . -name "*.mov" -exec bash -c 'ffmpeg -i "{}" -c:v libx264 -crf 20 -pix_fmt yuv420p "${0/.mov}.mp4"' {} \; Above command works perfectly when I run it manually but I could not put it within a ...
1
vote
1answer
48 views

bashrc function, git commit -m with spaces

Currently I have this and it works as expected if I use it like addcommit 'test commit' but if I use it as addcommit test commit it only sees the first word test. Ideally I'd like to have the ...
0
votes
2answers
57 views

environment variables script

There's several centos linux boxes at my workplace. I've been tasked with creating some form of environment variable tool for them. The idea is the user runs the tool, with the argument of their ...
1
vote
2answers
523 views

Set last command exit code to bash prompt

I am running Ubuntu 18.04, and I would like to set my bash prompt so it reads like below: user:~/Documents [14:22:07] 1 $ My PS1 is as follows: ALERT_COLOR="$(tput setaf 1)" # Display unsuccessful ...
0
votes
1answer
129 views

Matlab application command alias creation error in Ubuntu 18.04

I had installed MATLAB 2017b in my Ubuntu 18.04 PC and am able to execute it as : sudo /usr/local/MATLAB/R2017b/bin/matlab -desktop I intend to install another version sometime in the future as well....
0
votes
2answers
116 views

To create an alias for grep and to exclude svn directory

To create an alias for grep and to exclude svn directory (currently no questions cover this) on bash env I did: $ function gp {grep -rnIi --exclude-dir='.svn';} However, I get error bash: syntax ...
1
vote
2answers
335 views

How can I customize $PROMPT_COMMAND without overwriting the default (if present)?

Mac's Terminal comes with a default PROMPT_COMMAND that checks the history and updates the current working directory (title of the tab): Add echo $PROMPT_COMMAND to the top of your .bash_profile and ...
0
votes
2answers
66 views

Setting an alias when double quotes and single quotes both fail

This question is not a duplicate of Why alias behave different than running bash command directly? because I have tried that solution and it hasn't worked. I replaced all my single quotes with double ...
1
vote
0answers
50 views

Export vars env to tmux's window/session/pane's env

Is there any way to export/upgrade list of variable env from a file or something to tmux's window/session/pane? Here I have to manually source .bashrc to update new var env to each tmux's pane.
0
votes
3answers
234 views

My MacOSX terminal doesn't show the current directory

No matter what directory I enter, the terminal always shows me the root directory which is "Nidas-MBP" Nidas-MBP% cd Projects Nidas-MBP% ls 09-Selector-Exercise-Starter.zip My Little Form ...
1
vote
1answer
57 views

Conditional env proxy?

I have the following proxy info in my bash_profile: export http_proxy=http://work.proxy.address.com:8080 export https_proxy=$http_proxy export no_proxy="localhost,.workURL.com" This allows me to run ...
1
vote
2answers
60 views

what might be defining the $PATH variable? [duplicate]

I'm currently exploring and experimenting with my linux just for fun and educational purposes. I have deleted the content of the /etc/bash.bashrc and /etc/profile and I don't have any configuration ...
10
votes
4answers
2k views

Purpose of [ -n “$PS1” ] in bashrc

What purpose does the [ -n "$PS1" ] in [ -n "$PS1" ] && source ~/.bash_profile; serve? This line is included in a .bashrc of a dotfiles repo.
0
votes
1answer
40 views

Multi-line commands are messed up in my PS1

declare __host='\[\e[30;102m\] \h \[\e[0m\]'; declare __dir='\[\e[1;97;44m\] \w \[\e[22m\]'; declare __arrow='\[\e[1m\]▸ \[\e[0m\]'; function __git_status() { local info; info=$(__git_info) &&...
1
vote
3answers
69 views

How to tell what method was used to log in (Password vs. Keyfile) from the bashrc

Is there a way how you can check what auth method the user which just logged in to an account were using? I like to print out a warning after login if someone is using a password instead of a keyfile....
0
votes
1answer
174 views

/etc/bashrc overrides my settings in home .bashrc

i have the following code for my prompt in .bashrc in home dir: PS1_TIME='\033[01;31m\]\t \033[01;32m\]' PS1_USERNAME='\[\e[1;36m\]\u\e[1;37m\]@\e[1;32m\]\h\[\033[00m\]' PS1_LOCATION='\[\033[01;34m\]\...
0
votes
1answer
52 views

Shell Script To CD and Run a Python Script

OK, I know that there is a lot like this question but I literally get nothing. The thing i need is a script that cd's to /home/project then runs python3 pyscript.py I created an alias to cd alias name=...
4
votes
2answers
1k views

Making alias of rm command [duplicate]

Making alias of rm command so that when rm command is executed it will first copy file to /tmp/recycle_bin and then remove the file. But I'm getting issue in the process. Steps performed by me: I ...
0
votes
2answers
74 views

.bashrc is causing git push to fail

I'm trying to push code using git to my remote server, but I get the error: fatal: protocol error: bad line length character: 8 I researched this bug and it turns out my .bashrc file that echos ...
4
votes
0answers
123 views

xmodmap key bindings reset when I open a new tab in the shell

When I open a shell in ranger with shift-s, open vim and then open a shell with :sh or open a new shell tab with ctrl-shift-t, my xmodmap keybindings (swapped caps lock and escape keys) are reset. ...
0
votes
0answers
25 views

Directory Not Accessible As User Sudoing [duplicate]

I'm not entirely sure I follow what is going on here. I've written a function to pull real traffic to my site and placed that function in /etc/bashrc file: traffic() { sudo zgrep " $1" /var/log/httpd/...
2
votes
1answer
253 views

How evil is this: echo bash >> .bashrc

I was thinking of playing a prank on someone by running one of the following commands: echo bash >> .bashrc or echo source .bashrc >> .bashrc If someone did this to you, what could you ...