Newer
Older
# Terminals and Shells
## Content ideas
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
### The why and a general comparison of TUI vs GUI
- why use terminal
- only option
- maths compute server doesn't allow you to remote desktop
- related being light processes (no gui overhead)
- base way of manipulating files and processes
- making, moving, renaming... files and folders (directories)
- modify environment variables
- string together multiple processes
- automating, scheduling
- launching scripts
- cron
- motivations for those *nerds*
- whole keyboard becomes buttons
- learning curve
- possible increase in efficiency
- minimalism: programs, typically lighter and faster
- want to look like a hacker
- a look at gui alternatives
- benefits
- some things are just better
- ui not limited to grid of characters
- insert quote Bram Molenaar about gvim
- example of git operations
- browse log and revert to a specific revision
- TUI: multi-step operation involving copying hash
- GUI: look at log, click on revision, choose hard revert
- alt to text scripting
- visual editors
- example: website making
- wix
- adobe dreamweaver
- drawbacks
- when it's an abstraction on text:
- extra dependency
- cost
- difficulty moving
- potentially less flexible
- RPA (robotic processes automation)
- program that automates interactions with GUIs
- scripting alternative usually simpler/robust when possible
### General knowledge
- Linux/unix
- bash
- other shells
- new: zsh
- new default on mac
- trendy on linux
- old
- (bourne) shell
- predecessor of bourne again shell (bash)
- broadly a subset other shells *modulo edge case behaviours*
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
- case for targeting this shell for portability (`dash` is also quite fast)
- EXERCISE
- ksh, csh, tcsh, scsh
- not very common
- exist on some machines for legacy, licensing reasons
- FreeBSD license is too liberal to include bash in the install
- shells straying away from sh (fish)
- attempt to give better interactive experience
- not great solution for scripting
- the pros don't carry over to scripting
- less portable
- Windows
- cmd.exe
- behaves similarly to unix shells
- manipulates:
- processes (from executables)
- inputs and outputs (typically text): stdin(0), stdout(1), stderr(2)
- arguments to executables
- environment variables
- the skin is different
- different commands
- which -> where
- ls -> dir
- mv -> move
- rm -> del
- different env vars
- $PWD -> %CD%
- $HOME -> %USERPROFILE%
- many things are more
- Cygwin/similar
- bash but in windows
- allows things built on linux to be ported to windows
- SageMath
- Lean3
- Maxima
- powershell
- available on Linux (powershell core)
- (ba)sh commands available
- looks are deceiving, cmd works much more similarly to unix shells
- "powershell is great, but only when there exists a cmdlet for what you want to do"
### Practical tips
- Terminal troubleshooting
- Can't find program?
- test `which/where program_name`
- executable must be in PATH to be found
- immediate fix attempt
- find executable, paste whole thing into terminal
- May fail if process expects other env vars to be set
- add executable locations to PATH (global/user installation)
- Installers in windows usually have an option to "add to path" = "allow terminal usage"
- linux, mac: `~/.bashrc` `~/.zshrc`
- windows: start > search "environment variables"
- activate some environment
- Some programs expect an "environment" to be set before using
- linux, mac: `. <smth>`
- virtual environments
- conda
- pipenv (python)
- windows MSVC or other software suite expecting you to open specific terminal profile
- terminal bugging out in program (colours/icons/text placement)
- processes control colours and text placement via special chars in output, which requires a standard (which have evolved)
- aside: illustrate difference between bash/terminal
- problem: misunderstanding between process/shell and terminal
- new terminal + old program : SSHing onto old machine
- typical fix: `export TERM=xterm`
- old terminal + new program : using trendy software in `cmd.exe`
- windows terminal
- different terminal font
- other evironment variables (`COLORTERM`, `LANG`)