Newer
Older
1
2
3
4
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
48
49
50
51
52
53
54
55
56
57
58
59
60
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
# Terminals and Shells
## Content ideas
### 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*
- 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`)