literate-dotfiles/docs/bash.html

972 lines
62 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2020-01-11 sam. 22:00 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Bash Configuration</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Dehaeze Thomas" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="../css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="../css/readtheorg.css"/>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/jquery.stickytableheaders.min.js"></script>
<script type="text/javascript" src="../js/readtheorg.js"></script>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2020 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href="./index.html"> UP </a>
|
<a accesskey="H" href="./index.html"> HOME </a>
</div><div id="content">
<h1 class="title">Bash Configuration</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orge676bb2">Bashrc</a>
<ul>
<li><a href="#org6524e6a"><span class="todo TODO">TODO</span> What does that do?</a></li>
<li><a href="#orgade44ee">Bash Completion</a></li>
<li><a href="#orgd9f988d">Ignore case for autocompletion</a></li>
<li><a href="#org41663f0">Use Color</a></li>
<li><a href="#org72d992f"><span class="todo TODO">TODO</span> Set colorful PS1 only on colorful terminals.</a></li>
<li><a href="#org6e324a6">Prompt</a></li>
<li><a href="#org3b3776c">SSH Agent</a></li>
<li><a href="#org586ae40">Rebind up and down arrow keys to search through bash history</a></li>
<li><a href="#org928d454"><span class="todo TODO">TODO</span> Aliases</a>
<ul>
<li><a href="#orgfc778e8">Better defaults for some commands</a></li>
<li><a href="#orgd519f4b">One letter aliases</a></li>
<li><a href="#org564af34">Neovim</a></li>
<li><a href="#org258d499">Magit</a></li>
<li><a href="#org9b3882d">Vim-like</a></li>
<li><a href="#orgafc5f84">Youtube</a></li>
<li><a href="#org62f7fe5">Print each PATH entry on a separate line</a></li>
<li><a href="#orgc2bc628"><span class="todo TODO">TODO</span> IP addresses - Remove the use of <code>dig</code> and <code>ifbashig</code></a></li>
</ul>
</li>
<li><a href="#org25e4d93"><span class="todo TODO">TODO</span> Functions</a>
<ul>
<li><a href="#orgfc4520c">Display colors</a></li>
<li><a href="#orgd523ae5"><span class="todo TODO">TODO</span> Meteo - Is Dig mandatory?</a></li>
<li><a href="#org9277857"><span class="todo TODO">TODO</span> Upload using transfer.sh</a></li>
<li><a href="#orgee3bfdb"><span class="todo TODO">TODO</span> Upload alternative</a></li>
<li><a href="#org06c01e0">Extract archive</a></li>
<li><a href="#org1522290">Tree display</a></li>
<li><a href="#orgfe71409">Create a new directory and enter it</a></li>
<li><a href="#org4395b78">Filesize of directory</a></li>
<li><a href="#orgf1e7ce2">Redirect both standard output and standard error, as well as sending to background</a></li>
<li><a href="#org2896f4a">Send SMS</a></li>
</ul>
</li>
<li><a href="#org9d14b86">Bash History</a></li>
</ul>
</li>
<li><a href="#org6a5ac47">Bash Profile</a></li>
<li><a href="#org99b9ec7">Profile</a>
<ul>
<li><a href="#orgfbbfbf9">QT And GTK Themes</a></li>
<li><a href="#orgbe2ffab">Gui program to ask for sudo password</a></li>
<li><a href="#org3e2966e">Default</a></li>
<li><a href="#org5ea13c1">Exports</a>
<ul>
<li><a href="#org1a74001">XDG Default</a></li>
<li><a href="#org117a776">Better yaourt colors</a></li>
<li><a href="#org684e85f">Use Ripgrep for FZF</a></li>
<li><a href="#org545dc00">Goland</a></li>
<li><a href="#orgeca4d01">SSH Agent</a></li>
</ul>
</li>
<li><a href="#org3b15f2e">Path</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-orge676bb2" class="outline-2">
<h2 id="orge676bb2">Bashrc</h2>
<div class="outline-text-2" id="text-orge676bb2">
</div>
<div id="outline-container-org6524e6a" class="outline-3">
<h3 id="org6524e6a"><span class="todo TODO">TODO</span> What does that do?</h3>
<div class="outline-text-3" id="text-org6524e6a">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> $<span class="org-variable-name">-</span> != *i* <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> &amp;&amp; <span class="org-keyword">return</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgade44ee" class="outline-3">
<h3 id="orgade44ee">Bash Completion</h3>
<div class="outline-text-3" id="text-orgade44ee">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-rainbow-delimiters-depth-1">[</span> -r /usr/share/bash-completion/bash_completion <span class="org-rainbow-delimiters-depth-1">]</span> &amp;&amp; <span class="org-builtin">.</span> /usr/share/bash-completion/bash_completion
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd9f988d" class="outline-3">
<h3 id="orgd9f988d">Ignore case for autocompletion</h3>
<div class="outline-text-3" id="text-orgd9f988d">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">bind</span> <span class="org-string">"set completion-ignore-case on"</span>
<span class="org-builtin">bind</span> <span class="org-string">"set show-all-if-ambiguous on"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org41663f0" class="outline-3">
<h3 id="org41663f0">Use Color</h3>
<div class="outline-text-3" id="text-org41663f0">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-variable-name">use_color</span>=true
<span class="org-builtin">alias</span> <span class="org-type">ls</span>=<span class="org-string">'</span><span class="org-type"><span class="org-string">ls</span></span><span class="org-string"> -hN --color=auto --group-directories-first'</span>
<span class="org-builtin">alias</span> <span class="org-type">grep</span>=<span class="org-string">'</span><span class="org-type"><span class="org-string">grep</span></span><span class="org-string"> --colour=auto'</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org72d992f" class="outline-3">
<h3 id="org72d992f"><span class="todo TODO">TODO</span> Set colorful PS1 only on colorful terminals.</h3>
<div class="outline-text-3" id="text-org72d992f">
<p>
dircolors &#x2013;print-database uses its own built-in database instead of using /etc/DIR<sub>COLORS</sub>. Try to use the external file first to take advantage of user additions. Use internal bash globbing instead of external grep binary.
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-variable-name">safe_term</span>=$<span class="org-rainbow-delimiters-depth-1">{</span><span class="org-variable-name">TERM</span>//<span class="org-rainbow-delimiters-depth-2">[</span>^<span class="org-rainbow-delimiters-depth-3">[</span>:alnum:<span class="org-rainbow-delimiters-depth-3">]</span><span class="org-rainbow-delimiters-depth-2">]</span>/?<span class="org-rainbow-delimiters-depth-1">}</span> <span class="org-comment-delimiter"># </span><span class="org-comment">sanitize TERM</span>
<span class="org-variable-name">match_lhs</span>=<span class="org-string">""</span>
<span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> -f ~/.dir_colors <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> &amp;&amp; <span class="org-variable-name">match_lhs</span>=<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{match_lhs}</span></span><span class="org-string"><span class="org-sh-quoted-exec">$(&lt;~/.dir_colors)</span></span><span class="org-string">"</span>
<span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> -f /etc/DIR_COLORS <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> &amp;&amp; <span class="org-variable-name">match_lhs</span>=<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{match_lhs}</span></span><span class="org-string"><span class="org-sh-quoted-exec">$(&lt;/etc/DIR_COLORS)</span></span><span class="org-string">"</span>
<span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> -z $<span class="org-rainbow-delimiters-depth-3">{</span><span class="org-variable-name">match_lhs</span><span class="org-rainbow-delimiters-depth-3">}</span> <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> <span class="org-sh-escaped-newline">\</span>
&amp;&amp; <span class="org-builtin">type</span> -P dircolors &gt;/dev/null <span class="org-sh-escaped-newline">\</span>
&amp;&amp; <span class="org-variable-name">match_lhs</span>=$<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-sh-quoted-exec">dircolors</span> --print-database<span class="org-rainbow-delimiters-depth-1">)</span>
<span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> $<span class="org-string">'\n'</span>$<span class="org-rainbow-delimiters-depth-3">{</span><span class="org-variable-name">match_lhs</span><span class="org-rainbow-delimiters-depth-3">}</span> == *$<span class="org-string">'\n'"TERM "</span>$<span class="org-rainbow-delimiters-depth-3">{</span><span class="org-variable-name">safe_term</span><span class="org-rainbow-delimiters-depth-3">}</span>* <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> &amp;&amp; <span class="org-variable-name">use_color</span>=true
<span class="org-keyword">if</span> $<span class="org-rainbow-delimiters-depth-1">{</span><span class="org-variable-name">use_color</span><span class="org-rainbow-delimiters-depth-1">}</span> ; <span class="org-keyword">then</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Enable colors for ls, etc. Prefer ~/.dir_colors #64489</span>
<span class="org-keyword">if </span><span class="org-builtin">type</span> -P dircolors &gt;/dev/null ; <span class="org-keyword">then</span>
<span class="org-keyword">if</span> <span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> -f ~/.dir_colors <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> ; <span class="org-keyword">then</span>
<span class="org-builtin">eval</span> $<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-sh-quoted-exec">dircolors</span> -b ~/.dir_colors<span class="org-rainbow-delimiters-depth-1">)</span>
<span class="org-keyword">elif</span> <span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> -f /etc/DIR_COLORS <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> ; <span class="org-keyword">then</span>
<span class="org-builtin">eval</span> $<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-sh-quoted-exec">dircolors</span> -b /etc/DIR_COLORS<span class="org-rainbow-delimiters-depth-1">)</span>
<span class="org-keyword">fi</span>
<span class="org-keyword">fi</span>
<span class="org-keyword">if</span> <span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> $<span class="org-rainbow-delimiters-depth-3">{</span><span class="org-variable-name">EUID</span><span class="org-rainbow-delimiters-depth-3">}</span> == <span class="org-highlight-numbers-number">0</span> <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> ; <span class="org-keyword">then</span>
<span class="org-variable-name">PS1</span>=<span class="org-string">'\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '</span>
<span class="org-keyword">else</span>
<span class="org-variable-name">PS1</span>=<span class="org-string">'\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] '</span>
<span class="org-keyword">fi</span>
<span class="org-keyword">else</span>
<span class="org-keyword">if</span> <span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> $<span class="org-rainbow-delimiters-depth-3">{</span><span class="org-variable-name">EUID</span><span class="org-rainbow-delimiters-depth-3">}</span> == <span class="org-highlight-numbers-number">0</span> <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> ; <span class="org-keyword">then</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">show root@ when we don't have colors</span>
<span class="org-variable-name">PS1</span>=<span class="org-string">'\u@\h \W \$ '</span>
<span class="org-keyword">else</span>
<span class="org-variable-name">PS1</span>=<span class="org-string">'\u@\h \w \$ '</span>
<span class="org-keyword">fi</span>
<span class="org-keyword">fi</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">unset</span> use_color safe_term match_lhs sh
</pre>
</div>
<div class="org-src-container">
<pre class="src src-bash">xhost +local:root &gt; /dev/null <span class="org-highlight-numbers-number">2</span>&gt;&amp;<span class="org-highlight-numbers-number">1</span>
<span class="org-builtin">complete</span> -cf <span class="org-type">sudo</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Line wrap on window resize</span>
<span class="org-builtin">shopt</span> -s checkwinsize
<span class="org-builtin">shopt</span> -s expand_aliases
<span class="org-comment-delimiter"># </span><span class="org-comment">Auto "</span><span class="org-type"><span class="org-comment">cd</span></span><span class="org-comment">" when entering just a path</span>
<span class="org-builtin">shopt</span> -s autocd
<span class="org-comment-delimiter"># </span><span class="org-comment">Enable history appending instead of overwriting</span>
<span class="org-builtin">shopt</span> -s histappend
</pre>
</div>
</div>
</div>
<div id="outline-container-org6e324a6" class="outline-3">
<h3 id="org6e324a6">Prompt</h3>
<div class="outline-text-3" id="text-org6e324a6">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">PS1</span>=<span class="org-string">"\[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> bold)</span></span><span class="org-string">\]\[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> setaf 1)</span></span><span class="org-string">\][\[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> setaf 3)</span></span><span class="org-string">\]\u\[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> setaf 2)</span></span><span class="org-string">\]@\[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> setaf 4)</span></span><span class="org-string">\]\h \[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> setaf 5)</span></span><span class="org-string">\]\W\[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> setaf 1)</span></span><span class="org-string">\]]\[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> setaf 7)</span></span><span class="org-string">\]\\$ \[</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">tput</span><span class="org-string"><span class="org-sh-quoted-exec"> sgr0)</span></span><span class="org-string">\]"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org3b3776c" class="outline-3">
<h3 id="org3b3776c">SSH Agent</h3>
<div class="outline-text-3" id="text-org3b3776c">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-comment-delimiter"># </span><span class="org-comment">if ! </span><span class="org-type"><span class="org-comment">pgrep</span></span><span class="org-comment"> -u "$USER" ssh-agent &gt; /dev/null; then</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">ssh-agent &gt; "$XDG_RUNTIME_DIR/ssh-agent.env"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">fi</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">if [[ ! "$SSH_AUTH_SOCK" ]]; then</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">eval "$(&lt;"$XDG_RUNTIME_DIR/ssh-agent.env")"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">fi</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org586ae40" class="outline-3">
<h3 id="org586ae40">Rebind up and down arrow keys to search through bash history</h3>
<div class="outline-text-3" id="text-org586ae40">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">bind</span> <span class="org-string">'"\e[A": history-search-backward'</span>
<span class="org-builtin">bind</span> <span class="org-string">'"\e[B": history-search-forward'</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org928d454" class="outline-3">
<h3 id="org928d454"><span class="todo TODO">TODO</span> Aliases</h3>
<div class="outline-text-3" id="text-org928d454">
</div>
<div id="outline-container-orgfc778e8" class="outline-4">
<h4 id="orgfc778e8">Better defaults for some commands</h4>
<div class="outline-text-4" id="text-orgfc778e8">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">alias</span> <span class="org-type">cp</span>=<span class="org-string">"</span><span class="org-type"><span class="org-string">cp</span></span><span class="org-string"> -i"</span> <span class="org-comment-delimiter"># </span><span class="org-comment">confirm before overwriting something</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">df</span>=<span class="org-string">'df -h'</span> <span class="org-comment-delimiter"># </span><span class="org-comment">human-readable sizes</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">free</span>=<span class="org-string">'free -m'</span> <span class="org-comment-delimiter"># </span><span class="org-comment">show sizes in MB</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">mutt</span>=<span class="org-string">"neomutt"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">tmux</span>=<span class="org-string">'tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf'</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd519f4b" class="outline-4">
<h4 id="orgd519f4b">One letter aliases</h4>
<div class="outline-text-4" id="text-orgd519f4b">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">alias</span> <span class="org-variable-name">r</span>=<span class="org-string">"ranger"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">t</span>=<span class="org-string">"tmux"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">v</span>=<span class="org-string">"nvim"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">sv</span>=<span class="org-string">'</span><span class="org-type"><span class="org-string">sudo</span></span><span class="org-string"> -E nvim'</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">g</span>=<span class="org-string">"</span><span class="org-type"><span class="org-string">git</span></span><span class="org-string">"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">m</span>=<span class="org-string">"neomutt"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">y</span>=<span class="org-string">"yadm"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">o</span>=<span class="org-string">"xdg-open"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">x</span>=<span class="org-string">"sxiv -ft *"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org564af34" class="outline-4">
<h4 id="org564af34">Neovim</h4>
<div class="outline-text-4" id="text-org564af34">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">command</span> -v nvim &gt;/dev/null &amp;&amp; <span class="org-builtin">alias</span> <span class="org-variable-name">vim</span>=<span class="org-string">"nvim"</span> <span class="org-variable-name">vimdiff</span>=<span class="org-string">"nvim -d"</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Use neovim for vim if present.</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org258d499" class="outline-4">
<h4 id="org258d499">Magit</h4>
<div class="outline-text-4" id="text-org258d499">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-comment-delimiter"># </span><span class="org-comment">alias magit="emacsclient -create-frame --alternate-editor=\"\" --eval '(magit-status)'"</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">magit</span>=<span class="org-string">"nvim -c MagitOnly"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org9b3882d" class="outline-4">
<h4 id="org9b3882d">Vim-like</h4>
<div class="outline-text-4" id="text-org9b3882d">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">alias</span> :<span class="org-variable-name">q</span>=exit
<span class="org-builtin">alias</span> :<span class="org-variable-name">e</span>=nvim
</pre>
</div>
</div>
</div>
<div id="outline-container-orgafc5f84" class="outline-4">
<h4 id="orgafc5f84">Youtube</h4>
<div class="outline-text-4" id="text-orgafc5f84">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">alias</span> <span class="org-variable-name">yt</span>=<span class="org-string">"youtube-dl --add-metadata -ic"</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Download video link</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">yta</span>=<span class="org-string">"yt -x -f bestaudio/best"</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Download only audio</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org62f7fe5" class="outline-4">
<h4 id="org62f7fe5">Print each PATH entry on a separate line</h4>
<div class="outline-text-4" id="text-org62f7fe5">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">alias</span> <span class="org-variable-name">path</span>=<span class="org-string">'</span><span class="org-type"><span class="org-string">echo</span></span><span class="org-string"> -e ${PATH//:/\\n}'</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc2bc628" class="outline-4">
<h4 id="orgc2bc628"><span class="todo TODO">TODO</span> IP addresses - Remove the use of <code>dig</code> and <code>ifbashig</code></h4>
<div class="outline-text-4" id="text-orgc2bc628">
<p>
Use <code>addr</code> instead
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-comment-delimiter"># </span><span class="org-comment">alias ip="dig +short myip.opendns.com @resolver1.opendns.com"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">alias localip="ip route get 8.8.4.4 | head -1 | awk '{print $7}'"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">alias ips="ifconfig -a | </span><span class="org-type"><span class="org-comment">grep</span></span><span class="org-comment"> -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org25e4d93" class="outline-3">
<h3 id="org25e4d93"><span class="todo TODO">TODO</span> Functions</h3>
<div class="outline-text-3" id="text-org25e4d93">
</div>
<div id="outline-container-orgfc4520c" class="outline-4">
<h4 id="orgfc4520c">Display colors</h4>
<div class="outline-text-4" id="text-orgfc4520c">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-function-name">colors</span><span class="org-rainbow-delimiters-depth-1">()</span> <span class="org-rainbow-delimiters-depth-1">{</span>
<span class="org-builtin">local</span> fgc bgc vals seq0
<span class="org-builtin">printf</span> <span class="org-string">"Color escapes are %s\n"</span> <span class="org-string">'\e[${value};...;${value}m'</span>
<span class="org-builtin">printf</span> <span class="org-string">"Values 30..37 are \e[33mforeground colors\e[m\n"</span>
<span class="org-builtin">printf</span> <span class="org-string">"Values 40..47 are \e[43mbackground colors\e[m\n"</span>
<span class="org-builtin">printf</span> <span class="org-string">"Value 1 gives a \e[1mbold-faced look\e[m\n\n"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">foreground colors</span>
<span class="org-keyword">for</span> fgc<span class="org-keyword"> in</span> <span class="org-rainbow-delimiters-depth-2">{</span>30..37<span class="org-rainbow-delimiters-depth-2">}</span>; <span class="org-keyword">do</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">background colors</span>
<span class="org-keyword">for</span> bgc<span class="org-keyword"> in</span> <span class="org-rainbow-delimiters-depth-2">{</span>40..47<span class="org-rainbow-delimiters-depth-2">}</span>; <span class="org-keyword">do</span>
<span class="org-variable-name">fgc</span>=$<span class="org-rainbow-delimiters-depth-2">{</span><span class="org-variable-name">fgc</span>#37<span class="org-rainbow-delimiters-depth-2">}</span> <span class="org-comment-delimiter"># </span><span class="org-comment">white</span>
<span class="org-variable-name">bgc</span>=$<span class="org-rainbow-delimiters-depth-2">{</span><span class="org-variable-name">bgc</span>#40<span class="org-rainbow-delimiters-depth-2">}</span> <span class="org-comment-delimiter"># </span><span class="org-comment">black</span>
<span class="org-variable-name">vals</span>=<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{fgc:+$fgc;}</span></span><span class="org-string">${bgc}"</span>
<span class="org-variable-name">vals</span>=$<span class="org-rainbow-delimiters-depth-2">{</span><span class="org-variable-name">vals</span>%%;<span class="org-rainbow-delimiters-depth-2">}</span>
<span class="org-variable-name">seq0</span>=<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{vals:+\e[${vals}</span></span><span class="org-string">m}"</span>
<span class="org-builtin">printf</span> <span class="org-string">" %-9s"</span> <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{seq0:-(default)}</span></span><span class="org-string">"</span>
<span class="org-builtin">printf</span> <span class="org-string">" </span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{seq0}</span></span><span class="org-string">TEXT\e[m"</span>
<span class="org-builtin">printf</span> <span class="org-string">" \e[</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{vals:+${vals+$vals;}</span></span><span class="org-string">}1mBOLD\e[m"</span>
<span class="org-keyword">done</span>
<span class="org-type">echo</span>; <span class="org-type">echo</span>
<span class="org-keyword">done</span>
<span class="org-rainbow-delimiters-depth-1">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd523ae5" class="outline-4">
<h4 id="orgd523ae5"><span class="todo TODO">TODO</span> Meteo - Is Dig mandatory?</h4>
<div class="outline-text-4" id="text-orgd523ae5">
<p>
To install <code>dig</code>, use <code>yay -S bind-tools</code>
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-function-name">meteo</span><span class="org-rainbow-delimiters-depth-1">()</span> <span class="org-rainbow-delimiters-depth-1">{</span>
<span class="org-keyword">if</span> <span class="org-rainbow-delimiters-depth-2">[</span> -n <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">*</span></span><span class="org-string">"</span> <span class="org-rainbow-delimiters-depth-2">]</span>; <span class="org-keyword">then</span>
<span class="org-variable-name">address</span>=<span class="org-string">"wttr.in/"</span>
<span class="org-variable-name">address</span>+=$<span class="org-variable-name">*</span>
<span class="org-variable-name">address</span>+=<span class="org-string">"?lang=fr"</span>
<span class="org-type">curl</span> <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">address</span></span><span class="org-string">"</span>
<span class="org-keyword">else</span>
<span class="org-variable-name">address</span>=<span class="org-string">"wttr.in/"</span>
<span class="org-variable-name">address</span>+=$<span class="org-rainbow-delimiters-depth-2">(</span><span class="org-sh-quoted-exec">ip</span><span class="org-rainbow-delimiters-depth-2">)</span>
<span class="org-variable-name">address</span>+=<span class="org-string">"?lang=fr"</span>
<span class="org-type">curl</span> <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">address</span></span><span class="org-string">"</span>
<span class="org-keyword">fi</span>
<span class="org-rainbow-delimiters-depth-1">}</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">meteo</span>=meteo
</pre>
</div>
</div>
</div>
<div id="outline-container-org9277857" class="outline-4">
<h4 id="org9277857"><span class="todo TODO">TODO</span> Upload using transfer.sh</h4>
<div class="outline-text-4" id="text-org9277857">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-function-name">upload</span><span class="org-rainbow-delimiters-depth-1">()</span> <span class="org-rainbow-delimiters-depth-1">{</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">write to output to tmpfile because of progress bar</span>
<span class="org-variable-name">tmpfile</span>=$<span class="org-rainbow-delimiters-depth-2">(</span><span class="org-sh-quoted-exec">mktemp</span> -t transferXXX<span class="org-rainbow-delimiters-depth-2">)</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">basefile=$(</span><span class="org-sh-quoted-exec">basename</span><span class="org-comment"> "$1" | sed -e 's/[^a-zA-Z0-9]/-/g')</span>
<span class="org-type">curl</span> --progress-bar --upload-file <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">1</span></span><span class="org-string">"</span> <span class="org-string">"https://transfer.sh/"</span> &gt;&gt; $<span class="org-variable-name">tmpfile</span>;
<span class="org-type">cat</span> $<span class="org-variable-name">tmpfile</span> | xclip -selection clipboard;
<span class="org-type">echo</span> <span class="org-string">"Copied:"</span> $<span class="org-rainbow-delimiters-depth-2">(</span><span class="org-sh-quoted-exec">cat</span> $<span class="org-variable-name">tmpfile</span><span class="org-rainbow-delimiters-depth-2">)</span>;
<span class="org-type">rm</span> -f $<span class="org-variable-name">tmpfile</span>;
<span class="org-rainbow-delimiters-depth-1">}</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">upload</span>=upload
</pre>
</div>
</div>
</div>
<div id="outline-container-orgee3bfdb" class="outline-4">
<h4 id="orgee3bfdb"><span class="todo TODO">TODO</span> Upload alternative</h4>
<div class="outline-text-4" id="text-orgee3bfdb">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-function-name">transfer</span><span class="org-rainbow-delimiters-depth-1">()</span> <span class="org-rainbow-delimiters-depth-1">{</span>
<span class="org-type">curl</span> --progress-bar --upload-file <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">1</span></span><span class="org-string">"</span> https://transfer.sh/$<span class="org-rainbow-delimiters-depth-2">(</span><span class="org-sh-quoted-exec">basename</span> $<span class="org-highlight-numbers-number">1</span><span class="org-rainbow-delimiters-depth-2">)</span> | xclip -in -selection clipboard;
<span class="org-rainbow-delimiters-depth-1">}</span>
<span class="org-builtin">alias</span> <span class="org-variable-name">transfer</span>=transfer
</pre>
</div>
</div>
</div>
<div id="outline-container-org06c01e0" class="outline-4">
<h4 id="org06c01e0">Extract archive</h4>
<div class="outline-text-4" id="text-org06c01e0">
<p>
usage: ex &lt;file&gt;
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-function-name">ex</span> <span class="org-rainbow-delimiters-depth-1">()</span>
<span class="org-rainbow-delimiters-depth-1">{</span>
<span class="org-keyword">if</span> <span class="org-rainbow-delimiters-depth-2">[</span> -f $<span class="org-highlight-numbers-number">1</span> <span class="org-rainbow-delimiters-depth-2">]</span> ; <span class="org-keyword">then</span>
<span class="org-keyword">case</span> $<span class="org-highlight-numbers-number">1</span><span class="org-keyword"> in</span>
*.tar.bz2) tar xjf $<span class="org-highlight-numbers-number">1</span> ;;
*.tar.gz) tar xzf $<span class="org-highlight-numbers-number">1</span> ;;
*.bz2) bunzip2 $<span class="org-highlight-numbers-number">1</span> ;;
*.rar) unrar x $<span class="org-highlight-numbers-number">1</span> ;;
*.gz) gunzip $<span class="org-highlight-numbers-number">1</span> ;;
*.tar) tar xf $<span class="org-highlight-numbers-number">1</span> ;;
*.tbz2) tar xjf $<span class="org-highlight-numbers-number">1</span> ;;
*.tgz) tar xzf $<span class="org-highlight-numbers-number">1</span> ;;
*.zip) unzip $<span class="org-highlight-numbers-number">1</span> ;;
*.Z) uncompress $<span class="org-highlight-numbers-number">1</span>;;
*.7z) 7z x $<span class="org-highlight-numbers-number">1</span> ;;
*) <span class="org-type">echo</span> <span class="org-string">"'</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">1</span></span><span class="org-string">' cannot be extracted via ex()"</span> ;;
<span class="org-keyword">esac</span>
<span class="org-keyword">else</span>
<span class="org-type">echo</span> <span class="org-string">"'</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">1</span></span><span class="org-string">' is not a valid file"</span>
<span class="org-keyword">fi</span>
<span class="org-rainbow-delimiters-depth-1">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org1522290" class="outline-4">
<h4 id="org1522290">Tree display</h4>
<div class="outline-text-4" id="text-org1522290">
<p>
<code>tre</code> is a shorthand for <code>tree</code> with hidden files and color enabled, ignoring
the <code>.git</code> directory, listing directories first. The output gets piped into
<code>less</code> with options to preserve color and line numbers, unless the output is
small enough for one screen.
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-keyword">function</span> <span class="org-function-name">tre</span><span class="org-rainbow-delimiters-depth-1">()</span> <span class="org-rainbow-delimiters-depth-1">{</span>
tree -aC -I <span class="org-string">'.git|node_modules|bower_components'</span> --dirsfirst <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">@</span></span><span class="org-string">"</span> | <span class="org-type">less</span> -FRNX;
<span class="org-rainbow-delimiters-depth-1">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgfe71409" class="outline-4">
<h4 id="orgfe71409">Create a new directory and enter it</h4>
<div class="outline-text-4" id="text-orgfe71409">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-keyword">function</span> <span class="org-function-name">mkd</span><span class="org-rainbow-delimiters-depth-1">()</span> <span class="org-rainbow-delimiters-depth-1">{</span>
<span class="org-type">mkdir</span> -p <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">@</span></span><span class="org-string">"</span> &amp;&amp; <span class="org-type">cd</span> <span class="org-string">"$_"</span>;
<span class="org-rainbow-delimiters-depth-1">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org4395b78" class="outline-4">
<h4 id="org4395b78">Filesize of directory</h4>
<div class="outline-text-4" id="text-org4395b78">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-keyword">function</span> <span class="org-function-name">fs</span><span class="org-rainbow-delimiters-depth-1">()</span> <span class="org-rainbow-delimiters-depth-1">{</span>
<span class="org-keyword">if</span> du -b /dev/null &gt; /dev/null <span class="org-highlight-numbers-number">2</span>&gt;&amp;<span class="org-highlight-numbers-number">1</span>; <span class="org-keyword">then</span>
<span class="org-builtin">local</span> <span class="org-variable-name">arg</span>=-sbh;
<span class="org-keyword">else</span>
<span class="org-builtin">local</span> <span class="org-variable-name">arg</span>=-sh;
<span class="org-keyword">fi</span>
<span class="org-keyword">if</span> <span class="org-rainbow-delimiters-depth-2">[</span><span class="org-rainbow-delimiters-depth-3">[</span> -n <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">@</span></span><span class="org-string">"</span> <span class="org-rainbow-delimiters-depth-3">]</span><span class="org-rainbow-delimiters-depth-2">]</span>; <span class="org-keyword">then</span>
du $<span class="org-variable-name">arg</span> -- <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">@</span></span><span class="org-string">"</span>;
<span class="org-keyword">else</span>
du $<span class="org-variable-name">arg</span> .<span class="org-rainbow-delimiters-depth-2">[</span>^.<span class="org-rainbow-delimiters-depth-2">]</span>* ./*;
<span class="org-keyword">fi</span>;
<span class="org-rainbow-delimiters-depth-1">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf1e7ce2" class="outline-4">
<h4 id="orgf1e7ce2">Redirect both standard output and standard error, as well as sending to background</h4>
<div class="outline-text-4" id="text-orgf1e7ce2">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-keyword">function</span> <span class="org-function-name">nullify</span><span class="org-rainbow-delimiters-depth-1">()</span> <span class="org-rainbow-delimiters-depth-1">{</span>
<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">@</span></span><span class="org-string">"</span> &gt;/dev/null <span class="org-highlight-numbers-number">2</span>&gt;&amp;<span class="org-highlight-numbers-number">1</span>
<span class="org-rainbow-delimiters-depth-1">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org2896f4a" class="outline-4">
<h4 id="org2896f4a">Send SMS</h4>
<div class="outline-text-4" id="text-org2896f4a">
<p>
<a href="https://doronbehar.com/articles/using-kdeconnect-to-comfortably-send-sms-messages-from-the-shell/#kdeconnects-builtin-sms-interface">https://doronbehar.com/articles/using-kdeconnect-to-comfortably-send-sms-messages-from-the-shell/#kdeconnects-builtin-sms-interface</a>
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-function-name">sms</span><span class="org-rainbow-delimiters-depth-1">(){</span>
<span class="org-builtin">local</span> <span class="org-variable-name">args</span>=<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">@</span></span><span class="org-string">"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">local phone_number name phone_type</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">khard phone --parsable | sort -u | fzf | IFS=$'\t' read -r phone_number name phone_type</span>
<span class="org-builtin">local</span> <span class="org-variable-name">phone_number</span>=$<span class="org-rainbow-delimiters-depth-2">(</span><span class="org-sh-quoted-exec">khard</span> phone --parsable | sort -u | fzf | cut -f1 -d$<span class="org-string">'\t'</span><span class="org-rainbow-delimiters-depth-2">)</span>
<span class="org-keyword">if</span> <span class="org-rainbow-delimiters-depth-2">[</span><span class="org-rainbow-delimiters-depth-3">[</span> -z <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{phone_number}</span></span><span class="org-string">"</span> <span class="org-rainbow-delimiters-depth-3">]</span><span class="org-rainbow-delimiters-depth-2">]</span>; <span class="org-keyword">then</span>
<span class="org-type">echo</span> No recipient was chosen &gt;&amp;<span class="org-highlight-numbers-number">2</span>
<span class="org-keyword">return</span>
<span class="org-keyword">else</span>
<span class="org-comment-delimiter"># </span><span class="org-type"><span class="org-comment">echo</span></span><span class="org-comment"> "${name}"$'\t'"${phone_number}"$'\t'"${phone_type}" &gt; ${_KDECONNECT_SMS_LAST_RECIPIENT}</span>
kdeconnect-cli --send-sms <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{args}</span></span><span class="org-string">"</span> --destination <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{phone_number}</span></span><span class="org-string">"</span> --device 4de3b5de2264a17c
<span class="org-comment-delimiter"># </span><span class="org-comment">kdeconnect-cli --device ${_KDECONNECT_DEFAULT_DEVICE} --send-sms "${args}" --destination "${phone_number}" &amp;&amp; \</span>
<span class="org-comment-delimiter"># </span><span class="org-type"><span class="org-comment">echo</span></span><span class="org-comment"> sent sms message to ${name} | fribidi</span>
<span class="org-keyword">fi</span>
<span class="org-rainbow-delimiters-depth-1">}</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org9d14b86" class="outline-3">
<h3 id="org9d14b86">Bash History</h3>
<div class="outline-text-3" id="text-org9d14b86">
<p>
Undocumented feature which sets the size to &ldquo;unlimited&rdquo;. <a href="http://stackoverflow.com/questions/9457233/unlimited-bash-history">http://stackoverflow.com/questions/9457233/unlimited-bash-history</a>
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">HISTFILESIZE</span>=
<span class="org-builtin">export</span> <span class="org-variable-name">HISTSIZE</span>=
<span class="org-builtin">export</span> <span class="org-variable-name">HISTTIMEFORMAT</span>=<span class="org-string">"[%F %T] "</span>
</pre>
</div>
<p>
Change the file location because certain bash sessions truncate <code>.bash_history</code> file upon close. <a href="http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login">http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login</a>
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">HISTFILE</span>=~/.bash_eternal_history
</pre>
</div>
<p>
Force prompt to write history after every command. <a href="http://superuser.com/questions/20900/bash-history-loss">http://superuser.com/questions/20900/bash-history-loss</a>
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-variable-name">PROMPT_COMMAND</span>=<span class="org-string">"history -a; </span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">PROMPT_COMMAND</span></span><span class="org-string">"</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org6a5ac47" class="outline-2">
<h2 id="org6a5ac47">Bash Profile</h2>
<div class="outline-text-2" id="text-org6a5ac47">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> -f ~/.profile <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> &amp;&amp; <span class="org-builtin">.</span> ~/.profile
<span class="org-rainbow-delimiters-depth-1">[</span><span class="org-rainbow-delimiters-depth-2">[</span> -f ~/.bashrc <span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">]</span> &amp;&amp; <span class="org-builtin">.</span> ~/.bashrc
</pre>
</div>
</div>
</div>
<div id="outline-container-org99b9ec7" class="outline-2">
<h2 id="org99b9ec7">Profile</h2>
<div class="outline-text-2" id="text-org99b9ec7">
</div>
<div id="outline-container-orgfbbfbf9" class="outline-3">
<h3 id="orgfbbfbf9">QT And GTK Themes</h3>
<div class="outline-text-3" id="text-orgfbbfbf9">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">QT_QPA_PLATFORMTHEME</span>=<span class="org-string">"qt5ct"</span>
<span class="org-builtin">export</span> <span class="org-variable-name">GTK2_RC_FILES</span>=<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">HOME</span></span><span class="org-string">/.gtkrc-2.0"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgbe2ffab" class="outline-3">
<h3 id="orgbe2ffab">Gui program to ask for sudo password</h3>
<div class="outline-text-3" id="text-orgbe2ffab">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">SUDO_ASKPASS</span>=~/bin/askpass-rofi
</pre>
</div>
</div>
</div>
<div id="outline-container-org3e2966e" class="outline-3">
<h3 id="org3e2966e">Default</h3>
<div class="outline-text-3" id="text-org3e2966e">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">EDITOR</span>=<span class="org-string">"nvim"</span>
<span class="org-builtin">export</span> <span class="org-variable-name">TERMINAL</span>=<span class="org-string">"termite"</span>
<span class="org-builtin">export</span> <span class="org-variable-name">BROWSER</span>=<span class="org-string">"qutebrowser"</span>
<span class="org-builtin">export</span> <span class="org-variable-name">READER</span>=<span class="org-string">"zathura"</span>
<span class="org-builtin">export</span> <span class="org-variable-name">FILE</span>=<span class="org-string">"ranger"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org5ea13c1" class="outline-3">
<h3 id="org5ea13c1">Exports</h3>
<div class="outline-text-3" id="text-org5ea13c1">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">TERM</span>=xterm-256color
</pre>
</div>
</div>
<div id="outline-container-org1a74001" class="outline-4">
<h4 id="org1a74001">XDG Default</h4>
<div class="outline-text-4" id="text-org1a74001">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">XDG_CONFIG_HOME</span>=<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">HOME</span></span><span class="org-string">/.config"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org117a776" class="outline-4">
<h4 id="org117a776">Better yaourt colors</h4>
<div class="outline-text-4" id="text-org117a776">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">YAOURT_COLORS</span>=<span class="org-string">"nb=1:pkg=1:ver=1;32:lver=1;45:installed=1;42:grp=1;34:od=1;41;5:votes=1;44:dsc=0:other=1;35"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org684e85f" class="outline-4">
<h4 id="org684e85f">Use Ripgrep for FZF</h4>
<div class="outline-text-4" id="text-org684e85f">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">FZF_DEFAULT_COMMAND</span>=<span class="org-string">'rg --files --no-ignore --hidden --follow --glob "!.git/*"'</span>
<span class="org-builtin">export</span> <span class="org-variable-name">FZF_DEFAULT_OPTS</span>=<span class="org-string">'--layout=reverse --height=20'</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org545dc00" class="outline-4">
<h4 id="org545dc00">Goland</h4>
<div class="outline-text-4" id="text-org545dc00">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">GOPATH</span>=$<span class="org-variable-name">HOME</span>/go
</pre>
</div>
</div>
</div>
<div id="outline-container-orgeca4d01" class="outline-4">
<h4 id="orgeca4d01">SSH Agent</h4>
<div class="outline-text-4" id="text-orgeca4d01">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">SSH_AUTH_SOCK</span>=<span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{XDG_RUNTIME_DIR}</span></span><span class="org-string">/ssh-agent.socket"</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org3b15f2e" class="outline-3">
<h3 id="org3b15f2e">Path</h3>
<div class="outline-text-3" id="text-org3b15f2e">
<div class="org-src-container">
<pre class="src src-bash"><span class="org-variable-name">PATH</span>=$<span class="org-variable-name">HOME</span>/appimages:$<span class="org-variable-name">PATH</span>
<span class="org-variable-name">PATH</span>=$<span class="org-variable-name">HOME</span>/.gem/ruby/2.5.0/bin:$<span class="org-variable-name">PATH</span>
<span class="org-variable-name">PATH</span>=$<span class="org-variable-name">GOPATH</span>:$<span class="org-variable-name">GOPATH</span>/bin:$<span class="org-variable-name">PATH</span>
<span class="org-variable-name">PATH</span>=~/bin:$<span class="org-variable-name">PATH</span>
<span class="org-variable-name">PATH</span>=~/.emacs.d/bin:$<span class="org-variable-name">PATH</span>
<span class="org-builtin">export</span> PATH
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
<p class="date">Created: 2020-01-11 sam. 22:00</p>
</div>
</body>
</html>