Mercurial > hg > config
comparison .bash_overrides @ 929:7c4be71a560b default tip
remove old aliases
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 20 Oct 2025 15:22:19 -0700 |
parents | 753b1c2bd64c |
children |
comparison
equal
deleted
inserted
replaced
928:84543f2cda0d | 929:7c4be71a560b |
---|---|
1 #!/bin/bash | |
2 | |
3 ### command overrides too elaborate for aliases | |
4 | |
5 cd() { | |
6 | |
7 ENV="" | |
8 if [ -n "${VIRTUAL_ENV}" ] | |
9 then | |
10 ENV="${VIRTUAL_ENV}" | |
11 fi | |
12 | |
13 | |
14 if [ -d "$@" ] | |
15 then | |
16 command cd "$@" | |
17 else | |
18 if [ -e "$@" ] | |
19 then | |
20 command cd `dirname "$@"` | |
21 else | |
22 if [[ "$@" == "^" && -n "${ENV}" ]] | |
23 then | |
24 command cd "${ENV}" | |
25 else | |
26 command cd "$@" | |
27 fi | |
28 fi | |
29 fi | |
30 | |
31 # handle ENVs | |
32 if [ -e "bin/activate" ] | |
33 then | |
34 if [ -n "${ENV}" ] | |
35 then | |
36 if [ "${ENV}" != "${PWD}" ] | |
37 then | |
38 if [[ -n "`type -t deactivate`" ]] | |
39 then | |
40 deactivate | |
41 fi | |
42 else | |
43 return | |
44 fi | |
45 fi | |
46 source "bin/activate" | |
47 fi | |
48 | |
49 ENV="" | |
50 if [ -n "${VIRTUAL_ENV}" ] | |
51 then | |
52 ENV="${VIRTUAL_ENV}" | |
53 fi | |
54 | |
55 if [ -n "${ENV}" ] | |
56 then | |
57 FULLPWD=$(python -c 'import os; print (os.getcwd())') | |
58 if (( ! `expr "${FULLPWD}" : "${ENV}"` )) | |
59 then | |
60 if [[ -n "`type -t deactivate`" ]] | |
61 then | |
62 deactivate | |
63 fi | |
64 fi | |
65 fi | |
66 unset ENV | |
67 } | |
68 | |
69 function emacsclient() { | 1 function emacsclient() { |
70 command emacsclient $@ > /dev/null & | 2 command emacsclient $@ > /dev/null & |
71 } | |
72 | |
73 function find { | |
74 | |
75 if (( ! $# )) | |
76 then | |
77 command find | |
78 return | |
79 fi | |
80 | |
81 if [ -d $1 ] | |
82 then | |
83 DIR="$1" | |
84 shift | |
85 else | |
86 DIR="$PWD" | |
87 fi | |
88 | |
89 if [ "$#" == "1" ] | |
90 then | |
91 `which find` -L "$PWD" -not -path '*.svn*' -iname "$1" | |
92 return 0 | |
93 fi | |
94 | |
95 COMMAND="`which find` -L \"$DIR\" -not -path '*.svn*' $@" | |
96 #echo $COMMAND # for debugging | |
97 `which find` -L "$DIR" -not -path '*.svn*' "$@" | |
98 } | 3 } |
99 | 4 |
100 # make hg safer since $HOME is versioned | 5 # make hg safer since $HOME is versioned |
101 function hg { | 6 function hg { |
102 if [[ "$(command hg root)" == "${HOME}" ]] | 7 if [[ "$(command hg root)" == "${HOME}" ]] |
123 else | 28 else |
124 command lsdiff "$@" | 29 command lsdiff "$@" |
125 fi | 30 fi |
126 | 31 |
127 } | 32 } |
128 | |
129 function mv { | |
130 num=$# | |
131 if (( num == 0 )) | |
132 then | |
133 command mv "$@" | |
134 return | |
135 fi | |
136 last=${!#} | |
137 if [[ "${last:(-1)}" == "/" ]] | |
138 then | |
139 directory=${last} | |
140 else | |
141 directory=$(dirname ${last}) | |
142 fi | |
143 if [[ ! -e "${directory}" ]] | |
144 then | |
145 mkdir -p "${directory}" | |
146 fi | |
147 command mv "$@" | |
148 return | |
149 | |
150 } | |
151 | |
152 function unlink { | |
153 command unlink `echo $@ | sed 's/\/$//g'` | |
154 } | |
155 |