You are not logged in.

#1 2011-11-26 01:02:31

handy
Member
Registered: 2011-11-03
Posts: 501

~/.bashrc - What can/does it do for you?

The purpose of this thread is:


1.  Introduce the wonders of ~/.bashrc to those unfamiliar with it, which primarily means the use of custom user made (or added) command line aliases & functions.


2.  Be a venue for users of all levels of experience to learn from each other;- posting questions, answers, parts of or all of their .bashrc file for others to peruse & therefore be able to learn from, & most importantly be able to use parts of others .bashrc files to customise their own to suit themselves due to (hopefully) the inspiration provided in this thread to create a Terminal experience that suits the way that the user (You) would like it to be.

________________



First off, for those unfamiliar with the .bashrc , it really is well worth having a read of the following section of the Arch wiki:

https://wiki.archlinux.org/index.php/Bash

Having read that you should now have a rough idea of just how ~/.bashrc fits in to the functioning of the Arch system.

If that lot sounded like a lot of gobeldy gook don't worry about it, you can still benefit greatly from this thread just by adding any aliases to your .bashrc that you think will make your computing life easier & more productive, & due to the file in question being in your /home directory it is even easier to work with (& backup before you start modifying it).

It is a really good idea to backup your ~/.bashrc before you edit it, as it is easy & great insurance, allowing you to be able to  easily recover from the unexpected. wink Just sticking a .bak on the end of the duplicate & leaving it in the same directory is what I do when a backup is required.

Also, I should mention that any changes you make to the .bashrc will have no effect on any currently open Terminal windows. After you shut an open Terminal window down & then restart it you can then test out your alias(s).

So, lets get down to it.


Aliases:

Are my favourite ~/.bashrc trick, as they allow the user to customise how they use Bash in the Terminal. Which means we can turn a complex command string (which most of us would never remember anyway) into a very simple easily remembered custom made command that we type in the Terminal.

For example, by using the alias in bold under this paragraph, in your .bashrc , it allows the user to input the following relatively brief custom command (that it is its purpose to create) into the Terminal, pSyu which will cause the machine to ask you for your password & then do something that we are all familiar with:

alias pSyu="sudo pacman -Syu"

By inputting the following c-c you run CacheClean, telling it to keep the current & the previous versions of packages in your /var/cache/pacman/pkg :

alias c-c="sudo cacheclean -v 2"

To make package management easier I've added an alias to my ~/.bashrc that allows me to call packer by typing aur in the Terminal:

alias aur="packer -Syu"

You can make an alias for yaourt too, using whatever alias you prefer, in the following example I'll use yaur as the alias:

alias yaur="sudo yaourt -Syu --aur"

Aliases are a great way to make oft used Terminal commands simple to call. I have aliases for all of the configuration files (amongst other things) so I can just enter their name (or an abbreviation) & they are loaded in nano ready for reference or editing, like so:

alias bashrc="nano ~/.bashrc"

& so:

alias rc.conf="sudo nano /etc/rc.conf"


When I installed ArchBang, I copied over many config files from my other Arch machine (editing where appropriate). The .bashrc of course being one of them, so there may be some ArchBang style specifics missing from my .bashrc that I'm unaware of.

This is not a problem as if you see anything that you like in someone's posted .bashrc , you can take that out & add it into yours with no negative side effects,  providing you have the command on your machine of course.

My .bashrc file follows. Please keep in mind that my .bashrc is a relatively very simple one, there are Bash scripters that write complex functions into their .bashrc & do many things that I have no need for, &/or don't understand. So just know that your .bashrc has the potential to be immensely powerful to those that know how to tap into that power, so please consider this to be a simple introduction. smile



## ~/.bashrc


alias ls='ls --color=auto'

eval `dircolors -b`

#PS1='[\u@\h \W]\$ '

PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[m\] \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\] '

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi


# Aliases to save time & typing:
#-------------------------------

alias al="alias"   
alias ll="ls -lh"
alias llm="ls -lh"
alias la="ls -a"
alias lam="ls -a"
alias exit="clear; exit"
alias x="startx"
alias h="htop"
alias a="alsamixer"
alias m="sudo mount -a"
alias um="sudo umount 192.168.1.15:/media"
alias ub="sudo umount 192.168.1.15:/backup"
alias network="sudo /etc/rc.d/network restart"
alias netfix="sudo dhcpcd eth0"
alias removedir="sudo rm -rf" ### removes directories & their contents ###
alias rmfile="sudo find / -name ".AppleDB" -depth -exec rm -rf {} \;"


# GPU stuff:
#-----------

alias gl="glxinfo | grep -i opengl && glxgears"
alias mgl="LIBGL_DRIVERS_PATH=/usr/lib/xorg/modules/dri_g/ glxinfo |grep -i opengl && glxgears"
alias drm="dmesg | grep drm"


# Screenshot (Function as command would not run as an alias):
#------------------------------------------------------------
 
function shot
{
scrot '%T_$wx$h_scrot.png' -c -d 5 -e 'mv $f /home/handy/data/.pics/.shots'
}


# Handbrake & associated:
#------------------------

alias .tmp="cd /mnt/store/pkg/vid/.tmp"

# The following alias doesn't do anything but echo the looong
# command to the Terminal window where it can be copied, pasted & edited for use:
alias hb="echo HandBrakeCLI -t 0 -i /media/dvd -o NAME.HERE.mp4 -e x264 -b 1000 -B 192 -s 1 --subtitle-burn"

alias hbhelp="HandBrakeCLI --help"


# Quick call for Nano & major conf files:
#----------------------------------------

alias rc.conf="sudo nano /etc/rc.conf"
alias pacman.conf="sudo nano /etc/pacman.conf"
alias menu.lst="sudo nano /boot/grub/menu.lst"
alias fstab="sudo nano /etc/fstab"
alias bashrc="nano ~/.bashrc"
alias rc.local="sudo nano /etc/rc.local"  ### where I can call files during the boot process
alias xinitrc="nano ~/.xinitrc"
alias mkinit="sudo nano /etc/mkinitcpio.conf"
alias inittab="sudo nano /etc/inittab"


# Python:
#--------

alias mypy="cd ~/documents/.mypy"
alias p3="python3"
alias i3="idle3"


# DOTPAC - cleans up .pac* files:
#--------------------------------

alias pac="locate *.pac*"
# following is just for my memory regarding the wondrous dotpac :) :
alias delete.pacsave="dotpac"  


# Package Management:
#--------------------

# Reflector creates a set number of the most up to date & fastest repo mirrors:
alias mirror="sudo reflector -l 12 --sort rate --save /etc/pacman.d/mirrorlist"

# Creates a list of all installed packages:
alias pkglist="comm -13 <(pacman -Qmq | sort) <(pacman -Qqe | sort) > pkglist"

# Lets you search through all available packages simply using 'pacsearch packagename':
alias pacsearch="pacman -Sl | cut -d' ' -f2 | grep "

# sudo pacman -Syu by typing pSyu (sudo must be installed and configured first):
alias pSyu="sudo pacman -Syu"

# pacman -S by typing pS :
alias pS="sudo pacman -S"

# pacman -Rsn  ,which fully deletes packages - including dependencies & config files 
alias pdelete="sudo pacman -Rsn"

# pacman -Syy ,this forces a refresh of all package lists:
alias refresh="sudo pacman -Syy"

