Stack Exchange Network

Stack Exchange network consists of 174 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.

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
32 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
34 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
47 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
60 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
54 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
15 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
57 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
24 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
65 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
58 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
242 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
414 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
85 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
237 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
118 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
31 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
42 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
314 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
84 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
0answers
37 views

Exporting Ruby Gems to $PATH

I am trying to run some ruby gems from my terminal, but I am getting the following error: You don't have /Users/developer/.gem/ruby/2.3.0/bin in your PATH, gem executables will not run. I added ...
0
votes
2answers
78 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
93 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
49 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
16 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
143 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
40 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
57 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
27 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
65 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
89 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
43 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
53 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 ...
2
votes
0answers
73 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
210 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 ...
1
vote
1answer
115 views

creating alias in bashrc in wsl [duplicate]

I'm trying to create alias for for cd command to AppData and %programdata% folders but I got path not found while if I write manual it works, here is what I'm doing: In .bashrc I do alias client= '...
0
votes
2answers
46 views

Executing remote command just before remote server terminates connection

So I have searched for this but I didn't find anything which addresses this. I frequently connect to a remote server through ssh on which I don't have sudo permissions. Let's say the connection gets ...
0
votes
0answers
125 views

How to set environment variables to path so it can be read from GUI and command line from the same program?

I installed texlive and I want to add it as an environment variable to my Path so that Emacs AucTeX can read it when I start emacs from the GUI or from the command line. So far I've read that emacs ...
0
votes
2answers
482 views

Refresh .profile and .bashrc

I've split up my .profile and .bashrc files like so based on various advice I've read. I have an alias bin which I use to refresh my environment after changing .profile and .bashrc to avoid exiting ...
2
votes
1answer
57 views

bashrc not activated

I have installed the Anaconda data science package on my Ubuntu 16.04 server. To make it work (I think this means adding Anaconda to the path), I must enter, every time after I log in to the server ...
1
vote
0answers
25 views

Display not working for any user except root on tool vnc for Os Suselinux

I was trying to install SAP Hana Data provisioning agent for which SAP Note said that we need a non-root user who should have read/write access to /usr/sap folder and display access. So I started ...
1
vote
0answers
56 views

How to run vim with a color file from an uncommon place?

I try to make a bash alias like this : alias vi='vim -u /path/to/conf/.vimrc' It works well, but if I add the color file, it failed : vim -u /path/to/conf/.vimrc -S /path/to/conf/colors/foobar.vim :...
1
vote
2answers
662 views

Date & Time loop in bash

I am trying to download the yesterday logs through an external API, For API I need to provide a date range from & to as input parameters. From API I can download 1 hour log max for each call. ...
2
votes
2answers
81 views

How do I make a working emacs alias function?

In an attempt to go around an annoying aspect of tmux, I have the following code in my .bashrc file: alias emcs="command emacs" # Fix emacs in tmux emacs () { if [ $TERM != "xterm" ] then ...
0
votes
0answers
16 views

Refresh command output in alias [duplicate]

When I set in .bashrc something like: alias="docker stop $(docker ps -aq)" or alias="echo $(ls -l ~)" obviously never refreshes the command output in $(), so is an string... So, my question is, ...
-1
votes
2answers
180 views

Can you make the `dd` command safe?

We all have (or know someone who has) unintentionally misused the destroy-disk (dd) command. What ways exist (if any) to change the command in the following or a similar way: If /dev/sda is given as ...