Solved Can't get BASH alias to stick

I've got the following two lines (they are in fact the only two lines) in my ~/.bashrc file:
Code:
alias ls='ls -G' # to enable colorized output of the ls command
alias startie='xinit /usr/local/bin/i3' # shortcut to launch i3
Neither command seems to take effect, even after completely logging out and then logging back in (though they do seem to work once i3 has launched). How do I get them to work right out of the gate after I first log in after starting the system?

Does it matter if you use single quotes (') or double quotes (")? (I didn't think it did.)

Should I create a script instead of using the second line?

===Updated to add:
Not sure if this helps, but here is some terminal output:
Code:
$ echo $SHELL
/usr/local/bin/bash
$ echo $0
/usr/local/bin/bash
$ ps $$
PID TT  STAT  TIME COMMAND
891  1  Ss  0:00.03 /usr/local/bin/bash -i

Regarding the second line: I've got the i3 tiling window manager installed. I want the ability to sometimes start the X windows manager (via startx) or sometimes just launch i3 which is why I haven't included /usr/local/bin/i3 in my .xinitrc file. Also, I always fat finger "i3" as "ie", hence the spelling of the alias.
 
Dear spython01,
first you have to make sure that your login sshell is bash. Usually it is sh. May be you do not need bash. Please see vipw(8) which allows to change /etc/passwd including all additional actions. Regarding the window manager I can use the script as below to change to a different window managers than default.
Code:
#!/bin/sh
WM=`/usr/bin/dialog --stdout --no-tags --menu "Window Manager" 15 25 5 i3 i3 jwm jwm fvwm fvwm fvwm-themes-start fvwm-themes-start twm twm`
export WM
startx
The basic part of my ~/.xinitrc is just
Code:
exec $WM
In my ~/.profile the default is set to i3 by
Code:
WM=i3;     export WM
Usually I just type startx which invokes x11-wm/i3 .
 
Thanks for the quick reply, chrbr! I have to admit that as a FreeBSD and Unix newcomer, it will take me some time to digest your suggestions. However, I did execute the following commands immediately after installing the bash shell:
Code:
echo "fdesc    /dev/fd        fdescfs        rw    0    0" >> /etc/fstab
chsh -s /usr/local/bin/bash
Doesn't the second line make bash my default shell? How do I confirm if my login shell is now bash? I thought that providing those additional details in my original post would have done that.

When I look at my /etc/passwd file, I do see this line near the bottom:
Code:
username:*:1001:1001:fullname:/home/username/:/usr/local/bin/bash
Even after the reading the man page, I'm not sure what to do with vipw(8).

Regarding your script, I will really have to let that soak in! I'm not a bash scripting expert so I will probably come back with more questions on your approach. Apologies in advance!
 
Dear spython01,
after reading my original post I think it is misleading. You are using shells/bash. You can verify some settings by set. Using ps() with different options or top() you can see which commands are running. It might be just worth to try to live with the default shell sh. For certain tasks you can switch to a different shell anyhow, for example by tying bash while you are in a different shell.

The script uses the variable WM to define the window manager. dialog() is nice to generate small user interfaces.

I wish you a successful start at FreeBSD. The handbook and the forum are very good resources.
 
This might help explain the difference between .bash_profile and .bashrc

http://linuxcourse.rutgers.edu/documents/Bash-Beginners-Guide/sect_01_02.html has a nice section about startup files. I'm pretty sure that the reason I don't have to do anything in Linux to make it read the rc file is that most Linux systems have a default .bash_profile that does have a line sourcing .bashrc if it exists. (If you have a Linux install around to check for yourself, just look for a .bash_profile in /etc/skel (Note the dot in front of the name, you'll have to do ls -a /etc/skel
 
Thanks for the clarification, scottro. I am actually running FreeBSD on a VirtualBox VM where the host OS is in fact Ubuntu. In both my home directory and in /etc/skel, there is a file called .profile (which is used since .bash_profile does not exist) which does include .bashrc as seen below. Thanks again.

Code:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
  # include .bashrc if it exists
  if [ -f "$HOME/.bashrc" ]; then
   . "$HOME/.bashrc"
  fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
  PATH="$HOME/bin:$PATH"
fi
 
Back
Top