# cacheclean -v 2 ,deletes all but the last 2 versions of installed packages the pacman cache:
alias c-c="sudo cacheclean -v 2"

# pacman -U ,installs package from specified location on disk,
# usually /var/cache/pacman/pkg/ following command will
# echo command to Terminal where it can be copied, have the
# file name added & used:
alias pU="echo sudo pacman -U /var/cache/pacman/pkg/-file name here-"

### packer -Syu --aur equivelent by typing aur :
alias aur="packer -Syu"

### packer -S by typing pkS :
alias pkS="packer -S"

# yaourt -Syu by typing yaur :
alias yaur="sudo yaourt -Syu --aur"

# yaourt -S by typing yS :
alias yS="sudo yaourt -S"

# yaourt -Rsn , which fully deletes packages - see above :
alias ydelete="sudo yaourt -Rsn"


# colorized pacman output with pacs alias:
#-----------------------------------------

alias pacs="pacsearch"
pacsearch() {
   echo -e "$(pacman -Ss "$@" | sed \
        -e 's#^core/.*#\\033[1;31m&\\033[0;37m#g' \
        -e 's#^extra/.*#\\033[0;32m&\\033[0;37m#g' \
        -e 's#^community/.*#\\033[1;35m&\\033[0;37m#g' \
        -e 's#^.*/.* [0-9].*#\\033[0;36m&\\033[0;37m#g' ) \
        \033[0m"
}

Something you may have noticed in my .bashrc above, is that you can use an alias to echo a complex command to the Terminal, which gives you the ability to then copy & paste it to the command line where you can then edit it appropriately - hit the enter key & run it. I find this most useful for using HandBrakeCLI in particular & also for using pacman -U on the odd occasion that it is necessary.

Last edited by handy (2011-11-26 21:20:05)

Offline

#2 2011-11-26 05:56:08

pablokal
Administrator
From: Nijmegen, Holland
Registered: 2010-10-12
Posts: 3,596
Website

Re: ~/.bashrc - What can/does it do for you?

Nice initiative, Handy.
I don't use alias myself because I'm always too lazy to set it up ;-)
Nice addition for the Wiki, I would say.

I'm curious with what bashrc. others will turn up.

This is for the affectionados of bashrc, the ultimate bashrc:
http://gnome-look.org/content/show.php/?content=129746

I don't recommend using it for it is debian based but it is full of ideas and solutions.
Archwiki: https://wiki.archlinux.org/index.php/Ba … figuration
Also the Arch forum has a thread where people exchange their bashrc files and ideas: https://bbs.archlinux.org/viewtopic.php?id=21556

Nice pacman aliases:

#Pacman shortcuts
alias p="pacman" 
alias pQ="pacman -Q"
alias pqs="pacman -Qs" 
alias pqi="pacman -Qi"
alias pS="sudo pacman -S"
alias psyu="sudo pacman -Syu"
alias psi="pacman -Si"
alias pR="sudo pacman -R"
alias prc="sudo pacman -Rc"
alias prs="sudo pacman -Rs"
alias prsc="sudo pacman -Rsc"
alias pA="sudo pacman -A"
alias pU="sudo pacman -U"
alias pO="sudo pacman-optimize"
#Colorful pacman -Ss output
pss () {
       echo -e "$(pacman -Ss $@ | sed 
       -e 's#current/.*#\033[1;31m&\033[0;37m#g' 
       -e 's#extra/.*#\033[0;32m&\033[0;37m#g' 
       -e 's#community/.*#\033[1;35m&\033[0;37m#g' 
       -e 's#^.*/.* [0-9].*#\033[0;36m&\033[0;37m#g' )"
}

This is nice about mounting via udev: https://bbs.archlinux.org/viewtopic.php … 87#p859887


Getting your questions answered here at ArchBang Forums
Please! Always give hardware info, if there is a chance that 's relevant: #lspci -vnn
On Arch(bang) and Openbox: http://stillstup.blogspot.com/

Offline

#3 2011-11-26 06:11:56

ArchVortex
Retired
From: Bali
Registered: 2011-04-01
Posts: 1,464

Re: ~/.bashrc - What can/does it do for you?

Thanks Handy for starting this after it being mentioned on another thread. I've "sticky"ed it and hopefully others will learn and share on this thread. Much appreciated that you spent the time to write this and that you're spending time away from the Arch Forum and hanging out over here. Thanks so much!!


You have the capacity to learn from mistakes. You'll learn a lot today.
FP:E5F8 7DBA 8128 9ACB 75F7 7279 BE34 AB66 76D9 16DE
KEY ID:76D916DE
Currently running ArchBang / LinuxBBQ / Funtoo (FunBang?) / FreeBSD / SlackBang Current 14.2

Offline

#4 2011-11-26 08:44:33

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,692

Re: ~/.bashrc - What can/does it do for you?

quick note that once you edit .bashrc do source ~/.bashrc to get new additions working

alias coma='more ~/.bashrc | grep alias'

Also have read that simply typing alias in a terminal will give a list of commands


Comments, suggestions, donations please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#5 2011-11-26 17:58:19

oliver
Administrator
Registered: 2010-11-04
Posts: 2,209

Re: ~/.bashrc - What can/does it do for you?

.:Mr Green:. wrote:
alias coma='more ~/.bashrc | grep alias'

Also have read that simply typing alias in a terminal will give a list of commands


I'm an easy going person (I think) but a couple of things tweak my OCD :-)

1) redundant commands
2) 'useless uses of cat or more'

I'm afraid you've triggered them both in one command :-)

Don't take this as a criticism, because what you've written works perfectly, it just uses two system calls (more and grep) when one will do (grep)

$ grep alias ~/,bashrc

The real kicker is that 'alias' already does it (and you've noted that)

FWIW, you can unalias a command too... with, quite unsurprisingly, 'unalias <alias>'

Offline

#6 2011-11-26 20:41:38

handy
Member
Registered: 2011-11-03
Posts: 501

Re: ~/.bashrc - What can/does it do for you?

ArchVortex wrote:

Thanks Handy for starting this after it being mentioned on another thread. I've "sticky"ed it and hopefully others will learn and share on this thread. Much appreciated that you spent the time to write this and that you're spending time away from the Arch Forum and hanging out over here. Thanks so much!!

My pleasure. smile

I don't spend much time on the Arch forum these days, only when I need to really. Though I'm always logged in there when one of my machines are on line as I like to watch Perry3D's thread on the open AMD/ATi driver stack, though that thread is incredibly quiet these days as there really hasn't been any problems being faced by users of the git stack for some time now. Which is nice.


@pablokal: It doesn't take long to copy some aliases over & then modify them to suit yourself. smile

__________

[edit:] I modified the OP a little in the interest of clarity & also added some to the bottom of it on the wonderful shortcut ability to echo complex commands to the Terminal via an alias, after which you can copy/paste edit & run them.

[edit2:] & I just added a new alias:

alias al="alias"

I thought oliver might like it... wink

Last edited by handy (2011-11-26 21:21:01)

Offline

#7 2011-11-27 01:37:58

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,692

Re: ~/.bashrc - What can/does it do for you?

oliver wrote:

I'm an easy going person (I think) but a couple of things tweak my OCD :-)

1) redundant commands
2) 'useless uses of cat or more'

