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
1answer
35 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
45 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
72 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
402 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
60 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
80 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
103 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
27 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
41 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
176 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
50 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
29 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
60 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
33 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
0answers
13 views

Redirecting /var/log/appname to a more accessible location

I have a dev server at work that's decently locked down. However, the application mean to be debugged here only logs to /var/log/appname/[objecttarget]. The object target can change regularly, so I ...
0
votes
2answers
41 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 ...
0
votes
0answers
12 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
100 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
33 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
56 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
1k 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
21 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
62 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
67 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
39 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
45 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
55 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
190 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
80 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
42 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
115 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
357 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
50 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
23 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
51 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
495 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
50 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
138 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 ...
-1
votes
1answer
190 views

Debian 9.4— .profile not read on bash login

The .profile file includes a statement to add the $HOME/bin directory to the PATH (if that bin directory exists). This is not being executed on my bash login. If I manually load the .profile file . ...
1
vote
1answer
52 views

“Cloud” Alias File

I quite frequently will nano ~/.bashrc and add small little alias here and there on one of my boxes. The issue being, often I'll go to use this alias on another one of my PCs and it not be found. I ...
3
votes
2answers
1k views

/etc/profile not sourced for users

In the ubuntu server I run, I added customisations in /etc/bash.bashrc and as .sh files in /etc/profile.d, to add some useful aliases and functionalities for my users. All of them run correctly for my ...
1
vote
1answer
110 views

Set the environment variable in bashrc for preferred PDF viewer

I am currently remoted into my linux workstation's command line environment (bash shell) using SSH with X11 forwarding enabled. I am using the mendeley citation manager's desktop application to ...
0
votes
1answer
65 views

Is there a way to bind a key to a control-sequence in bash?

In my .bashrc file I'm trying to bind a custom escape-sequence key to a control-sequence. What I have is: bind -x '"\eJD0C": "^C"' And it does not execute the shell control-sequence ^C which ...
0
votes
1answer
109 views

How to avoid creating an infinite loop when calling bash inside of bashrc with BASH_ENV set?

Inside of ~/.bashrc, I run a bash script (a script with #!/usr/bin/env bash at the top). I have found that when BASH_ENV is set to my ~/.bashrc that this sets up an infinite loop when a bash command ...
0
votes
0answers
215 views

CentOS 7 XFCE Desktop does not run executable programs

I have a Qt application that I want to run from Desktop. I put the binary itself, created a launcher, created a symbolic link but nothing worked. Nothing shows up like I did not even double click. The ...
0
votes
0answers
35 views

Starting Script at FTP login

I run a vsftp server on Debian and connecting with FTP over TLS. all allowed users are jailed in a chroot after login. Now i want to mount different folders inside the users chroot. For every single ...
1
vote
1answer
41 views

Is it a good practice to make different configuration files as symlinks to some scripts under the same directory?

I was wondering if it is a good practice to make the following configuration files as symlinks to some scripts under a directory e.g. ~/program_files/configurations/. The scripts /etc/rc.local, /...