« first day (14 days earlier)      last day (36 days later) » 
14:00 - 16:0016:00 - 21:00

16:00
Brain overflow is off topic here. We only answer questions about Ubuntu.
3
@terdon lol
@jokerdino hugs
we can do another 15 minutes and keep the remaining for the next day/weekend?
yes, there is loads more. Let's go on for a bit and find a good place to stop, and schedule another class for the rest?
16:02
@Zanna ok..
I'm OK
Me too
same here
OK
:)
You can pass variables into the environment with the export command.
For example, you can export foo. This causes all child processes of the shell where you run export to know about that variable. You can change the value later and the change will also be passed to child processes (so you only need to export a variable once).
liah Kagan gave me a nice example for this. The handy GNU date command will look for the TZ variable, and use it if it is set, which it probably is not on your system yet. Try running it
date
zanna@peach:~/playroom$ date
Sunday 11 October 2020 09:34:15 PM IST
16:04
what's a TZ?
@Zanna Sun Oct 11 19:34:36 +0330 2020
some kind of animal? or could it be a time zone? or maybe a variable that we haven't set yet
Sun Oct 11 12:04:23 EDT 2020
Sun 11 Oct 19:04:24 EEST 2020
Now try running it like this
TZ=UTC date
16:05
Sun 11 Oct 16:05:48 UTC 2020
This syntax is very useful - you can run one command with variable=value by prepending it with variable=value like that.
Sunday 11 October 2020 04:05:44 PM UTC
Sun Oct 11 16:06:00 UTC 2020
@Zanna Sun Oct 11 16:06:04 UTC 2020
now run date again
16:06
Sun Oct 11 16:05:48 UTC 2020
@Zanna Back to:
Sun Oct 11 12:06:23 EDT 2020
Back to the previous
Now try this:
TZ=UTC
date
no changes
yes, same again
16:07
Sun Oct 11 19:37:13 +0330 2020
it is what it is
you have set TZ for the shell - you can echo $TZ, but `date doesn't know about it
so now run export TZ
zanna@peach:~/playroom$ export TZ
zanna@peach:~/playroom$ date
Sunday 11 October 2020 04:08:23 PM UTC
Magic!
16:08
:)
(great example BTW)
credit to @EliahKagan
now change it again:
we are all in same time zone now
TZ=Asia/Hong_Kong
and again run date
@jokerdino :)
@Zanna Thanks @EliahKagan
16:10
Thanks EK
It changed
That's very kind, but I only contributed the idea to demonstrate environment variables by running date with TZ set, not the specific progression of commands and explanation -- which is actually better than the way I have shown people, and I shall be linking to it here, I think, to help people in the future.
Mon 12 Oct 00:10:22 HKT 2020
@user3140225 I should be sleeping then..
Can we try something like TZ=Asia/Kolkata?
16:11
@user3140225 yes :) that demonstrates that you don't have to export again after changing the value - the date command got the update. This is always the case when you change an environment variable - you don't have to export a variable that is already in the environment, you can just assign a new value to it (although nothing bad happens when you unnecessarily export a variable that is already exported).
@technastic_tc sure, but I guess that's what you had at the start?
I mean, at the start you had IST
But how can we go back to the default?
yes I want to go home
I am stuck in HK now
@Zanna yeah.. let's say we don't know what the TZ variable is equal to. How do we find it?
hahaha well you can close the terminal and open a new one
or you can run unset TZ
16:13
Bash also has export -n
@technastic_tc we are totally coming to that!
@jokerdino Wouldn't be bad
@EliahKagan what does it do?
If you want to keep the shell variable set but unexport it.
@EliahKagan neat!
You can also run export variable=value, combining the two steps of assigning a value to a variable and passing it into the environment into one step. So instead of doing TZ=UTC and then later export TZ, We could have just run export TZ=UTC
Note that if you open a new terminal, the shell that opens won't be a child of the shell you exported from, so it will not know about that variable. To set an environment variable that all shells will know about, you could export it in .profile.
There is a command that lists only environment variables - it is printenv
try running it without any arguments
whole lot of stuff
16:15
a lot of stuff
I've just noticed that the value of my LS_COLORS environment variable is quite long. :)
If you want to know the value of a particular environment variable, or know whether it is set, you can run, for example, printenv TZ (@technastic_tc)
@EliahKagan same here - more than 11 lines on the full screen
same for a bunch of them, like printenv USER HOME PATH
@Zanna I got no ouput..
yeah same
@technastic_tc did you unset TZ earlier?
16:18
@Zanna nope.. May be that's why..
If TZ is set and exported, printenv TZ should print its value.
@technastic_tc oh haha I was expecting you to say yes
I reopened a new terminal, oops
@jokerdino that explains it :)
I don't have TZ set by default
date gets its information from somewhere else if TZ isn't set, not sure where but maybe /etc/timezone
@technastic_tc did you open a new terminal?
how do I find out what kind of time zones are available for me to set?
16:21
@Zanna no.. I didn't change the TZ values..
@jokerdino that's a damn good question. I found out on Wikipedia but maybe there is something in the system
@technastic_tc ok, anyway it will most likely just be unset by default for you, like it is for me
@jokerdino Look in: /usr/share/zoneinfo
@jokerdino locale -a will list the ones you have generated on your system, the ones that can be used now.
Ah sorry. That's locales in general not timezones.
@jokerdino Or here
good stuff, thanks all
16:23
Sorry for not allowing enough time
@technastic_tc Is echo $TZ printing anything?
@EliahKagan UTC
But printenv TZ does not print anything?
@EliahKagan yeah
Then it seems to be set as a shell variable but not exported as an environment variable.
16:24
yes, needs to be exported I think
When you run date by itself, is the output affected by the value of TZ?
Like, is it in UTC?
Sunday 11 October 2020 09:55:07 PM IST
I suppose we can wrap it up for the day with the session.
Yeah, it's set but not exported.
@jokerdino Ok.. Bye!
16:27
We can continue another day with the lesson, if folks are interested
@technastic_tc export TZ=UTC
Or just export TZ since it's set.
@Zanna Sure.
@Zanna Of course!
great stuff so far
:) any suggestions for a day? We could continue same time next week
16:28
thanks @Zanna for the lesson
thank you @Zanna
@Zanna yes next week same time would be great
@jokerdino I closed the terminal...
@Zanna Should be good for me
Is the first topic for next time the difference between things like $TZ and "$TZ"? (I'm not saying it has to be, I'm just wondering.)
16:29
Same time next week works for me.
why am I running date command to know the time though?
Yes, that's fine for me.
Thanks @Zanna for the session. Thanks @EliahKagan and @jokerdino for supporting Zanna!
Thanks @Zanna!
@EliahKagan it could be..
16:30
@Zanna That was an awesome lesson! Looking forward for the next one!
@EliahKagan that comes a bit later due to jumping around a bit trying to create some files to play with... I'll have to think about how best to resume though so it can get rearranged
Thanks @Zanna for hosting the session.
Thank you so much for participating @αғsнιη @karel @user3140225 @EliahKagan @jokerdino @technastic_tc @terdon and anyone else who was here - you have been awesome!
@jokerdino If you want to know how long date takes to tell you the date and time then you could time it with time by running time date. :)
3
Thanks everyone for making this lesson a grand success. @αғsнιη @EliahKagan @karel @user3140225 @Zanna @technastic_tc
16:32
@jokerdino Thank you for organizing the lessons and for your input here today and yesterday!
3
@user3140225 :) :)
@Zanna @jokerdino you're welcome.
@EliahKagan oooh
@EliahKagan Suggesting the date example was great!
Thanks. :)
16:34
Zanna has added an event to this room's schedule.
@jokerdino There's also an external command called time. If you want to time with the time builtin how long the external time command takes to run date to time how long date takes then you could run time command time date (or time \time date).
@user3140225 you are giving me too much credit for doing nothing here haha
@jokerdino Your comments made my day!
@EliahKagan O_O
16:38
@Zanna All I did was make one wrong suggestion and one snide remark. But hey, you're welcome, any time! :P
@terdon haha it all helps!
@jokerdino Sorry, I made a mistake in saying "the time builtin." time in bash is actually a shell keyword (per type time) rather than a shell builtin, which is necessary so that it can be used to time any pipeline.
On a more serious note, I'm afraid I'm working full tilt these days dealing with a crisis at work, so I couldn't participate as I'd have liked to. But here's one nifty tip that makes my life on the command line much easier:
Open the file $HOME/.inputrc in your favorite editor (e.g. nano ~/.inputrc) and add these two lines:
"\e[A": history-search-backward
"\e[B": history-search-forward
Now, save and close the file and open a new terminal. You know how hitting the Up button cycles through the command history? Now, with these lines, if you start typing and then press the Up, only commands that started with what you've typed will be shown. This makes it very easy to find the specific commands you were after.
yeah, I don't know what that isn't always on by default. It's brilliant.
16:43
I rarely edit .inputrc and I don't know its syntax. On some systems I don't have that file in my home directory. When I create it, do I need to source/include/whatever another file to retain all the other behavior?
I seem to recall something about this but I don't know if that's true.
Like, does it still also use /etc/inputrc if ~/.inputrc is present?
@EliahKagan Yes. Or, at least, I believe so. I know that I've been using the same ~/.inputrc for years and I've never had any issues. It also makes sense that it would work like other rc files: your ~/.foorc will be read last, so anything in there will overwrite stuff from the system files, but if you haven't explicitly changed a setting, the original one from the system file will be in effect.
The other ones I use a lot are Alt+Left and Alt+forward to move one word backwords or forwards respectively
"\e[1;3D": backward-word ### Alt left
"\e[1;3C": forward-word ### Alt right
I find those easier to use than the default Alt+b and Alt+f
@terdon awesome!
/etc/inputrc on my system (probably on all Ubuntu systems?) has:
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
So I think I'll source/include /etc/inputrc in my new custom ~/.inputrc to keep that and other default goodies while also having that nice functionality. (Since I've just tested and found that I lose that behavior when I have my own ~/.inputrc.) Now I just have to look up now to do that...
@EliahKagan Wait what? What did you lose?
@terdon By default I can use Ctrl+right/left for this
16:51
@terdon When I don't have a ~/.inputrc file, Ctrl+Left and Ctrl+Right move left and right one word. When I do have it, they print ;5D and ;5C instead. I presume the other stuff in /etc/inputrc is likewise not run when I have an .inputrc in $HOME. But I recall there is some way to source /etc/inputrc in ~/.inputrc. I'd rather do that than copy its contents.
@user3140225 Yes, I just find Alt more intuitive for some reason. But that's a very personal preference.
Unfortunately, code fences don't work in chat. You can indent four spaces though. If you have more than one line in a message, the UI adds a "fixed font" button (to the right of the "upload..." button) to automatically indent every line of the message by four spaces.
@EliahKagan huh. That seems very strange. I guess the simplest solution would be to combine them:
cat /etc/inputrc > ~/.inputrc && printf '\n"\e[A": history-search-backward\n"\e[B": history-search-forward\n' >> ~/.inputrc
$include /etc/inputrc
set completion-ignore-case On
set colored-completion-prefix On
set colored-stats On
set show-all-if-ambiguous On
set show-all-if-unmodified On
set mark-symlinked-directories On
set menu-complete-display-prefix On
"\t": menu-complete
"\e[Z": menu-complete-backward
"\e[A": history-search-backward
"\e[B": history-search-forward
Ah no. hang on, I'm beeing stoopid
16:55
23
A: How to call a "sub" .inputrc? (Like in .bashrc, where you can "source sub_script.sh")

Arkadiusz DrabczykAccording to man readline: $include This directive takes a single filename as an argument and reads commands and bindings from that file. For example, the following directive would read /etc/inputrc: $include /etc/inputrc

set completion-ignore-case On is the most useful option in my opinion
@user3140225 Eh, you're used to Windows :) That is a feature, not a bug for me. I don't want FOO and foo to be the same thing.
@EliahKagan this should work:
    cat /etc/inputrc > ~/.inputrc && printf '\n"\\e\[A": history-search-backward\n"\\e\[B": history-search-forward\n' >> ~/.inputrc
I tried the way in Arkadiusz Drabczyk's answer and it worked.
The contents of my ~/.inputrc are now:
$include /etc/inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
@terdon Not at all! With the above .inputrc I can cycle between foo and FOO using Tab
@EliahKagan Ah yes. Much better. Mine was hacky, I just didn't know what the "source" equivalent was for the inputrc world.
17:00
Yeah, I had to search a bit to find it.
@user3140225 Yes, I know. I do not want that. At all.
@terdon Yeah. That's a matter of taste
I have been using case-sensitive file systems for near on 20 years now, so I really don't want to have case insensitive matching.
@user3140225 Exactly. I completely understand why you might want it. It just isn't for me.
@terdon thank you, for me doesn't work, I don't know why, maybe again WSL issue?
17:04
Very possibly, yes. WSL is a complete unknown for me.
It isn't Linux, so it is bound to behave in different ways.
when sourcing .inputrc for every entries saying …. command not found
Speaking of ignoring case, I noticed something during the lesson that I either never knew or had forgotten: man runs less with the -i option (by putting it in $LESS), so searching with / and ? is case-insensitive. Something else that I probably should've known but didn't is, you can specify options interactively, while less is running, by typing something that starts with a -. So I can make less have case-insensitive searching while it's already running by typing -i in it.
cool!
@αғsнιη what command exactly did you type?
I'm not finding a way to make it case-sensitive again though...
@terdon WSL2 uses an actual Linux kernel (unlike WSL1). There are still some ways that it's weird, though.
@Zanna 'source ~/.inputrc'
17:09
Oh.
inputrc does not consist of commands that can be run in a shell.
It's used by GNU readline, a library that various programs -- including bash -- use to provide commad-line interactivity. It has its own syntax.
@EliahKagan Ohhh, you are right, totally didn't know that, my bad
after reopening WSL it worked, thanks
@EliahKagan The Linux bit is probably Linux, yes. I was (mis)using the word "Linux" to mean "GNU/Linux Operating System", meaning all the various bits and bobs and file locations and home dirs etc. Those I would expect to change since they have nothing to do with the kernel.
Ah.
A WSL system has its own filesystem, with mount points to access stuff in the Windows system outside of it. So within the WSL system, most userland stuff is in the expected places.
Though it's set up in such a way that PATH lookup also finds Windows programs (which can be run from inside the WSL system... sometimes with the desired effect), and that's fairly weird.
The one (intentional) use I've found for that is to redirect or pipe to clip.exe.
17:38
@EliahKagan definitely
17:55
Hang on, @EliahKagan. Are you telling me that you, of all people, are a Windows user?
@terdon I have Windows on one of my machines, yes.
:'(
At least it isn't your main OS, right?
(and no, I'm not being at all serious, in case anyone was wondering)
18:53
@terdon It is not. Although... while I use Lubuntu somewhat more than Windows, it is perhaps not by enough for me to say that any OS is my main OS.
@terdon (no worries -- it had not occurred to me that you were :)
 
1 hour later…
20:05
@Zanna Should it just be called part 2? And then part 2 can be called part 3?
14:00 - 16:0016:00 - 21:00

« first day (14 days earlier)      last day (36 days later) »