I'm afraid you've triggered them both in one command :-)

Don't take this as a criticism, because what you've written works perfectly, it just uses two system calls (more and grep) when one will do (grep)

$ grep alias ~/,bashrc

The real kicker is that 'alias' already does it (and you've noted that)

FWIW, you can unalias a command too... with, quite unsurprisingly, 'unalias <alias>'

Well I have to keep you on your toes smile so used to using <command> | grep <foo> find it hard to change but I know with your help I will be a bash ninja in no time...


Comments, suggestions, donations please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#8 2011-11-27 05:28:56

jfb3
Member
From: Jakarta, Indonesia
Registered: 2011-11-08
Posts: 47

Re: ~/.bashrc - What can/does it do for you?

In /etc/bash.bashrc   {so every user gets the benefits including root}:

# Red for root, Green for user
NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
   PS1="$RED\u[$NORMAL\w$RED]# $NORMAL"  
else
   PS1="$GREEN\u[$NORMAL\w$GREEN]# $NORMAL"  
fi


alias ls="ls --color=auto"
alias less="less -R"

alias   lsa="ls -alh --color=always"
alias   lsl="lsa | less"
alias  lsdf="lsa --group-directories-first" 
alias lsdfl="lsa --group-directories-firsti | less" 

alias Locate="locate"
alias locate="locate -i"

alias  grep="grep --color=always"
alias egrep="egrep --color=always"
alias fgrep="fgrep --color=always"

alias cdc="clear;date;cal"

alias showmounted="mount | column -t"
alias syncdatetime="ntpdate -u 2.pool.ntp.org; sudo hwclock -w"

#-------------------------------------------------------------------------
# Less Colors for Man Pages
export LESS_TERMCAP_mb=$'\E[01;31m'       # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m'  # begin bold
export LESS_TERMCAP_me=$'\E[0m'           # end mode
export LESS_TERMCAP_se=$'\E[0m'           # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;246m'    # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m'           # end underline
export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline
#-------------------------------------------------------------------------

More complicated things go into scripts in my ~/Utilities folder.  {Password generator, trash emptiers, wallpaper changers, etc)

Offline

#9 2011-11-27 08:02:47

oliver
Administrator
Registered: 2010-11-04
Posts: 2,209

Re: ~/.bashrc - What can/does it do for you?

.:Mr Green:. wrote:

Well I have to keep you on your toes smile so used to using <command> | grep <foo> find it hard to change but I know with your help I will be a bash ninja in no time...

logically, that makes sense... first you learn how to view a file (cat/more/less) and then you learn how to build commands with | and filter stuff out with grep... and I'm sure it's something we all do occasionally.  But just as I like my CDs sorted in chronological order I like my commands as efficient as possible.  And I'm 100% certain there are tons of things I do that could be improved upon so please bring them up when you see them

Offline

#10 2011-11-27 08:04:14

oliver
Administrator
Registered: 2010-11-04
Posts: 2,209

Re: ~/.bashrc - What can/does it do for you?

handy wrote:

alias al="alias"

I thought oliver might like it... wink

My favourite one was a function someone wrote for .bashrc that timed how long a command took.  The thing was about 15 lines of code and then someone piped up with "why don't you use 'time <command>'?"

Offline

#11 2011-11-27 11:48:38

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,692

Re: ~/.bashrc - What can/does it do for you?

functions now that is a whole new thread smile


Comments, suggestions, donations please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#12 2011-11-28 04:34:49

handy
Member
Registered: 2011-11-03
Posts: 501

Re: ~/.bashrc - What can/does it do for you?

Mr Green wrote:

functions now that is a whole new thread smile

You think?

I have a simple one in my .bashrc , for no other reason than scrot wouldn't run via an alias. Some people write some incredible functions that they use in their .bashrc or /etc/bash.bashrc .

I don't really have a need for them, so I don't include them in mine.

Last edited by handy (2011-11-28 04:35:23)

Offline

#13 2011-11-28 06:38:37

ratcheer
Member
Registered: 2011-10-08
Posts: 114

Re: ~/.bashrc - What can/does it do for you?

Heh. I just discovered .bashrc this morning. I added "set -o vi" to root's .profile, tested it, and it did not work. So I poked around in root's home, found .bashrc, added it there, and it worked perfectly.

There are so many slight differences between distros. I've used Solatis and HP-UX for years and could always depend on .profile. The same on Ubuntu. Not anymore, I guess.

Tim

Offline

#14 2011-11-28 08:10:02

oliver
Administrator
Registered: 2010-11-04
Posts: 2,209

Re: ~/.bashrc - What can/does it do for you?

ratcheer wrote:

Heh. I just discovered .bashrc this morning. I added "set -o vi" to root's .profile, tested it, and it did not work. So I poked around in root's home, found .bashrc, added it there, and it worked perfectly.

There are so many slight differences between distros. I've used Solatis and HP-UX for years and could always depend on .profile. The same on Ubuntu. Not anymore, I guess.

Tim

.profile is for korn shell (maybe bourne too, I don't remember)... ksh used to be the default for solaris - maybe it still is but they at least started including bash a while back

You could always add a line to source .profile in the .bashrc file

Offline

#15 2011-11-28 08:30:11

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,692

Re: ~/.bashrc - What can/does it do for you?

Some people source .bash_aliases keep them separate from other bash stuff ....


Comments, suggestions, donations please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#16 2011-11-28 19:43:35

oliver
Administrator
Registered: 2010-11-04
Posts: 2,209

Re: ~/.bashrc - What can/does it do for you?

Mr Green wrote:

Some people source .bash_aliases keep them separate from other bash stuff ....

ppfj.jpg

SPLITTERS!

Offline

#17 2011-11-28 19:45:58

handy
Member
Registered: 2011-11-03
Posts: 501

Re: ~/.bashrc - What can/does it do for you?

Followers of the sandal...

Offline

#18 2012-01-31 11:03:30

ArchVortex
Retired
From: Bali
Registered: 2011-04-01
Posts: 1,464

Re: ~/.bashrc - What can/does it do for you?

For you bash ninjas  http://www.bashoneliners.com/


You have the capacity to learn from mistakes. You'll learn a lot today.
FP:E5F8 7DBA 8128 9ACB 75F7 7279 BE34 AB66 76D9 16DE
KEY ID:76D916DE
Currently running ArchBang / LinuxBBQ / Funtoo (FunBang?) / FreeBSD / SlackBang Current 14.2

Offline

#19 2012-07-13 11:33:58

lspci
Member
Registered: 2012-07-13
Posts: 3

Re: ~/.bashrc - What can/does it do for you?

Here's my ~/.bashrc and my /etc/bash.bashrc files

# ~/.bashrc
#

export EDITOR="vim"
export lcffi="/home/gm/quicklisp/dists/quicklisp/software/cffi_0.10.7.1"
# If not running interactively, don't do anything

[[ $- != *i* ]] && return

# clear
alias claer='clear' # I keep misspelling it.  
alias cls='clear'

# sed 


# ls 

alias ls='ls --color=auto'
alias ls..='ls ..'
alias lr='ls -R' 	# recursive ls
alias ll='ls -l'
alias la='ls -a'
alias lla='ll -a'
alias llA='ll -A'
alias llx='ll -BX'
alias llz='ll -rS'
alias lx='ls -BX'	# sort by extension 
alias lz='ls -rS'	# sort by size 
alias lt='ls -rt'	# sort by date
alias lm='ls | less'	# cool way of displaying the contents of a folder
alias lf='ls -hF'
alias lu='ls -U'
alias ls2="ls -xl" 

# killall 
alias k911='killit stumpwm'
alias killit='killall -s KILL'
alias ka='killall '
alias kK='killall -s KILL'
alias kT='killall -s TERM'
alias kA='killall -s ABRT'
alias kS='killall -s STOP'
alias kQ='killall -s QUIT'


# dir

alias dir='dir --color=auto'
alias dir..='dir ..'
alias dira='dir -a'
alias dirf='dir -F'
alias dirg='dir -g'
alias dirH='dir -H'
alias dirh='dir -h'
alias dirr='dir -R'
alias dirs='dir -s'
alias dirS='dir -S'
alias diru='dir -U'
alias dir1='dir -1'


# cd 

alias cd..="cd .."
alias co='cd "$OLDPWD"'
#alias ..='cd..'
alias cd.='cd .'
#alias .='cd.'
alias cd....='cd .. ..'
alias cd......='cd .. .. ..'
alias cd........='cd .. .. .. ..'
alias cd..........='cd .. .. .. .. ..'
alias cd............='cd .. .. .. .. .. ..'

# packer & pacman
alias pacman.nc='/usr/bin/pacman'
alias pacman='pacman-color' 
alias p='sudo pacman'
alias pp='packer'
alias ppsearch='packer -Ss'
alias psearch='p -Ss'
alias piocal='p -U'
alias ppiort='packer -S'
alias piort='p -S'
alias ppskip='packer --skipinteg'
alias pupdate='p -Sy'
alias ppupgrade='packer -Syu'
alias pupgrade='p -Syu'
alias premove='p -R'
alias ppremove='p -R'
alias ppupdate='packer -Syu'
alias pinstall='piort'
alias ppinstall='ppiort'

# clear

alias cls='clear'

# sh *

alias rns='sh $1' 

# repo-add 

alias lark-update='repo-add /home/pkgs/lark/lark.db.tar.gz /home/pkgs/lark/*.tar.*'

# wmhandler

alias wmhandler='sh ~/:B/wmhandler.sh'

# wine

alias wineld='LIBGL_DRIVERS_PATH=/usr/lib32/xorg/modules/dri wine'

# Games
    # Minesweeper
alias minesweeper='wine ~/dos/winmine.exe'
alias winmine='wine ~/dos/winmine.exe'
alias minesweep='wine ~/dos/winmine.exe'
alias minesw='wine ~/dos/winmine.exe'
	# Starcraft
alias sc='wine ~/dos/Starcraft/StarCraft.exe'
alias SC='sc'
alias starcraft='wine ~/dos/Starcraft/StarCraft.exe'
#alias StarCraft='wine ~/dos/Starcraft/StarCraft.exe'
alias Starcraft='wine ~/dos/Starcraft/StarCraft.exe'

	# Warcraft
alias wc='dosbox ~/dos/Warcraft/WAR.EXE'	
alias WC='dosbox ~/dos/Warcraft/WAR.EXE'
alias warcraft='dosbox ~/dos/Warcraft/WAR.EXE'
alias Warcraft='warcraft'
alias WarCraft='warcraft'

# Applications
	
	# Skype

alias skype="LD_PRELOAD=/usr/lib32/libv4l/v4l1compat.so skype"

	# Zinit

alias zinit="sh ~/zinit.sh"

	# Wine
alias wine='LIBGL_DRIVERS_PATH=/usr/lib32/xorg/modules/dri wine'

	# Backup Script
alias backup='sudo sh ~/:B/backup.sh'

	# Calis, the AI
alias calis='clisp "~/:B/Calis/calis.lisp"'
alias Calis='calis'

	# 688I Hunter Killer Sub Game
alias subgame='wine ~/hk6/688I_HK.exe'

    # pSX-select
alias pSX-select='sh ~/:B/psx-select.sh'
alias psx-select='sh ~/:B/psx-select.sh'
    # Stumpwm
#alias stumpwm='/home/gm/Downloads/Hacking/quicklisp/stumpwm/stumpwm'

    # xterm -display :1
alias xterm1='xterm -display :1 &'
    
    # Xnest & Xephyr
alias xnest1='Xnest :1 &'
alias xephyr='Xephyr :1 &'

    # Xnesting
alias subX='xnest1 xterm1'

# colors 
###############################

txtblk='\e[0;30m' # Black
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m'   # Black - Background
bakred='\e[41m'   # Red
bakgrn='\e[42m'   # Green
bakylw='\e[43m'   # Yellow
bakblu='\e[44m'   # Blue
bakpur='\e[45m'   # Purple
bakcyn='\e[46m'   # Cyan
bakwht='\e[47m'   # White
txtrst='\e[0m'    # Text Reset
###############################
# effects
###############################

txtblink='\e[5m' # Blink
txtbold='\e[1m'  # Bold

###############################
#  Bash prompts
# Bash allows these prompt strings to be customized by inserting a
# number of backslash-escaped special characters that are
# decoded as follows:
#
# \a         an ASCII bell character (07)
# \d         the date in "Weekday Month Date" format (e.g., "Tue May 26")
# \D{format} the format is passed to strftime(3) and the result is inserted into the prompt string an empty format results in a locale-specific time representation The braces are required
# \e         an ASCII escape character (033)
# \h         the hostname up to the first `.'
# \H         the hostname
# \j         the number of jobs currently managed by the shell
# \l         the basename of the shell's terminal device name
# \n         newline
# \r         carriage return
# \s         the name of the shell, the basename of $0 (the portion following
#                                                                           the final slash)
# \t         the current time in 24-hour HH:MM:SS format
# \T         the current time in 12-hour HH:MM:SS format
# \@         the current time in 12-hour am/pm format
# \A         the current time in 24-hour HH:MM format
# \u         the username of the current user
# \v         the version of bash (e.g., 2.00)
# \V         the release of bash, version + patch level (e.g., 2.00.0)
# \w         the current working directory, with $HOME abbreviated with a tilde
# \W         the basename of the current working directory, with $HOME
#                                       abbreviated with a tilde
# \!         the history number of this command
# \#         the command number of this command
# \$         if the effective UID is 0, a #, otherwise a $
# \nnn       the character corresponding to the octal number nnn
# \\         a backslash
# \[         begin a sequence of non-printing characters, which could be used
#                            to embed a terminal control sequence into the prompt
# \]         end a sequence of non-printing characters

PS1='[\u@\h \W]\$ '

# PS1='(\e[1;34m * \e[0m$TERM\e[1;34m * \e[0m)\(\D{%I}\e[5m:\e[0m\D{%M %p})\n[\u@\h \W]( \e[1;31m\#\e[0;0m )\$ '
# \n\e[4;32m[[
#= ]]\e[0m\n
# \e[1;33m\s-\v\e[0;0m\n
PS5='[\#]> ' 
# '#4e9a06'
PS6='\n'

#declare PS5=''
#PS5='\H'

#PS1='[\e[1;34m * \e[0m$TERM\e[0m\e[1;34m * \e[0m\D{%I}:\D{%M %p} \n\u@\h \W]( \e[1;31m\#\e[0m )\$ '

# End of File
# /etc/bash.bashrc
#

export EDITOR="vim"

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h \W]\$ '
PS2='> '
PS3='> '
PS4='+ '

alias cd..="cd .."
alias ls="ls --color=auto"
alias dir="dir --color=auto"
alias dir..="dir .."
alias ls..="ls .."
alias vi="vim"



case ${TERM} in
  xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
                                                        
    ;;
  screen)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
    ;;
