You are not logged in.

#51 2006-09-03 09:00:46

palandir
Member
Registered: 2006-05-14
Posts: 73

Re: basic ~/.bashrc ~/.bash_profile tips thread

Elias wrote:

BTW, i got a directory here that state : "drwxr-xr-t", what does it means and what is the octal value, if it exist, for that ?

If "t" is set on a directory, it means that files inside this directory can be renamed or removed only by the owner of the file, directory or the superuser. That's why /tmp always has "t" set.
I don't remember what "t" on a regular file does, it might have no effect at all. Thank god it's quite unimportant. wink

Keep in mind that "drwxr-xr-t" means "drwxr-xr-x" with sticky bit set. If the last "x" wasn't set, it would read "drwxr-xr-T".
Same goes for "s" (setuid/setgid) respectively "S".

The octal form to display the special access rights is:
1xxx for t
2xxx for setgid
4xxx for setuid

For example (very made-up):
3641 is rw-r-S--t
7654 is rwSr-sr-T

Offline

#52 2007-04-27 02:31:53

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Re: basic ~/.bashrc ~/.bash_profile tips thread

jaboua wrote:
fk wrote:

Why exists .bashrc and .bash_profile, when I only need one?

I think one of them is run only when logging in, while the other one is run every time bash is run.

Hooray for resurrecting dead threads! Yay!

.bash_profile is called only once, when you log in. .bashrc is called each time you spawn a new bash shell.

As a tidbit, many of you have said you have

source ~/.bashrc

in .bash_profile, or that you symlink the latter to the former.

To avoid errors, should .bashrc go missing, here's a minor modification:

if [ -f ~/.bashrc]; then
  source ~/.bashrc
fi

- KD

Offline

#53 2007-04-27 14:29:28

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Re: basic ~/.bashrc ~/.bash_profile tips thread

More handy settings:

(More info at: http://forums.gentoo.org/viewtopic.php?t=112348)

# checks window size after command execution -> prevents wrapping problems after window resize
shopt -s checkwinsize

# autocorrects cd misspellings, eg. from 'cd /sur/src/linus', shell would correctly guess 'cd /usr/src/linux'
shopt -s cdspell

# wildcard includes dotfiles
#   - this is handy since eg. 'chmod -r .* *' would include the directory itself, whereas
#     now you can do 'chmod -r *' and all files and dotfiles will be chmodded, without the
#     directory itself being affected
shopt -s dotglob

- KD

Offline

#54 2013-08-11 23:23:24

Ahad12
Member
Registered: 2013-01-14
Posts: 41

Re: basic ~/.bashrc ~/.bash_profile tips thread

Got two of em:
Install packages from the AUR:

# Requires base-devel at latest version
alias inspkg=makepkg -sic

Stream YouTube videos to mplayer:

# Requires youtube-dl at the latest version
playYouTube(){
       #If you would like to use a diffrent command-line-accesable media player simply replace 'mplayer' with your player and options of your choice eg. ffplay
        mplayer $(youtube-dl -g -f 34 $1) # If you have a fast connection and would like to play youtube videos at full resoultion remove '-f 34' option from 
                                                              # youtube-dl
}   

Simple scripts I came up with myself
EDIT:
Added commenting, added the i and c option for makepkg : );

Last edited by Ahad12 (2013-08-11 23:43:14)

Offline

#55 2013-08-11 23:27:08

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: basic ~/.bashrc ~/.bash_profile tips thread

Instead of the first one, why not use 'makepkg -si'?

Offline

#56 2013-08-11 23:30:55

Ahad12
Member
Registered: 2013-01-14
Posts: 41

Re: basic ~/.bashrc ~/.bash_profile tips thread

karol wrote:

Instead of the first one, why not use 'makepkg -si'?

Cool, never noticed unitil now, and yes you can add the i option.

Offline

#57 2013-08-11 23:31:54

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: basic ~/.bashrc ~/.bash_profile tips thread

KomodoDave wrote:

Hooray for resurrecting dead threads! Yay!


Oh, if only he could see the glorious 6-year necrobump that would follow his post.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#58 2013-08-11 23:38:20

Ahad12
Member
Registered: 2013-01-14
Posts: 41

Re: basic ~/.bashrc ~/.bash_profile tips thread

Xyne wrote:
KomodoDave wrote:

Hooray for resurrecting dead threads! Yay!


Oh, if only he could see the glorious 6-year necrobump that would follow his post.

Never even STARTED using linux till 2011...

Offline

#59 2014-07-31 07:33:06

xKISAMEx
Member
From: USA
Registered: 2011-09-23
Posts: 26

Re: basic ~/.bashrc ~/.bash_profile tips thread

Excuse the necrobump, found a function I quite enjoy e.o

conf() {
    case $1 in
        bspwm)       vim ~/.config/bspwm/bspwmrc ;;
        panel)       vim ~/.config/bspwm/panel ;;
        sxhkd)       vim ~/.config/sxhkd/sxhkdrc ;;
        baliases)    vim ~/.bash_aliases ;;
        xinit)       vim ~/.xinitrc ;;
        xresource)   vim ~/.Xresources && xrdb ~/.Xresources ;;
        bashrc)      vim ~/.bashrc && source ~/.bashrc ;;
        mpd)         vim ~/.mpd/mpd.conf ;;
        ncmpcpp)     vim ~/.ncmpcpp/config ;;
esac
}

Don't really remember where I found it though, lost the bookmark. Somewhere on github I think...

Offline

#60 2014-07-31 07:36:35

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: basic ~/.bashrc ~/.bash_profile tips thread

This is more maintainable/flexible:

#!/usr/bin/env bash
# edit dotfiles
# heavy lifting by falconindy: https://bbs.archlinux.org/viewtopic.php?id=128585

dirs=($HOME/.$1* $HOME/.$1/ $XDG_CONFIG_HOME/$1/)
IFS=$'\n'

read -r -d '' -a files < \
  <(find "${dirs[@]}" -type f \( \
       -name "*.conf" \
    -o -name "*.cfg" \
    -o -name "*rc" \
    -o -regextype posix-extended -regex '.*/conf(ig|ig[.][a-z]{2,3})?$' \
    \) 2>/dev/null)

(( ${#files[*]} )) && "${EDITOR:-vi}" "${files}"

# vim:set sw=2 ts=2 et:

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#61 2014-07-31 11:17:57

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: basic ~/.bashrc ~/.bash_profile tips thread

xKISAMEx wrote:

found a function I quite enjoy

jasonwryan wrote:

This is more maintainable/flexible:

Maintainable for you, maybe... That's an intense piece of code!

I have my "HISTSIZE" and "HISTFILESIZE" variables set to something enormous, so editing a configuration file for me is done with "Ctrl-R, blargittyblarg.rc". smile

Offline

#62 2014-07-31 11:57:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: basic ~/.bashrc ~/.bash_profile tips thread

Why the read + array, wouldn't a find with "-exec $EDITOR '{}' \;" be sufficient?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#63 2014-08-01 08:26:56

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: basic ~/.bashrc ~/.bash_profile tips thread

Trilby wrote:

Why the read + array, wouldn't a find with "-exec $EDITOR '{}' \;" be sufficient?

It would, for GNU find. I was vacilating between POSIX and bash when I first started this and seem to have alighted on the most complex implementation... tongue

In its defence, it does work exceptionally well.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB