first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / core / sh_aliases.txt
1 # This file contains aliases that extend the set of commands available
2 # to the interactive shell user in Unix.  They are personally tailored.
3
4 if [ ! -z "$SHELL_DEBUG" ]; then
5   echo specialized alias initialization begins...
6 fi
7
8 # define our functions for use in the shell.
9 source "$SHELLDIR/core/functions.sh"
10
11 # Standard CAK aliases that add to or extend Unix commands.
12 alias bye='. $SHELLDIR/core/goodbye.sh'
13 alias calc='kcalc'
14 alias cls='clear_colormap; clear'
15 if [ "$OS" != "Windows_NT" ]; then
16   if [ -n "$IS_DARWIN" ]; then
17     # case for mac os x.
18     alias exp='open'
19   elif [ ! -z "$(which nautilus)" ]; then
20     alias exp='nautilus'
21   else
22 #check if konqueror exists also?  fall back to uhhh midnight cmdr?
23     alias exp='konqueror'
24   fi
25 else
26   alias explorer="bash $SHELLDIR/winders/exploder.sh"
27   alias exp="bash $SHELLDIR/winders/exploder.sh"
28 fi
29
30 alias pwd="/bin/pwd|sed -e 's/^\/home\/$USER/~/'"
31 alias notepad='gedit'
32 if [ "$OS" = "Windows_NT" ]; then
33   # aliases we only use on the winders side.
34   alias vi='gvim'
35 fi
36
37 # su function: makes su perform a login.
38 # for some OSes, this transfers the X authority information to the new login.
39 function su {
40   # decide if we think this is debian or ubuntu or a variant.
41   DEBIAN_LIKE=$(if [ ! -z "$(grep -i debian /etc/issue)" \
42       -o ! -z "$(grep -i ubuntu /etc/issue)" ]; then echo 1; else echo 0; fi)
43
44   if [ $DEBIAN_LIKE -eq 1 ]; then
45     # debian currently requires the full version which imports X authority
46     # information for su.
47
48     # get the x authority info for our current user.
49     source $SHELLDIR/x_win/get_x_auth.sh
50
51     if [ -z "$X_auth_info" ]; then
52       # if there's no authentication info to pass along, we just do a normal su.
53       /bin/su -l $*
54     else
55       # under X, we update the new login's authority info with the previous
56       # user's info.
57       (unset XAUTHORITY; /bin/su -l $* -c "$X_auth_info ; export DISPLAY=$DISPLAY ; bash")
58     fi
59   else
60     # non-debian supposedly doesn't need the extra overhead any more.
61     # or at least suse doesn't, which is the other one we've tested on.
62     /bin/su -l $*
63   fi
64
65   # relabel the console after returning.
66   bash $SHELLDIR/tty/label_terminal_with_infos.sh
67 }
68
69 # sudo function wraps the normal sudo by ensuring we replace the terminal
70 # label if they're doing an su with the sudo.
71 function sudo {
72   local first_command="$1"
73   /usr/bin/sudo $*
74   if [ "$first_command" == "su" ]; then
75     # yep, they were doing an su, but they're back now.
76     bash $SHELLDIR/tty/label_terminal_with_infos.sh
77   fi
78 }
79
80 alias whereami='echo whoa dude, try not to think about it...'
81
82 # buntar is a long needed uncompressing macro that feeds into tar -x.
83 # it takes a list of bz2 file names and extracts their contents into
84 # sequentially numbered directories.
85 function buntar {
86   index=1
87   for i in $*; do
88     mkdir buntar_$index
89     pushd buntar_$index &>/dev/null
90     file=$i
91     # if the filename has no directory component, we will assume it used to
92     # be above our unzipping directory here.
93     if [ "$(basename $file)" = $file ]; then
94       file=../$file
95     fi
96     bunzip2 -d -c $file | tar -xf -
97     popd &>/dev/null
98     index=$(expr $index + 1)
99   done
100 }
101
102 # trashes the .#blah files that cvs and svn leave behind when finding conflicts.
103 # this kind of assumes you've already checked them for any salient facts.
104 function clean_cvs_junk {
105   for i in $*; do
106     find $i -follow -type f -iname ".#*" -exec perl $SHELLDIR/files/safedel.pl {} ";" 
107   done
108 }
109
110 # call the generated aliases file, if it exists.
111 if [ -f "$GENERADIR/p_alias.sh" ]; then 
112   if [ ! -z "$SHELL_DEBUG" ]; then echo launching generated aliases.; fi
113   source $GENERADIR/p_alias.sh
114   if [ ! -z "$SHELL_DEBUG" ]; then echo done with generated aliases.; fi
115 fi
116
117 # remove the fredization macro if it was defined, helping to avoid running
118 # the shell scripts twice for users like root that don't always load this
119 # stuff.
120 unalias fredme >/dev/null 2>&1
121
122 if [ ! -z "$SHELL_DEBUG" ]; then echo aliases initialization ends....; fi
123