esac

[ -r /usr/share/bash-completion/bash_completion   ] && . /usr/share/bash-completion/bash_completion

# End of File

lol lol, just noticed that some of the aliases in my ~/.bashrc are iterated twice or more.

Last edited by lspci (2012-07-13 11:36:16)

Offline

#20 2013-05-29 00:04:59

barchi
Member
From: Leipzig, Germany
Registered: 2011-02-08
Posts: 64

Re: ~/.bashrc - What can/does it do for you?

hi there,

nice idea to post this. I think it became quite silent in here, there must be more users using aliases.
Here is my .bashrc, pretty short but usefull for me:

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return


export EDITOR=nano

alias pq='pacman -Q'
alias blame='sudo systemd-analyze blame && systemd-analyze'
alias jctl='sudo journalctl > journal.txt'
alias cpu='grep MHz /proc/cpuinfo'
alias upd='sudo pacman -Syy'
alias upg='sudo pacman -Syu'
alias pas='sudo pacman -Ss'
alias yas='yaourt -Ss'
alias yinst='yaourt -S'
alias inst='sudo pacman -S'
alias deinst='sudo pacman -Rs'
alias clean='sudo pacman -Scc'
alias ls='ls --color=auto'
alias uuid='sudo blkid -c /dev/null'
alias mc='sudo mc'
alias visudo='sudo visudo'
alias cls='clear'
alias mp='makepkg -s'
alias qdt='sudo pacman -Qdt'
alias rqdt='sudo pacman -Rns $(pacman -Qdtq)'
alias ydl='youtube-dl '

