# Start .bashrc
# G.Campton
##############################
#
##############################
# Source global definitions
##############################
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
##############################
## SHELL OPTIONS
##############################
# umask is set to ensure that newly created files
# and directories are only writable by the owner,
# but reading and executing by anyone. (chmod 755)
# umask 022
##############################
# Use case-insensitive filename globbing
shopt -s nocaseglob
# Make bash append rather than overwrite the history on disk
shopt -s histappend
# When changing directory small typos can be ignored by bash
# for example, cd /vr/lgo/apaache would find /var/log/apache
shopt -s cdspell
# Completion options
# ##################
# These completion tuning parameters change the default behavior of bash_completion:
# Define to access remotely checked-out files over passwordless ssh for CVS
# COMP_CVS_REMOTE=1
# Define to avoid stripping description in --option=description of './configure --help'
COMP_CONFIGURE_HINTS=1
# Define to avoid flattening internal contents of tar files
COMP_TAR_INTERNAL_PATHS=1
# If this shell is interactive, turn on programmable completion enhancements.
# Any completions you add in ~/.bash_completion are sourced last.
# case $- in
# *i*) [[ -f /etc/bash_completion ]] && . /etc/bash_completion ;;
# esac
# History Options
# ###############
# Don't put duplicate lines in the history.
export HISTCONTROL="ignoredups"
# Whenever displaying the prompt, write the previous line to disk
export PROMPT_COMMAND="history -a"
# Aliases
# #######
# Some example alias instructions
# If these are enabled they will be used instead of any instructions
# they may mask. For example, alias rm='rm -i' will mask the rm
# application. To override the alias instruction use a \ before, ie
# \rm will call the real rm not the alias.
# Interactive operation...
alias rm='rm -v'
alias cp='cp -v'
alias mv='mv -v'
alias ls='pwd; ls -alhF --color=auto'
# Misc :)
alias whence='type -a' # where, of a sort
alias which='type -a'
alias man='man -a'
# Print out some path variables.
alias path='echo -e ${PATH//:/\\n}'
alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
# Some shortcuts for different directory listings ( if you like remembering list calls )
# alias ls='ls -hF --color=tty' # classify files in colour
# alias dir='ls --color=auto --format=vertical'
# alias vdir='ls --color=auto --format=long'
# alias ll='ls -l' # long list
# alias la='ls -A' # all but . and ..
# alias l='ls -CF' #
##############################
## FUNCTION DEFINITIONS
##############################
# Some example functions
function settitle() { echo -ne "\e]2;$@\a\e]1;$@\a"; }
# move filenames to lowercase
function lowercase()
{
for file ; do
filename=${file##*/}
case"$filename" in
*/*) dirname==${file%/*} ;;
*) dirname=.;;
esac
nf=$(echo $filename | tr A-Z a-z)
newname="${dirname}/${nf}"
if [ "$nf" != "$filename" ]; then
mv "$file" "$newname"
echo "lowercase: $file --> $newname"
else
echo "lowercase: $file not changed."
fi
done
}
# Swap 2 filenames around, if they exist
function swap()
{
local TMPFILE=tmp.$$
[ $# -ne 2 ] && echo "swap: 2 arguments needed" && return 1
[ ! -e $1 ] && echo "swap: $1 does not exist" && return 1
[ ! -e $2 ] && echo "swap: $2 does not exist" && return 1
mv -v "$1" $TMPFILE
mv -v "$2" "$1"
mv -v $TMPFILE "$2"
echo "Done: $1 & $2 switched filenames!!!"
}
# Extract Program.
function extract()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Local Variables:
# mode:shell-script
# sh-shell:bash
# [End of file] ~/.bashrc: */
Well it's very possible to port most console small C apps over to bash and use as functions.
I might do a translation of your code to bash just for the heck of it, I haven't done any in months so I should do something before I forget it all.
As for Linux, I tried to update my Kubuntu and the update hosed my system. I need to reinstall, but all I ever do to .profile is just make a bunch of little aliases that makes stuff easy to type.
That and some tweaks to /etc/fstab and to grub (for my own bg image) and to the system startup scripts (to make pure-text consoles available).
yea same, C:\cygwin\bin and C:\cygwin\usr\bin and C:\cygwin\home\Garratt\bin to windows environment.
So those are batch scripts Duoas? never done any batch scripting... looks easy enough.
I suppose it's not necessary to do up a bash version of small apps like that as you can just throw them in the bin folder and they still exec anywhere, but I like doing it because I can make them very portable with the 1 .bashrc file. just turning them into functions within my profile.
It's not exactly a .bashrc (mine's virtually the defualt one, with the additional condition that when it's a login shell and on TTY1 it executes startx (actually, gnome-session, which implies startx anyway)) but I created these two scripts to help with loop device mounting; 'cause before I kept getting it wrong and I couldn't free the loop devices.
/usr/bin/mountloop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/bin/sh
LOOPDEV_FILE=/tmp/loopdev
if [[ $# < 2 ]]; then
echo -e "Usage: $0 <file> <mount point>\n"
exit
fi
LOOPDEV=`losetup -f` # Get the first free loop device
echo "$LOOPDEV" >$LOOPDEV_FILE # So that umountloop can find which
# device to delete
losetup $LOOPDEV $1 # Loop the file on the loop device
mount $LOOPDEV $2 # Mount the device
exit 0
/usr/bin/umountloop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/bin/sh
LOOPDEV_FILE=/tmp/loopdev
if [[ ! -e $LOOPDEV_FILE]]; then
echo -e "Error: no loop device descriptor file found at $LOOPDEV_FILE"
exit
fi
read LOOPDEV <$LOOPDEV_FILE
umount $LOOPDEV
losetup -d $LOOPDEV
rm $LOOPDEV_FILE
exit 0