Difference between revisions of "Package:Bash"

From Funtoo
Jump to: navigation, search
m
m (more details)
 
(7 intermediate revisions by 3 users not shown)
Line 20: Line 20:
 
{|class="table table-striped"
 
{|class="table table-striped"
 
|| Shortcut || Description
 
|| Shortcut || Description
 +
|-
 +
|| <code>Tab</code> || Autocomplete
 
|-
 
|-
 
|| <code>Ctrl + r</code> || Search as you type from lastlog
 
|| <code>Ctrl + r</code> || Search as you type from lastlog
Line 47: Line 49:
 
== Bash Completion ==
 
== Bash Completion ==
 
See [[Package:Bash completion|bash completion page]].
 
See [[Package:Bash completion|bash completion page]].
 +
 +
== Configuration Files ==
 +
=== ~/.bashrc ===
 +
<code>~/.bashrc</code> gets loaded on bash startup. You can source files, put aliases, functions and export variables there.
 +
{{file|name=~/.bashrc|lang=bash|desc=bash runtime configuration|body=
 +
source /etc/profile.d/bash-completion.sh
 +
 +
export EDITOR="vim"
 +
 +
alias mv='mv -v'
 +
alias cp='cp -v'
 +
alias rm='rm -v'
 +
alias ping='ping -c 5'
 +
alias emerge='emerge --ask-enter-invalid -av'
 +
#unalias emerge to make it behave normally again
 +
 +
alias e='emerge'
 +
alias eu='emerge -uavDN --with-bdeps=y @world'
 +
 +
alias used='cat  ~/.bash_history {{!}} sort {{!}} uniq -c {{!}} sort -n'
 +
 +
calculator() {
 +
        echo "$@" {{!}} bc
 +
}
 +
 +
#to add more paths:
 +
PATH="/opt/bin:$PATH"
 +
}}
 +
 +
=== Path ===
 +
Any file within your path will be able to utilize tab completion and can be run with out ./ 
 +
You can see what paths are set by running:
 +
{{console|body=###i## echo $PATH
 +
/bin:/usr/bin}}
 +
 +
ls /bin/ shows /bin/echo and many other programs that can be invoked directly because they're in your path. 
 +
in this example echo hello world will be invoked using the path, absolute path, and then relative path:
 +
{{console|body=###i## echo "hello world"
 +
hello world
 +
###i## /bin/echo "hello world"
 +
hello world
 +
###i## cd /bin && ./echo "hello world"
 +
hello world}}
 +
 +
=== Process Management ===
 +
To show which path a binary is loaded from:
 +
{{console|body=###i## which rar
 +
/opt/bin/rar}}
 +
 +
to run a command and have it keep running regardless of killing the terminal:
 +
{{console|body=###i## nohup ##r##command##!r##}}
 +
 +
== media ==
 +
{{#widget:YouTube|playlist=PLDOiVunkOLsEJF2toupqFubpWtVasDqOg}}
  
 
{{EbuildFooter}}
 
{{EbuildFooter}}

Latest revision as of 04:41, May 19, 2015

Bash

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.

This is the ebuild for bash, the standard shell for Funtoo Linux systems.

Bash is the GNU Project's Bourne Again SHell, a complete implementation of the IEEE POSIX and Open Group shell specification with interactive command line editing, job control on architectures that support it, csh-like features such as history substitution and brace expansion, and a slew of other features. [1]

Learning Bash

The following articles, written originally for IBM developerWorks by Daniel Robbins, serve as an excellent introduction to the bash shell:

Moving on Command Line

Shortcut Description
Tab Autocomplete
Ctrl + r Search as you type from lastlog
Ctrl + a Move to the start of line
Ctrl + e Move to the end of line
Ctrl + k Cut from cursor to the end of line
Ctrl + w Cut from cursor to the previous whitespace
Ctrl + c Clear line
Ctrl + l Clear screen
Alt + f Move one word forward
Alt + b Move one word backwards
Alt + d Cut from cursor to the end of word
Alt + backspace Cut from cursor to the start of word

Bash Completion

See bash completion page.

Configuration Files

~/.bashrc

~/.bashrc gets loaded on bash startup. You can source files, put aliases, functions and export variables there.

   ~/.bashrc (bash source code) - bash runtime configuration
source /etc/profile.d/bash-completion.sh

export EDITOR="vim"

alias mv='mv -v'
alias cp='cp -v'
alias rm='rm -v'
alias ping='ping -c 5'
alias emerge='emerge --ask-enter-invalid -av'
#unalias emerge to make it behave normally again

alias e='emerge'
alias eu='emerge -uavDN --with-bdeps=y @world'

alias used='cat  ~/.bash_history | sort | uniq -c | sort -n'

calculator() {
        echo "$@" | bc
}

#to add more paths:
PATH="/opt/bin:$PATH"

Path

Any file within your path will be able to utilize tab completion and can be run with out ./ You can see what paths are set by running:

root # echo $PATH
/bin:/usr/bin

ls /bin/ shows /bin/echo and many other programs that can be invoked directly because they're in your path. in this example echo hello world will be invoked using the path, absolute path, and then relative path:

root # echo "hello world"
hello world
root # /bin/echo "hello world"
hello world
root # cd /bin && ./echo "hello world"
hello world

Process Management

To show which path a binary is loaded from:

root # which rar
/opt/bin/rar

to run a command and have it keep running regardless of killing the terminal:

root # nohup command

media