PS1="\[\e[01;31m\]┌─[\[\e[01;35m\u\e[01;31m\]]──[\[\e[00;37m\]${HOSTNAME%%.*}\[\e[01;32m\]]:\w$\[\e[01;31m\]\n\[\e[01;31m\]└──\[\e[01;36m\]>>\[\e[0m\]"

Offline

#21 2013-05-29 00:25:25

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,692

Re: ~/.bashrc - What can/does it do for you?

alias cls='clear'

Do not forget you can use Control+l to clear screen


Comments, suggestions, donations please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#22 2013-05-29 00:33:11

barchi
Member
From: Leipzig, Germany
Registered: 2011-02-08
Posts: 64

Re: ~/.bashrc - What can/does it do for you?

Control+l

nice one wink

Offline

#23 2013-05-29 00:39:56

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,692

Re: ~/.bashrc - What can/does it do for you?

@barchi might use some of your aliases, do not forget pacman -Qm wink


Comments, suggestions, donations please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#24 2013-05-29 01:44:47

handy
Member
Registered: 2011-11-03
Posts: 501

Re: ~/.bashrc - What can/does it do for you?

My script evolved some more as shown over here & some other people presented some good stuff too. Though it isn't a particularly popular topic as most people prefer to point & click. wink

http://forum.manjaro.org/index.php?topic=995.0

Offline

#25 2013-05-29 06:21:41

barchi
Member
From: Leipzig, Germany
Registered: 2011-02-08
Posts: 64

Re: ~/.bashrc - What can/does it do for you?

thats a nice .bashrc to have.
I saw that you also use aliases to edit system files, this reminds me about my post 2 years ago.
Just the openbox menu entries to edit some system files, for the ones who are even too lazy to type the alias wink

Offline

#26 2013-06-10 00:27:54

lebec
Member
Registered: 2013-06-07
Posts: 19

Re: ~/.bashrc - What can/does it do for you?

# clear
alias claer='clear' # I keep misspelling it.  
alias cls='clear'


Love it!
'S'like, alias-gin for the cyslexid!

Last edited by lebec (2013-06-10 00:51:05)


"I have an ocean to drink; therefore there is an ocean."
-Sam Beckett: a pure draught of elegant pessimism.
------------------------------------------------------------------------
ArchBang with 8G Memory and Seagate Hybrid HDD

Offline

#27 2013-06-10 00:36:00

lebec
Member
Registered: 2013-06-07
Posts: 19

Re: ~/.bashrc - What can/does it do for you?

handy wrote:

My script evolved some more as shown over here & some other people presented some good stuff too. Though it isn't a particularly popular topic as most people prefer to point & click. wink

http://forum.manjaro.org/index.php?topic=995.0

Hello Handy,
Great thread with lovely scripts, just about all of which I've incorporated into my .bashrc.

I shot over and had a look at the other forum you refer to, and found this line from one of your posts there:

"I forget commands, hell, I forget aliases, so I just type "bashrc" into my always open Terminal (on its own specified desktop from Openbox start-up) where I refresh my memory. smile"

from which I snip the following: "always open Terminal (on its own specified desktop from Openbox start-up) " in order to ask you if you could please explain how to do this? I want one of them! :0))

Thanks again,
cheers,
lebec
@DarkDuck


"I have an ocean to drink; therefore there is an ocean."
-Sam Beckett: a pure draught of elegant pessimism.
------------------------------------------------------------------------
ArchBang with 8G Memory and Seagate Hybrid HDD

Offline

#28 2013-06-10 00:53:44

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,692

Re: ~/.bashrc - What can/does it do for you?

An easier way is to type alias in a terminal and you will see what you can set up in .bashrc, this of course does work work with any functions you may have but that is not too difficult to figure out.


Comments, suggestions, donations please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#29 2013-06-10 07:36:44

lebec
Member
Registered: 2013-06-07
Posts: 19

Re: ~/.bashrc - What can/does it do for you?

handy wrote:

My script evolved some more as shown over here & some other people presented some good stuff too. Though it isn't a particularly popular topic as most people prefer to point & click. wink

http://forum.manjaro.org/index.php?topic=995.0

Hello Handy,
Great thread with lovely scripts, just about all of which I've incorporated into my .bashrc.

I shot over and had a look at the other forum you refer to, and found this line from one of your posts there:

"I forget commands, hell, I forget aliases, so I just type "bashrc" into my always open Terminal (on its own specified desktop from Openbox start-up) where I refresh my memory. smile"

from which I snip the following: "always open Terminal (on its own specified desktop from Openbox start-up) " in order to ask you if you could please explain how to do this? I want one of them! :0))

Thanks again,
cheers,
lebec
@DarkDuck


"I have an ocean to drink; therefore there is an ocean."
-Sam Beckett: a pure draught of elegant pessimism.
------------------------------------------------------------------------
ArchBang with 8G Memory and Seagate Hybrid HDD

Offline

#30 2013-06-10 21:42:40

handy
Member
Registered: 2011-11-03
Posts: 501

Re: ~/.bashrc - What can/does it do for you?

Hi there lebec, thanks for the compliments.

You need to call whichever program you want Openbox to start in the ~/.config/openbox/autostart file, like so:

sakura &

Don't forget to stick the & on the end of the command or your autostart file will stick there.

Doing the above will cause any & all files that open in a window on the desktop, like Firefox, Sakura, whatever file manager & such to open on Desktop 1. All on top of each other.

