EndeavourOS
[dotfilesold/.git] / .bashrc
1 # ~/.bashrc: executed by bash(1) for non-login shells.
2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
3 # for examples
4 export EDITOR=vim;
5 export VISUAL=vim; #Nano is the main editor
6 # If not running interactively, don't do anything
7 case $- in
8     *i*) ;;
9       *) return;;
10 esac
11
12 # don't put duplicate lines or lines starting with space in the history.
13 # See bash(1) for more options
14 HISTCONTROL=ignoreboth
15
16 # append to the history file, don't overwrite it
17 shopt -s histappend
18
19 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
20 HISTSIZE=
21 HISTFILESIZE=
22 export HISTIGNORE='&:ls:ll:la:cd:exit:clear:history'
23 # check the window size after each command and, if necessary,
24 # update the values of LINES and COLUMNS.
25 shopt -s checkwinsize
26
27 # If set, the pattern "**" used in a pathname expansion context will
28 # match all files and zero or more directories and subdirectories.
29 #shopt -s globstar
30
31 # make less more friendly for non-text input files, see lesspipe(1)
32 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
33
34
35 # If this is an xterm set the title to user@host:dir
36 case "$TERM" in
37 xterm*|rxvt*|alacritty)
38     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
39     ;;
40 *)
41     ;;
42 esac
43
44 # enable color support of ls and also add handy aliases
45 if [ -x /usr/bin/dircolors ]; then
46     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
47     alias ls='ls -hN --color=auto --group-directories-first'
48     #alias dir='dir --color=auto'
49     #alias vdir='vdir --color=auto'
50
51     alias grep='grep --color=auto'
52     alias fgrep='fgrep --color=auto'
53     alias egrep='egrep --color=auto'
54 fi
55
56 # colored GCC warnings and errors
57 #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
58
59 # some more ls aliases
60 alias ll='ls -alF'
61 alias la='ls -A'
62 alias l='ls -CF'
63
64 # Add an "alert" alias for long running commands.  Use like so:
65 #   sleep 10; alert
66 alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
67
68 # Alias definitions.
69 # You may want to put all your additions into a separate file like
70 # ~/.bash_aliases, instead of adding them here directly.
71 # See /usr/share/doc/bash-doc/examples in the bash-doc package.
72
73 if [ -f ~/.bash_aliases ]; then
74     . ~/.bash_aliases
75 fi
76
77 # enable programmable completion features (you don't need to enable
78 # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
79 # sources /etc/bash.bashrc).
80 if ! shopt -oq posix; then
81   if [ -f /usr/share/bash-completion/bash_completion ]; then
82     . /usr/share/bash-completion/bash_completion
83   elif [ -f /etc/bash_completion ]; then
84     . /etc/bash_completion
85   fi
86 fi
87 # vi mode in the shell
88 set -o vi
89 # transform md anotations into PDF
90 mdpdf () { pandoc "$1".md -t beamer -o "$1".pdf ;}
91 #byebye for shutdown
92 alias byebye='shutdown now'
93 # Get all metadata
94 metadata () { echo "Salida del comando stat" ; stat "$1" ; echo "Salida del comando ls -lisan" ; ls -lisan "$1" ; echo "salida del comando exiftool" ; exiftool "$1" ;}
95 # use highlight for colored cat
96 alias ccat='highlight --out-format=ansi'
97 # activates the autocd mode
98 shopt -s autocd
99 # wifi available
100 alias wifi='nmcli d wifi'
101 # personalized ps1
102 export PS1="[$?]\[\]\[\033[38;5;40m\]\u@\h\[\]:\[\]\[\033[38;5;45m\]\w\[\]\n\[\]\[\033[38;5;166m\]\$\[\]"
103 alias autowal='wal --iterative -i /usr/share/backgrounds/ > /dev/null'
104 #figlet de mi nombre
105 whoami | figlet Josuer08 | lolcat -F 0.25;
106 #whoami | figlet Josuer08 | lolcat;
107 # agragando el comando gitdotfiles para manejar los dotfiles
108 alias gitdotfiles='/usr/bin/git --git-dir=$HOME/Documents/dotfiles/ --work-tree=$HOME';
109
110 function cdls() {
111     DIR="$*";
112         # if no DIR given, go home
113         if [ $# -lt 1 ]; then
114                 DIR=$HOME;
115     fi;
116     builtin cd "${DIR}" && \
117     # use your preferred ls command
118         ls -F --color=auto
119 }
120
121
122
123
124
125
126 #colorman
127 if $_isxrunning; then
128   export PAGER=less
129   export LESS_TERMCAP_mb=$'\E[01;31m'       # begin blinking
130   export LESS_TERMCAP_md=$'\E[01;38;5;74m'  # begin bold
131   export LESS_TERMCAP_me=$'\E[0m'           # end mode
132   export LESS_TERMCAP_se=$'\E[0m'           # end standout-mode
133   export LESS_TERMCAP_so=$'\E[38;5;246m'    # begin standout-mode - info box
134   export LESS_TERMCAP_ue=$'\E[0m'           # end underline
135   export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline
136 fi
137 #top10 commands
138 top10() { history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head; }
139 # goes up by the number of directories
140 up() {
141   local d=""
142   limit=$1
143   for ((i=1 ; i <= limit ; i++)); do
144     d=$d/..
145   done
146   d=$(echo $d | sed 's/^\///')
147   if [[ -z "$d" ]]; then
148     d=..
149   fi
150   cd $d
151 }
152 # ARCHIVE EXTRACTOR {{{
153 extract() {
154   clrstart="\033[1;34m"  #color codes
155   clrend="\033[0m"
156
157   if [[ "$#" -lt 1 ]]; then
158     echo -e "${clrstart}Pass a filename. Optionally a destination folder. You can also append a v for verbose output.${clrend}"
159     exit 1 #not enough args
160   fi
161
162   if [[ ! -e "$1" ]]; then
163     echo -e "${clrstart}File does not exist!${clrend}"
164     exit 2 #file not found
165   fi
166
167   if [[ -z "$2" ]]; then
168     DESTDIR="." #set destdir to current dir
169   elif [[ ! -d "$2" ]]; then
170     echo -e -n "${clrstart}Destination folder doesn't exist or isnt a directory. Create? (y/n): ${clrend}"
171     read response
172     #echo -e "\n"
173     if [[ $response == y || $response == Y ]]; then
174       mkdir -p "$2"
175       if [ $? -eq 0 ]; then
176         DESTDIR="$2"
177       else
178         exit 6 #Write perms error
179       fi
180     else
181       echo -e "${clrstart}Closing.${clrend}"; exit 3 # n/wrong response
182     fi
183   else
184     DESTDIR="$2"
185   fi
186
187   if [[ ! -z "$3" ]]; then
188     if [[ "$3" != "v" ]]; then
189       echo -e "${clrstart}Wrong argument $3 !${clrend}"
190       exit 4 #wrong arg 3
191     fi
192   fi
193
194   filename=`basename "$1"`
195
196   #echo "${filename##*.}" debug
197
198   case "${filename##*.}" in
199     tar)
200       echo -e "${clrstart}Extracting $1 to $DESTDIR: (uncompressed tar)${clrend}"
201       tar x${3}f "$1" -C "$DESTDIR"
202       ;;
203     gz)
204       echo -e "${clrstart}Extracting $1 to $DESTDIR: (gip compressed tar)${clrend}"
205       tar x${3}fz "$1" -C "$DESTDIR"
206       ;;
207     tgz)
208       echo -e "${clrstart}Extracting $1 to $DESTDIR: (gip compressed tar)${clrend}"
209       tar x${3}fz "$1" -C "$DESTDIR"
210       ;;
211     xz)
212       echo -e "${clrstart}Extracting  $1 to $DESTDIR: (gip compressed tar)${clrend}"
213       tar x${3}f -J "$1" -C "$DESTDIR"
214       ;;
215     bz2)
216       echo -e "${clrstart}Extracting $1 to $DESTDIR: (bzip compressed tar)${clrend}"
217       tar x${3}fj "$1" -C "$DESTDIR"
218       ;;
219     zip)
220       echo -e "${clrstart}Extracting $1 to $DESTDIR: (zipp compressed file)${clrend}"
221       unzip "$1" -d "$DESTDIR"
222       ;;
223     rar)
224       echo -e "${clrstart}Extracting $1 to $DESTDIR: (rar compressed file)${clrend}"
225       unrar x "$1" "$DESTDIR"
226       ;;
227     7z)
228       echo -e  "${clrstart}Extracting $1 to $DESTDIR: (7zip compressed file)${clrend}"
229       7za e "$1" -o"$DESTDIR"
230       ;;
231     *)
232       echo -e "${clrstart}Unknown archieve format!"
233       exit 5
234       ;;
235   esac
236 }
237 #}}}
238
239
240
241 # REMIND ME, ITS IMPORTANT! {{{
242 # usage: remindme <time> <text>
243 # e.g.: remindme 10m "omg, the pizza"
244 remindme() {
245   if [[ "$#" -lt 2 ]]; then
246     echo -e "Usage: remindme [time] '[message]'"
247     echo -e "Example: remindme 50s 'check mail'"
248     echo -e "Example: remindme 10m 'go to class'"
249     #exit 0 #not enough args
250   fi
251   if [[ "$#" -gt 2 ]]; then
252     echo -e "Usage: remindme [time] '[message]'"
253     echo -e "Example: remindme 50s 'check mail'"
254     echo -e "Example: remindme 10m 'go to class'"
255     #exit 0 #more than enough args
256   fi
257   if  [[ "$#" == 2 ]]; then
258     sleep $1 && notify-send -t 15000 "$2" & echo 'Reminder set'
259   fi
260   }
261
262 #}}}
263
264 ### add to xterm
265 xrdb -merge ~/.Xresources >> /dev/null 2>&1