Announcement

Collapse
No announcement yet.

.bashrc

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    .bashrc

    Just had a look at the .bashrc of 8.10 and what can I say? There's more stuff in there than you can shake a stick at! Not sure how useful it all is...

    Anyway, I wondered what your ideal .bashrc looks like.

    Here a couple of additions I find useful:

    # my additions
    alias ..='cd ..'
    alias lla='ls -la'
    alias update='sudo aptitude update'
    alias upgrade='sudo aptitude safe-upgrade'
    alias install='sudo aptitude install'
    alias search='aptitude search'
    alias remove='sudo aptitude remove'
    alias purge='sudo aptitude remove --purge'
    alias show='aptitude show -v'
    alias clean='sudo aptitude clean'
    alias aclean='sudo aptitude autoclean'
    alias df='df -h'
    alias blkid='blkid -L'
    To activate your new .bashrc simply do a

    Code:
    source .bashrc
    Please post any suggestions, improvements, whatever!

    Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

    #2
    Re: .bashrc

    This applies to any configuration file I modify.

    I create ~/etc and store modified configuration files there. Then I symlink them to their standard locations and names. For instance, for .bashrc: cp .bashrc etc/bashrc && rm .bashrc && ln -s etc/bashrc .bashrc

    Then, when I want to modify the configuration for any file I can easily find it. I keep /home in a separate partition, so when I upgrade, my files remain intact. If any configuration files I customized get overwritten by the new installation, I can easily restore them.

    There is a post at https://wiki.ubuntu.com/Spec/EnhancedBash that has some good ideas.

    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize

    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"

    # set variable identifying the chroot you work in
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
    fi

    PS1='\n\[\033[01;31m\]\u\[\033[00m\]: \[\033[01;34m\]\W \[\033[00;36m\]\$\[\033[00m\] '

    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
    if env | grep -q 'KONSOLE'; then
    PS1=$PS1"\[\e]0;\w\a\]"
    fi
    ;;
    *)
    ;;
    esac

    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.

    if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
    fi

    # enable color support of ls and also add handy aliases
    if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
    fi

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
    fi
    if ! grep -q ${HOME}/bin <<< $PATH; then
    PATH=${PATH}:${HOME}/bin
    fi
    export PATH

    HISTIGNORE="cd:ls:[bf]g:clear:exit"

    # don't put duplicate lines in the history. See bash(1) for more options
    export HISTCONTROL=ignoredups
    # ... and ignore same sucessive entries.
    export HISTCONTROL=ignoreboth

    shopt -s histappend
    export PROMPT_COMMAND='history -a; history -n'
    #Increase history size
    export HISTSIZE=1000
    export HISTFILESIZE=1000

    (find ${HOME} -name '*~' -exec rm '{}' ';' >/dev/null 2>&1 &) >/dev/null 2>&1

    alias trash="mv -t ~/.local/share/Trash/files --backup=t"

    #Use GREP color features by default
    export GREP_OPTIONS='--color=auto'

    73, AC7ZZ

    Comment


      #3
      Re: .bashrc

      I opt to keep my alias definitions in the ~/.bash_aliases file instead of cluttering up the .bashrc file.
      Using Kubuntu Linux since March 23, 2007
      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

      Comment


        #4
        Re: .bashrc

        Then, when I want to modify the configuration for any file I can easily find it.
        I like that, it's simple and it's safe. You avoid the mv command - has it ever failed you or you never used it ?

        I opt to keep my alias definitions in the ~/.bash_aliases file instead of cluttering up the .bashrc file.
        I haven't got one Anyway, anything in there which you use on a regular basis?
        Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

        Comment


          #5
          Re: .bashrc

          What I have in my ~/.bash_aliases file:
          alias a='clear && alias'
          alias aptClean='sudo apt-get clean; sudo apt-get autoclean; sudo apt-get autoremove'
          alias chkHD='clear && sudo smartctl -a /dev/sda'
          alias findit='clear && sudo find /* -mount -name'
          alias fstab='clear && cat /etc/fstab'
          alias gM='clear && cat /boot/grub/menu.lst'
          alias ls='ls --color=auto'
          alias mtab='clear && cat /etc/mtab'
          alias sL='clear && cat /etc/apt/sources.list'
          alias simI='sudo apt-get install --simulate '
          alias simR='sudo apt-get remove --simulate '
          alias simU='sudo apt-get dist-upgrade --simulate '
          alias ua='clear && source ~/.bash_aliases'
          alias used='clear && df -hTxtmpfs'
          alias xC='clear && cat /etc/X11/xorg.conf'
          Using Kubuntu Linux since March 23, 2007
          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

          Comment


            #6
            Re: .bashrc

            That's aptClean with a real capital C 8) I'm including some of your ideas right now, thanks!
            Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

            Comment


              #7
              Re: .bashrc

              I had, at one time, three separate aliases for clean, autoclean, and autoremove, but as I always ran them sequentially, I decided to create the one single alias that does them all.
              Using Kubuntu Linux since March 23, 2007
              "It is a capital mistake to theorize before one has data." - Sherlock Holmes

              Comment

              Working...
              X