You can fix this by editing your ~/.config/openbox/rc.xml file. Following is the end of my rc.xml which has control for some files that I am not currently starting in the autostart file. This doesn't matter, rc.xml doesn't care about that.

  # end of the example
-->
    <application class="Qbittorrent">
      <desktop>6</desktop>
    </application>
    <application class="Sakura">
      <desktop>5</desktop>
      <maximized>yes</maximized>
    </application>
    <application class="Terminator">
      <desktop>4</desktop>
      <maximized>yes</maximized>
    </application>
    <application class="Worker">
      <desktop>3</desktop>
      <maximized>yes</maximized>
    </application>
    <application class="Firefox">
      <desktop>1</desktop>
      <maximized>yes</maximized>
      <focus>yes</focus>
    </application>
  </applications>
</openbox_config>

If a file doesn't do what you want it to re. opening on the chosen desktop, then it will be due to its name being wrong. Try upper & lower case for the first letter of the name & such. There is a bash command which will tell you what the name is that you need, but I've forgotten what it is. It can be found somewhere in on the Openbox site. Good luck with finding it in a hurry. wink

Hope that helps.

On seeing your aliases, you can just type alias in the Terminal & get a list, but you don't get any little stories you wrote to go with them. smile

Have fun...

Offline

#31 2013-06-12 00:56:22

lebec
Member
Registered: 2013-06-07
Posts: 19

Re: ~/.bashrc - What can/does it do for you?

Cheers Handy;
I'm on it!


"I have an ocean to drink; therefore there is an ocean."
-Sam Beckett: a pure draught of elegant pessimism.
------------------------------------------------------------------------
ArchBang with 8G Memory and Seagate Hybrid HDD

Offline

#32 2013-06-22 10:37:15

barchi
Member
From: Leipzig, Germany
Registered: 2011-02-08
Posts: 64

Re: ~/.bashrc - What can/does it do for you?

my latest...

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

export EDITOR=nano

#pacman stuff:
alias pq='pacman -Q'
alias pqi='pacman -Qi'
alias plog='sudo leafpad /var/log/pacman.log'
alias upd='sudo pacman -Syy'
alias upg='sudo pacman -Syu'
alias pas='sudo pacman -Ss'
alias yas='yaourt -Ss'
alias yinst='yaourt -S'
alias inst='sudo pacman -S'
alias deinst='sudo pacman -Rs'
alias clean='sudo pacman -Scc'
alias qdt='sudo pacman -Qdt'
alias rqdt='sudo pacman -Rns $(pacman -Qdtq)'


#system configs & infos:
alias blame='sudo systemd-analyze blame && systemd-analyze'
alias jctl='sudo journalctl > journal.txt'
alias cpu='grep MHz /proc/cpuinfo && sensors'
alias uuid='sudo blkid -c /dev/null'
alias visudo='sudo visudo'


#programs & tools:
alias mc='sudo mc'
alias ydl='youtube-dl '
alias mp='makepkg -s'
alias vboxdrv='sudo modprobe vboxdrv'
alias ls='ls --color=auto'
alias cls='clear'

PS1="\[\e[01;31m\]┌─[\[\e[01;35m\u\e[01;31m\]]@[\[\e[00;37m\]${HOSTNAME%%.*}\[\e[01;32m\]]:\w$\[\e[01;31m\]\n\[\e[01;31m\]└──\[\e[01;36m\]>>\[\e[0m\]"

Offline

#33 2013-06-22 11:10:17

scjet
Member
From: Canada
Registered: 2010-12-01
Posts: 1,463

Re: ~/.bashrc - What can/does it do for you?

Just chiming in, many nice tips n' tricks with the .bashrc's here. Thanks all.
@barchi I like your latest, also,  'it's very "~/.hashrc"
wink
..., simple sys-admin shortcuts like these never cease to amaze me in L/unix.

I love you guys.

Last edited by scjet (2013-06-22 11:50:34)

Offline

#34 2013-06-22 12:11:15

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,692

Re: ~/.bashrc - What can/does it do for you?

Please do not forget you can use functions in .bashrc for extra command line power....


Comments, suggestions, donations please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#35 2013-06-22 18:38:35

handy
Member
Registered: 2011-11-03
Posts: 501

Re: ~/.bashrc - What can/does it do for you?

Mine looks like this these days:

if [ -f /etc/bash_completion ]; then	# bash_completion can be used in 
	    . /etc/bash_completion	# sophisticated ways beyond my understanding. 
fi					# Even though I've installed the external 
					# bash-completion package the internal 
					# bash_completion should remain. 

export SDL_AUDIODRIVER=pulseaudio	# trying to get UT2K4 to have sound.

archey	 				# calls Archey3 (python3 version) which
					# shows basic system info in the Terminsl.

xhost +local:root > /dev/null 2>&1	# sudo & X magic :)


alias bbak="cp ~/.bashrc ~/.bashrc.bak"	# backs up ~/.bashrc to ~/.bashrc.bak

alias src="source .bashrc"		# reinitialises the Terminal so as to 
					# be able to use any changes made to .bashrc


#========================================
# The following allows the use of names instead of the colour codes when working with
# console colours for whatever reason e.g. prompts or ncurses stuff
#----------------------------------------
# Reset
Color_Off='\e[0m'       # Text Reset

# Regular Colors
Black='\e[0;30m'        # Black
Red='\e[0;31m'          # Red
Green='\e[0;32m'        # Green
Yellow='\e[0;33m'       # Yellow
Blue='\e[0;34m'         # Blue
Purple='\e[0;35m'       # Purple
Cyan='\e[0;36m'         # Cyan
White='\e[0;37m'        # White

# Bold
BBlack='\e[1;30m'       # Black
BRed='\e[1;31m'         # Red
BGreen='\e[1;32m'       # Green
BYellow='\e[1;33m'      # Yellow
BBlue='\e[1;34m'        # Blue
BPurple='\e[1;35m'      # Purple
BCyan='\e[1;36m'        # Cyan
BWhite='\e[1;37m'       # White

# Underline
UBlack='\e[4;30m'       # Black
URed='\e[4;31m'         # Red
UGreen='\e[4;32m'       # Green
UYellow='\e[4;33m'      # Yellow
UBlue='\e[4;34m'        # Blue
UPurple='\e[4;35m'      # Purple
UCyan='\e[4;36m'        # Cyan
UWhite='\e[4;37m'       # White

# Background
On_Black='\e[40m'       # Black
On_Red='\e[41m'         # Red
On_Green='\e[42m'       # Green
On_Yellow='\e[43m'      # Yellow
On_Blue='\e[44m'        # Blue
On_Purple='\e[45m'      # Purple
On_Cyan='\e[46m'        # Cyan
On_White='\e[47m'       # White

# High Intensity
IBlack='\e[0;90m'       # Black
IRed='\e[0;91m'         # Red
IGreen='\e[0;92m'       # Green
IYellow='\e[0;93m'      # Yellow
IBlue='\e[0;94m'        # Blue
IPurple='\e[0;95m'      # Purple
ICyan='\e[0;96m'        # Cyan
IWhite='\e[0;97m'       # White

