I needed an alias to show some code to copy, paste and edit without leaving the terminal.
Thanks to this thread https://unix.stackexchange.com/question ... mmand-line I found "tail filename.txt" .
I made an alias with 'tail /root/.bashrc' and placed the code to be modified at the bottom of my bash.rc file.
The last 12 lines of bash.rc appear in the terminal and I am back to the prompt.
Hope this is useful to someone.
Vic
An alias to show bash.rc text
- Rava
- Contributor
- Posts: 5416
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
An alias to show bash.rc text
^
https://unix.stackexchange.com is indeed your friend.
I <B the many alternatives that are given in https://unix.stackexchange.com/question ... mmand-line and also this
Since I have lots of aliases and functions, I have them in their own file:
As you can see, currently it holds 37 aliases and 15 functions:
The "^" is a special character meaning "beginning of a line" (while "$" would be the special character meaning "end of a line") More precise it means "start / end of the string" but in this case, that is also "start / end of a line"
And it is auto-loaded for guest and root via this snippet in their respective .bashrc :(Since I do not check if /usr/local/bin/aliasset is available that would produce an error if its not available; but on all of my systems that's not an issue since I use aliasset longer than Porteus exists. Currently its version is "V3.6.47 (2023-10-20)")
And out of security-reasons, aliasset is readable by guest, but only writeable by root:Having the aliases and functions in their own external file has one more advantage: when I created a new alias or a new function and added it to an updated aliasset, I can load that into one already running terminal via a simple
Typed that is a mere
. /u[TAB]lo[TAB]b[TAB]ali[TAB]
And when there would be some error or syntax error in the newest created /usr/local/bin/aliasset - executing . /usr/local/bin/aliasset would only give an error on that one terminal, and in the worst case scenario would only mess up that one terminal. Then I repair the coding error in /usr/local/bin/aliasset or revert it to its previous version, and all is good. The other already running terminals or virtual terminals are not affected.
────────────────────────────────────────────────────────────────────────
More on special characters and regex in general I collected in my help.regex help script:(The original help.regex makes coloured output but that cannot be displayed using [ code ] )
HTH.
https://unix.stackexchange.com is indeed your friend.
I <B the many alternatives that are given in https://unix.stackexchange.com/question ... mmand-line and also this
(highlighting by me) - these are my precise reasons for using less that often.I always use $ less "your file here" , as it is very simple, provides a built in interactive grep command, and gives you an easy to use interface that you can scroll with the arrow keys.
Since I have lots of aliases and functions, I have them in their own file:
Code: Select all
guest@rava:~$ /bin/ls -o --time-style=long-iso /usr/local/bin/aliasset | cut -c 19-$(expr 18 + $(tput cols))
10619 2023-10-20 11:33 /usr/local/bin/aliasset
Code: Select all
guest@rava:~$ grep "^alias " /usr/local/bin/aliasset|wc
37 168 1882
guest@rava:~$ grep "^function " /usr/local/bin/aliasset|wc
15 237 1703
And it is auto-loaded for guest and root via this snippet in their respective .bashrc :
Code: Select all
guest@rava:~$ grep aliasset .bash*
.bashrc:. /usr/local/bin/aliasset
And out of security-reasons, aliasset is readable by guest, but only writeable by root:
Code: Select all
guest@rava:/usr/local/bin$ ls -l aliasset
-rw-r--r-- 1 root root 10619 2023-10-20 11:33 aliasset
Code: Select all
guest@rava:~$ . /usr/local/bin/aliasset
. /u[TAB]lo[TAB]b[TAB]ali[TAB]
And when there would be some error or syntax error in the newest created /usr/local/bin/aliasset - executing . /usr/local/bin/aliasset would only give an error on that one terminal, and in the worst case scenario would only mess up that one terminal. Then I repair the coding error in /usr/local/bin/aliasset or revert it to its previous version, and all is good. The other already running terminals or virtual terminals are not affected.
────────────────────────────────────────────────────────────────────────
More on special characters and regex in general I collected in my help.regex help script:
Code: Select all
guest@rava:~$ help.regex
help.regex V0.1
Character classes
. any character except newline
\w \d \s word, digit, whitespace
\W \D \S not word, digit, whitespace
[abc] any of a, b, or c
[^abc] not a, b, or c
[a-g] character between range from a to g
Anchors
^abc$ start / end of the string
\b \B word, not-word boundary
Escaped characters
\. \* \\ escaped special characters
\t \n \r tab, linefeed, carriage return
\u00A9 unicode escaped (c)
Groups & Lookaround
(abc) capture group
\1 backreference to group #1
(?:abc) non-capturing group
(?=abc) positive lookahead
(?!abc) negative lookahead
Quantifiers & Alternation
a* a+ a? 0 or more, 1 or more, 0 or 1
a{5} a{2,} exactly five, two or more
a{1,3} between one & three
a+? a{2,}? match as few as possible
ab|cd match ab or cd
HTH.
Cheers!
Yours Rava
Yours Rava
-
- Samurai
- Posts: 122
- Joined: 10 Aug 2016, 05:36
- Distribution: Porteux V-0.1 64 KDE
- Location: Utopia in Tampa, Florida, USA
An alias to show bash.rc text
Hi Rava.
You blow me away man.
Vic
You blow me away man.
Vic
- Rava
- Contributor
- Posts: 5416
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
An alias to show bash.rc text
I hope in good way.
And I presume it is correct when I state that I love using the terminal. It makes automatisation easy and automatisation is the main reason computers were created in the first place.
Cheers!
Yours Rava
Yours Rava
-
- Samurai
- Posts: 122
- Joined: 10 Aug 2016, 05:36
- Distribution: Porteux V-0.1 64 KDE
- Location: Utopia in Tampa, Florida, USA
An alias to show bash.rc text
Yes. It is a good "hippie" thing from my younger days in the United States. It means WOW!!! man.
Vic
Vic