# Bold High Intensity
BIBlack='\e[1;90m'      # Black
BIRed='\e[1;91m'        # Red
BIGreen='\e[1;92m'      # Green
BIYellow='\e[1;93m'     # Yellow
BIBlue='\e[1;94m'       # Blue
BIPurple='\e[1;95m'     # Purple
BICyan='\e[1;96m'       # Cyan
BIWhite='\e[1;97m'      # White

# High Intensity backgrounds
On_IBlack='\e[0;100m'   # Black
On_IRed='\e[0;101m'     # Red
On_IGreen='\e[0;102m'   # Green
On_IYellow='\e[0;103m'  # Yellow
On_IBlue='\e[0;104m'    # Blue
On_IPurple='\e[10;95m'  # Purple
On_ICyan='\e[0;106m'    # Cyan
On_IWhite='\e[0;107m'   # White

#================================================

complete -cf sudo  # Sets bash completion

# shopt (shell options) - comments are too brief & ambigous - see man page:

shopt -s autocd			# automatically cd's to path entered at the prompt	
shopt -s cdspell		# corrects minor spelling errors in when using cd
shopt -s checkwinsize		# as the name says - after each bash command
shopt -s cmdhist		# attempts to save multiple line commands in the history
shopt -s dotglob		# includes <.dot> files in file name expansion if poss'
shopt -s expand_aliases		# aliases are expanded
shopt -s extglob		# the extended pattern matching enabled
shopt -s histappend		# history from exited shell kept for next open shell 
shopt -s hostcomplete		# host name completion when @ is in the word
shopt -s nocaseglob		# case-insensitive when performing filename expansion

export HISTSIZE=90000		# sets the size of the bash history file
export HISTFILESIZE=${HISTSIZE}
export HISTCONTROL=ignoreboth

#-----------------------------------------
# history completion using the arrow keys:
#-----------------------------------------

bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'

#-----------------------------------------


# ex - archive extractor	# command line archive extractor, came with Manjaro :)
# usage: ex <file>
ex ()
{
  if [ -f $1 ] ; then
    case $1 in
      *.tar.bz2)   tar xjf $1   ;;
      *.tar.gz)    tar xzf $1   ;;
      *.bz2)       bunzip2 $1   ;;
      *.rar)       unrar x $1     ;;
      *.gz)        gunzip $1    ;;
      *.tar)       tar xf $1    ;;
      *.tbz2)      tar xjf $1   ;;
      *.tgz)       tar xzf $1   ;;
      *.zip)       unzip $1     ;;
      *.Z)         uncompress $1;;
      *.7z)        7z x $1      ;;
      *)           echo "'$1' cannot be extracted via ex()" ;;
    esac
  else
    echo "'$1' is not a valid file"
  fi
}


#=================================================
# The Prompts Magic Section:
#=================================================

# Green user account prompt:
#PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '

# Red & blue - root account prompt, with green entered text:
#PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\]'

##################################################
# Fancy PWD display function
##################################################
# The home directory (HOME) is replaced with a ~
# The last pwdmaxlen characters of the PWD are displayed
# Leading partial directory names are striped off
# /home/me/stuff		-> ~/stuff			if USER=me
# /usr/share/big_dir_name	-> ../share/big_dir_name	if pwdmaxlen=20
##################################################

bash_prompt_command() {
	# How many characters of the $PWD should be kept
	local pwdmaxlen=25
	# Indicate that there has been dir truncation
	local trunc_symbol=".."
	local dir=${PWD##*/}
	pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
	NEW_PWD=${PWD/#$HOME/\~}
	local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
	if [ ${pwdoffset} -gt "0" ]
	then
		NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
		NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
	fi
}

bash_prompt() {
	case $TERM in
		xterm*|rxvt*)
			local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'
			;;
		*)
			local TITLEBAR=""
			;;
	esac
	local NONE="\[\033[0m\]"	# unsets color to term's fg color
	
	# regular colors
	local K="\[\033[0;30m\]"	# black
	local R="\[\033[0;31m\]"	# red
	local G="\[\033[0;32m\]"	# green
	local Y="\[\033[0;33m\]"	# yellow
	local B="\[\033[0;34m\]"	# blue
	local M="\[\033[0;35m\]"	# magenta
	local C="\[\033[0;36m\]"	# cyan
	local W="\[\033[0;37m\]"	# white
	
	# emphasized (bolded) colors
	local EMK="\[\033[1;30m\]"
	local EMR="\[\033[1;31m\]"
	local EMG="\[\033[1;32m\]"
	local EMY="\[\033[1;33m\]"
	local EMB="\[\033[1;34m\]"
	local EMM="\[\033[1;35m\]"
	local EMC="\[\033[1;36m\]"
	local EMW="\[\033[1;37m\]"
	
	# background colors
	local BGK="\[\033[40m\]"
	local BGR="\[\033[41m\]"
	local BGG="\[\033[42m\]"
	local BGY="\[\033[43m\]"
	local BGB="\[\033[44m\]"
	local BGM="\[\033[45m\]"
	local BGC="\[\033[46m\]"
	local BGW="\[\033[47m\]"
	
	local UC=$W			# user's color
	[ $UID -eq "0" ] && UC=$R	# root's color
	
	PS1="$TITLEBAR ${EMK}[${UC}\u${EMK}@${UC}\h ${EMB}\${NEW_PWD}${EMK}]${UC}\\$ ${NONE}"
	# without colors: PS1="[\u@\h \${NEW_PWD}]\\$ "
	# extra backslash in front of \$ to make bash colorize the prompt
}
PROMPT_COMMAND=bash_prompt_command
bash_prompt
unset bash_prompt

#=============================================================


#----------------------------
# set nano as default editor:
#----------------------------

export VISUAL=”/usr/bin/nano”


#=============================================================
# function: type "path" in terminal for ordered $PATH display:
#-------------------------------------------------------------

function path(){
    old=$IFS
    IFS=:
    printf "%s\n" $PATH
    IFS=$old
}

#=============================================================
# function to output module parameters:
#-------------------------------------------------------------

function modpar () 
{ 
    N=/dev/null;
    C=`tput op` O=$(echo -en "\n`tput setaf 2`>>> `tput op`");
    for mod in $(cat /proc/modules|cut -d" " -f1);
    do
        md=/sys/module/$mod/parameters;
        [[ ! -d $md ]] && continue;
        m=$mod;
        d=`modinfo -d $m 2>$N | tr "\n" "\t"`;
        echo -en "$O$m$C";
        [[ ${#d} -gt 0 ]] && echo -n " - $d";
        echo;
        for mc in $(cd $md; echo *);
        do
            de=`modinfo -p $mod 2>$N | grep ^$mc 2>$N|sed "s/^$mc=//" 2>$N`;
            echo -en "\t$mc=`cat $md/$mc 2>$N`";
            [[ ${#de} -gt 1 ]] && echo -en " - $de";
            echo;
        done;
    done
}

#============================================================= 
# cd & ls in one :- when you cd to a directory the ls command 
# automatically lists it's contents however you have configred 
# ls to do so:
#-------------------------------------------------------------

cl() {
if [ -d "$1" ]; then
	cd "$1"
	ls -la --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F	
	else
	echo "bash: cl: '$1': Directory not found"
fi
}

#=============================================================
# cd & ls & more in the same command. Pipes the output to more 
#for use with directories with many files in their contents:
#-------------------------------------------------------------

# cd and ls & more in one
cm() {
if [ -d "$1" ]; then
	cd "$1"
	ls | more
	else
	echo "bash: cl: '$1': Directory not found"
fi
}


#-------------------------------
# Aliases to save time & typing:
#-------------------------------

alias al="alias"
alias ls='ls --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias ll='ls -l --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias la='ls -la --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias grep='grep --color=tty -d skip'
alias cp="cp -i"                          # confirm before overwriting something
alias df='df -h'                          # human-readable sizes
alias free='free -m'                      # show sizes in MB
alias exit="clear; exit"
alias h="htop"
alias a="alsamixer"
alias m="sudo mount -a"
alias gparted="sudo gparted"
alias um="sudo umount 192.168.1.15:/media"
alias ub="sudo umount 192.168.1.15:/backup"
alias deldir="sudo rm -rf"        ### removes directories & their contents ###
alias rmfile="sudo find / -name ".AppleDB" -depth -exec rm -rf {} \;"
alias syns="synergys -d ERROR"
alias tw="tintwizard"
alias users="echo cut -d: -f1 /etc/passwd && cut -d: -f1 /etc/passwd"
alias hh="echo --help"
alias av="cd /mnt/bdata/av"

#=================================================================
# alias to ssh into ReadyNAS commands, followed by useful commands
# that won't work as aliases whilst using ssh.
#
# ***>>> REMEMBER <<<*** that the 65534.65534 user & group name is
# created for the default directories & can't be changed, so don't
# bother trying - again -.
#-----------------------------------------------------------------

# Use admin password <tough2> when requested:
alias snas="ssh -p 22 root@192.168.1.15"

# To delete Apple's <.dot> files:
# find . -name ".AppleDouble" -exec rm -rf {} \;

# To chmod drwxrwxrwx all files & subdirectories:
# chmod -R 777 /media

# To chown all files & subdirectories in given directory:
# chown -R handy:users /media

#==================================================================

#---------------------------
# NTP Network Time Protocol:
#---------------------------

## Gives time/date from various sources & displays in this case the 
## "local" NTP-server info' (Netgear Duo = 192.168.1.15):

alias time="timedatectl status && ntpq -c lpeer"


#-----------
# GPU stuff:
#-----------

alias gl="glxinfo | grep -i opengl && glxgears"


#----------------------------------------------------------------
# Screenshot (Function as the command would not run as an alias):
#----------------------------------------------------------------
 
function shot
{
scrot '%T_$wx$h_scrot.png' -c -d 5 -e 'mv $f /home/handy/data/_shots'
}


#------------------------
# Handbrake & associated:
#------------------------

alias .tmp="cd /mnt/store/pkg/vid/.tmp"

# The following alias doesn't do anything but echo the looong
# command to the Terminal window where it can be copied, pasted & edited for use:

alias hb="echo HandBrakeCLI -t 0 -i /media/dvd -o NAME.HERE.mp4 -e x264 -b 1000 -B 192 -s 1 --subtitle-burn"

alias hbhelp="HandBrakeCLI --help"


#----------------------------------------
# Quick call for Nano & major conf files:
#----------------------------------------

alias pacman.conf="sudo nano /etc/pacman.conf"	# pacman configuration file
alias fstab="sudo nano /etc/fstab"	# initialises partitions & other devices on boot
alias bashrc="nano ~/.bashrc"			# this wonderful file
alias rc.local="sudo nano /etc/rc.local"  # where I can call files during the boot process
alias xinitrc="nano ~/.xinitrc"			# works with startx to setup the desktop
alias mkinit="sudo nano /etc/mkinitcpio.conf"	# creates initial ramdisk environment
alias hosts="sudo nano /etc/hosts"	# networking - allows for added security blanket 
alias hdeny="sudo nano /etc/hosts.deny"		# networking
alias hallow="sudo nano /etc/hosts.allow"	# networking
alias exports="sudo nano /etc/exports"		# networking


#===========================================================
# Package Management:
#===========================================================

#--------------------------------------------------------------------
# Runs the allservers.sh script, ranking mirrors & syncing databases
# & bringing up a menu with options to upgrade system only or upgrade
# both system & AUR packages:
#--------------------------------------------------------------------

alias as="sudo su -c allservers.sh"

# Following is as above but runs "cacheclean -v 2" after upgrading:

alias asc="sudo su -c allservers.cc.sh"

#--------------------------------------------------------------------

# The following command needs to be in the /root/.bashrc as it must be 
# run as root = after "sudo su". Its purpose being to find the fastest 
# Manjaro mirror. Check out the Manjaro wiki for details:

alias mirror="sudo su -c rankmirrors -n 3 /etc/pacman.d/allservers > /etc/pacman.d/mirrorlist"

#--------------------------------------------------------------------

# Creates a list of orphan packages, which you can then add behind the pdelete alias:

alias orphan="pacman -Rs $(pacman -Qqdt)"

#---------------------------------------------------------------------

# Creates a list of all installed packages:

alias pkglist="comm -13 <(pacman -Qmq | sort) <(pacman -Qqe | sort) > pkglist"

#----------------------------------------------------------------------

# Lets you search through all available packages simply using 'pacsearch packagename':

alias pacsearch="pacman -Sl | cut -d' ' -f2 | grep "

#----------------------------------------------------------------------

# sudo pacman -Syu by typing pSyu:

alias Syu="sudo pacman -Syu"

#----------------------------------------------------------------------

# pacman -S by typing pS :

alias pS="sudo pacman -S"

#----------------------------------------------------------------------

# pacman -Rsn  ,which fully deletes packages - including dependencies & config files:
 
alias pdelete="sudo pacman -Rsn"

#----------------------------------------------------------------------

# pacman -Syy ,this forces a refresh of all package lists:

alias refresh="sudo pacman -Syy"

#----------------------------------------------------------------------

# deletes all but the last 2 versions of installed packages in the pacman cache:

alias cc="sudo cacheclean -v 2"

#----------------------------------------------------------------------

# pacman -U ,installs package(s) from the specified location on disk,
# usually /var/cache/pacman/pkg/ the following command will
# echo the command to the Terminal where it can be copied, have the
# file name added & used:

alias pU="echo sudo pacman -U /var/cache/pacman/pkg/-file.name- .pkg.tar.xz "

# in cases where multiple file up/downgrades are required you may choose to
# first CD to the cache before running the paman -U command multiple times -
# as adding all of the package names to the command line may be slower than
# recalling the previous pacman -U command & editing the name individually:

alias pkg="cd /var/cache/pacman/pkg"

alias pU2="echo sudo pacman -U .pkg.tar.xz"

#----------------------------------------------------------------------

### packer -Syu --aur equivelent by typing aur (packer is broken = comment):

#alias aur="packer -Syu"

#----------------------------------------------------------------------

### packer -S by typing pkS (packer is broken = commented out):

#alias pkS="packer -S"

#----------------------------------------------------------------------

# yaourt -Syu by typing yaur (changed to packer's old alias for the time being):

alias aur="sudo yaourt -Syua"

#---------------------------------------------------------------------

# yaourt -S by typing yS :

alias yS="sudo yaourt -S"

#---------------------------------------------------------------------

# yaourt -Rsn , which fully deletes packages - see above :

alias ydelete="sudo yaourt -Rsn"

#---------------------------------------------------------------------

Offline

Board footer

Powered by FluxBB